增加Ubuntu LVM分区
-
Start by creating a new partition from the free space. I prefer doing this with a GUI using
gparted
. You need XQuartz if you’re on a Mac.
- SSH into the box with -X, e.g. ssh -X myserver
- Install gparted: apt-get install -y gparted and run gparted
- Find the unallocated space (a grey bar)
- Select and create partition. Choose lvm2 pv as the “file system”
- Click OK
- Click Apply in the toolbar and again in the dialog
- Note the disk name in the Partition column, e.g. /dev/sda3
-
You should see the disk with fdisk -l
-
Run pvcreate
, e.g. pvcreate /dev/sda3 -
Find the volume group: run vgdisplay (name is where it says VG Group)
-
Extend the VG with the disk: vgextend
, e.g. vgextend VolumeGroup /dev/sda3 -
Run vgscan & pvscan
-
Run lvdisplay to find the LV Path, e.g. /dev/VolumeGroup/root
-
Extend the logical volume: lvextend
, e.g. lvextend /dev/VolumeGroup/root /dev/sda3 -
Resize the file system: resize2fs
, e.g. resize2fs /dev/VolumeGroup/root -
Finally, verify that the size of the partition has been increased with df -h