Online EXT4 on LVM resize
Have such partitions/volumes/mountpoints:
=$ LC_ALL=C df -hP | column -t
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg0-rootlv 19G 854M 17G 5% /
/dev/mapper/vg0-homelv 19G 343M 18G 2% /home
/dev/mapper/vg0-optlv 19G 192M 18G 2% /opt
/dev/mapper/vg0-varlv 19G 357M 18G 2% /var
Question is: how can I grow /home and /var partitions (to 100GB and 400GB respectively)?
Is it safe to do it online with database running on this server?
Solution 1:
First check if you have free space in volume group:
vgs
then resize the volumes:
lvresize -L 400G /dev/mapper/vg0-varlv lvresize -L 100G /dev/mapper/vg0-homelv
and resize the filesystems residing on them:
resize2fs /dev/mapper/vg0-varlv resize2fs /dev/mapper/vg0-homelv
I have to note though that resizing a partition from 20GB to 400GB will make your inodes quite sparse. If it is at all possible I strongly recommend creating new volumes with new filesystems and moving data there. You can copy the files during normal operation and then just rsync the changed files to new partition during downtime.