doom'd net

still mucking around with the ol'computer


Using LVM To Upgrade a Disk In a Linux System

Using LVM to upgrade a disk in a Linux system is very easy, assuming everything is set up correctly ahead of time.

Obviously everything ( except /boot and if applicable, /boot/efi ) needs to be in LVM. And the disk being upgraded should be 100% LVM, but it might work otherwise. 

You’ll also need free port, SATA, SAS, SCSI, what ever your system uses, along with appropriate power.

The way my Linux system is configured, I have / and /boot on a SSD.  I have swap, /var, and /home on a spinning platter drive.  I recently upgraded it from a 1 TB disk to a 4 TB disk.

So to start, you probably should turn off your computer, then hook up your new drive an appropriate port and its power connection.  Then boot your computer and using your favorite partitioning tool, create one big LVM partition.

NOTE: One that spans a >2 TB disk has to use gpt disk label.

NOTE: Possibly not necessary, but I did this in single user mode

On my system, the disk was /dev/sdb and the new one was /dev/sdc. The Volume group is called the default, fedora.

First step is to create the PV and add it to the VG:

pvcreate /dev/sdc1
vgextend fedora /dev/sdc1

Next step is to move the PV to the new disk:

pvmove /dev/sdb1 /dev/sdc1

Now you can go do something else.  If you are doing this to multi-TB disks, it will take HOURS, even on a fast computer. Once that has finally completed, remove the old disk.

vgreduce fedora /dev/sdb1

Then verify everything is how you expect it to be:

vgdisplay -v fedora
pvdisplay -m

That’s it, once everything is how it should be, you shutdown your computer and remove the old disk from you system, and permanently install the new one and let it boot into multi-user.  Then you can extend a file system to use some of the new space easily enough

NOTE: This can safely be done in multi-user to mounted filesystems:

lvextend -L +100%PV /dev/fedora/home
resize2fs /dev/fedora/home

It really is that easy.