联系我们:416326801#qq.com(#改成@)

img1

Linux增加新硬盘扩展VolGroup空间大小

887 Views 标签: Shell Linux

fdisk -l | grep dev
#硬盘分区,创建1个分区
fdisk /dev/sdc
n
p
1
#回车,默认值
#回车,默认值
w
#建立物理卷 
pvcreate /dev/sdc1
#把新物理卷加入到卷组中去
vgextend VolGroup /dev/sdc1
#把新的空间加到逻辑卷中去
lvextend -L +40G /dev/mapper/VolGroup-lv_root
#激活之后用df -h就可以看到了
resize2fs -p /dev/mapper/VolGroup-lv_root
df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root   77G   36G   38G  49% /
tmpfs                         935M     0  935M   0% /dev/shm
/dev/sda1                     485M   32M  428M   7% /boot

已有的lv逻辑卷,把所有剩余空间都加到逻辑卷

#把所有剩余空间加到逻辑卷中去
lvextend -l +100%FREE /dev/mapper/VolGroup-lv_root
新的lv逻辑卷
lvcreate -l +100%FREE -n home VolGroup
mkfs.ext3 /dev/VolGroup/lv_home
mkdir /home
mount /dev/VolGroup/lv_home /home
df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       18G  671M   16G   5% /
tmpfs                 3.9G     0  3.9G   0% /dev/shm
/dev/vda1             477M   32M  420M   8% /boot
/dev/mapper/VolGroup-lv_home
                       99G  188M   94G   1% /home
修改/etc/fstab,开机自动挂载
/dev/mapper/VolGroup-lv_root /                       ext4    defaults        1 1
UUID=de016c21-a3a6-43f1-89e3-046f55d67ade /boot                   ext4    defaults        1 2
/dev/mapper/VolGroup-lv_swap swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/mapper/VolGroup-lv_data /data                       ext4    defaults        1 2

重新挂载

umount -a & mount -a

如果觉得我的文章对您有用,打赏一下呗.

wxpay.png