Disc volume expansion in OS Linux with LVM
After increasing the server disc size of virtual server it is necessary to make it available for the operational system.
Open the ssh terminal under the root user and enter the following commands:
echo 1 > /sys/block/sda/device/rescan
View current LVM sections
With the help of utility «parted» see the full disc size and the divisions available:
parted /dev/sda print
Model: xxxxx
Disk /dev/sda: XX.XGB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 256MB 255MB primary ext2 boot
...
N ---- YY.YGB ZZ.ZGB primary lvm
Store the beginning of the new YY.YGB section, it is usually the last one
Create the new section by the utility parted:
parted -s /dev/sda mkpart primary YY.YGB 100%Check the created section by the utility parted:
parted /dev/sda print
Model: xxxxxx
Disk /dev/sda: XX.XGB
...
Number Start End Size Type File system Flags
...
Y XX.XGB XX.XGB XX.XGB primary
Store the created section number - Y, convert it into LVM section
parted -s /dev/sda set Y lvm on
Initialize LVM section
Initialize the new section for the use in LVM:
pvcreate /dev/sdaY
Writing physical volume data to disk "/dev/sdaY"
Physical volume "/dev/sdaY" successfully created
Add the new section to the LVM group:
vgextend lvm-vg /dev/sdaY
Volume group "lvm-vg" successfully extended
Increase the size of LVM logical volume:
lvextend -l +100%FREE /dev/lvm-vg/root
Extending logical volume root to XX.XX GiB
Logical volume root successfully resized
Increase the size of file system:
resize2fs /dev/lvm-vg/root
It is ready for service.