为 Centos 硬盘添加新分区

为 Centos 硬盘添加新分区

我的硬盘目前有(我相信)2 个分区;启动(sda1)和其他所有分区(sda2?)。部分硬盘还被用作交换内存,但我真的不明白这会有什么影响。服务器是物理的,我有一张 LiveCD。

如何向硬盘添加新分区(1 MB,ext3),并使 sda2 更小以适应新分区?

对于 lvm、/dev/mapper 以及 dm-0 和 dm-1 如何应用的任何额外评论都将受到欢迎,但这不是必须的。

谢谢

[root@desktop ~]# mount
/dev/mapper/vg_desktop-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) 

[root@desktop ~]# fdisk -l /dev/sda

Disk /dev/sda: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00056f9a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64      182402  1464625152   8e  Linux LVM

[root@desktop ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg_desktop/lv_root
  LV Name                lv_root
  VG Name                vg_desktop
  LV UUID                DhBjdq-0UJR-dJjx-bgH6-adGJ-TL43-8DrZR7
  LV Write Access        read/write
  LV Creation host, time desktop.xxx.com, 2013-07-01 04:10:19 -0700
  LV Status              available
  # open                 1
  LV Size                1.36 TiB
  Current LE             356082
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     1024
  Block device           253:0

  --- Logical volume ---
  LV Path                /dev/vg_desktop/lv_swap
  LV Name                lv_swap
  VG Name                vg_desktop
  LV UUID                mNpyae-UtdA-MzJR-bbEc-D9OA-VPn8-ECMpbq
  LV Write Access        read/write
  LV Creation host, time desktop.xxx.com, 2013-07-01 04:13:25 -0700
  LV Status              available
  # open                 1
  LV Size                5.83 GiB
  Current LE             1492
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     1024
  Block device           253:1

[root@desktop mapper]# ls -l /dev/mapper
total 0
crw-rw----. 1 root root 10, 58 Jul  4 00:37 control
lrwxrwxrwx. 1 root root      7 Jul  4 00:37 vg_desktop-lv_root -> ../dm-0
lrwxrwxrwx. 1 root root      7 Jul  4 00:37 vg_desktop-lv_swap -> ../dm-1
[root@desktop mapper]#

答案1

您需要缩小现有组以便lvreduce为新卷腾出空间。然后,您可以使用:

lvcreate -L 3G -n <lvname> vg_desktop其中 3G 是您希望卷的大小。然后:

mkfs -t ext3 /dev/vg_desktop/<lvname>对其进行格式化。最后,使用 将其挂载mount -t ext3 /dev/vg_desktop/<lvname> /mnt/somedir

相关内容