пятница, 27 ноября 2015 г.

Linux LVM Root VG extension

# fdisk -l
To see the new disk size on /dev/sda which we just extended, or to see new disks we just presented (/dev/sdb, /dev/sdc, etc.)
# fdisk /dev/sda
To create new partitions for the OS to use. These new partitions will be added to the VG so we can extend the LV that the “/” partition is on. My newly created partition in the example is /dev/sda3. For new disks you would use /dev/sdb, or /dev/sdc. If you are using an extended /dev/sda like in my case, you will need to reboot for the changes to be seen
# fdisk -l
To see the new partitions
# pvdisplay
View current physical volumes a.k.a. pv
# pvcreate /dev/sda3
Allow Linux OS to use the new partition in LVM
# pvdisplay
See the new pv /dev/sda3
# vgdisplay
View the current volume groups
# vgextend VolumeGroupName /dev/sda3
Add the new PV /dev/sda3 to the existing VG VolumeGroupName
# vgdisplay
Now you can see the new size of the VG VolumeGroupName. Note the new amount of free PE’s (physical extents)
# lvdisplay
View the current LV. In my example, /dev/VolumeGroupName/lv_root which is the root partition
# lvextend -l +2559 /dev/VolumeGroupName/lv_root
Now make the LV larger. Growing the LV /dev/VolumeGroupName/lv_root by 2559 PEs
# lvdisplay
Now you can see the larger size of the LV
# resize2fs /dev/VolumeGroupName/lv_root
Online resize of the actual filesystem now on that LV
# df -h
You can see the new size now using the “df” command