Resizing of Logical Volume on live Ubuntu Server

One of the logical volumes of an Ubuntu Server machine needs to be resized (enlarged) in order to be able to handle the amount of data to be stored. This should happen without having to shut down the web server which is currently running on this machine.

Taggings:

1 answer

Enlarging logical volumes

First, the current status of the logical volume to be resized can be monitored with

sudo lvdisplay

or, alternatively,

sudo lvs

which results in something like:

--- Logical volume ---
LV Name /dev/server/data
VG Name server
LV UUID 5t0OX9-sLc9-jPHb-k4zk-2RnE-fTzB-qjQ3qN
LV Write Access read/write
LV Status available
# open 1
LV Size 1,46 TiB
Current LE 384000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:3

or

LV VG Attr LSize Origin Snap% Move Log Copy% Convert
data server -wi-ao 1,46t

respectively.

Afterwards, the logical volume can be resized using

sudo lvextend -L 100G /dev/server/data

or

sudo lvextend -L +100G /dev/server/data

In the first case, the logical volume is set to exactly 100 Gigabyte, whereas in the second command 100 Gigabyte are added to the current size of the logical volume.

Finally it is necessary to also set the filesystem to the new size of the volume group, as this is not done with the commands above. This can be done

for ext2/ext3/ext4 file systems with

sudo resize2fs -p /dev/server/data

for JFS file systems with

sudo mount /mountpoint -o remount,resize

for XFS file systems with

sudo xfs_growfs /mountpoint

All other file systems cannot be resized while the machine is still online!