baumi's blog

baumi's personal blog … Linux, OS X, Windows, Random things, …

Useful tools & commands for resizing/growing LVM based disks/filesystems …

gparted … https://www.gnu.org/software/parted/ https://gparted.org/download.php

first boot into gparted, rightlick on the locked LVM areas and click “disable”. the lock disappears. then resize them to maximum, then open terminal:

useful sample commands: (WARNING: DO *NOT* USE THESE COMMANDS UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING! They are *NOT* thought to be copy/pasted, it’s just a collection of commands in random order!)

pvs -v --segments /dev/sdc5
lvdisplay
pvmove --alloc anywhere /dev/sdc5:7680-8445 /dev/sdc5:XXXX-YYYY
lvresize -l +100%FREE /dev/asterisk-vg/root
e2fsck /dev/asterisk-vg/root
#lvextend -l /dev/asterisk-vg/root
#vgscan
#vgchange -ay
#vgchange -an
resize2fs /dev/asterisk-vg/root
swapoff

Moving the system onto a bigger harddisk:

Step 1: dd the whole volume
Step 2: Getting “swap” out of the way (moving towards the end) after growing the disk, i.e. physically moving it towards the end of the bigger disk:

Screen Shot 2016-06-15 at 17.37.49

After this, you can resize the root LV …

Screen Shot 2016-06-15 at 17.42.27

Lets see if the disk size really has been adjusted:

Screen Shot 2016-06-15 at 17.44.44

Looks OK. – GParted also looks okay:

Screen Shot 2016-06-15 at 17.46.10

Different scenario: Moving a bigger LVM system onto a SMALLER harddisk:
yes, it works. did this yesterday. but it’s PITA. Basically works the same as above, but moving swap towards the front after shrinking the LVM volume. Then dd’ing the bigger disk to the smaller.

Comments are currently closed.