What to do when you buy a larger hard disk? - Linux LVM
By M. Bignotti, Posted Saturday, March 30 2019
 

Premise

make sure you update a new kernel, if you need to, and reboot BEFORE cloning the OLD disk into the NEW disk, or you might have a problem rebooting and using the last kernel installed.

Old disk still running: /dev/sda

New disk: /dev/sdd

Your LVM groups: unnamed

Your LVM volumes: root

 

Check the new disk with

smartctl -t long /dev/sdd

and wait ~4hrs and then check the results with

smartctl -a /dev/sdd

 

Copy the currently running disk over

dd if=/dev/sda of=/dev/sdd bs=32K conv=noerror,{SOMETHING} status=progress

 

when done; 10 eons later; turn off and switch the disks. 

 

if the disk was bigger, resize the main partition, you can do this live since you're just gonna use disk that isn't used now.

sfdisk -d /dev/sda > /tmp/eldisko

 

Now edit the file and enter the new size in /dev/sda2 (where sda2 is your large partition), then reload the partition onto the disk, live, yes, live :)

sfdisk /dev/sda < /tmp/eldisko

 

everything ok? Failed?

lol I just wanted to scare you, you need to add --force to run this on the live disk

 

sfdisk --force /dev/sda  < /tmp/eldisko

 

Now check it's been resized

sfdisk -l /dev/sda

 

Inform the OS about what we changed.

partprobe /dev/sda

 

 

Now onto the Physical Volume, the large magic chest of drawers

Let's relist the volumes the volumes

pvscan

 

and resize the volume

pvresize /dev/sda2

 

[TODO] add in premise variables

Then the Logical Volume, the drawers

lvresize /dev/unnamed/root -l +100%FREE

 

And now grow the xfs partition

xfs_growfs /

 

boom done

df -h

© CaViCcHi