LVM + RAID1 = Perfect solution to upgrade woes

By Greg Turnquist

Greg L. Turnquist worked on the Spring team for over thirteen years and is a senior staff technical content engineer at Cockroach Labs. He was the lead for Spring Data JPA and Spring Web Services. He wrote Packt's best-selling title, Learning Spring Boot 2.0 2nd Edition, and its 3rd Edition follow-up along many others.

February 3, 2016

As said before, I’m rebuilding an old system and have run into sneaky issues. In trying to upgrade from Ubuntu 12.04 to 14.04, it ran out of disk space at the last minute, and retreated to the old install. Unfortunately, this broke its ability to boot.

Digging in, it looks like Grub 2 (the newer version) can’t install itself properly due to insufficient space at the beginning of the partition. Booting up from the other disk drives (from a different computer), I have dug in to solve the problem.

How do you repartition a disk drive used to build a RAID 1 array, that itself is hosting a Linux Volume Group?

It’s not as hard as you think!

raid1 A mirror RAID array means you ALWAYS have double the disk space needed. So…I failed half of my RAID array and removed one of the drives from the assembly. Then I wiped the partition table and built a new one…starting at later cylinder.

POOF! More disk space instantly available at the beginning of the disk for GRUB2.

Now what?!? Creating a new RAID array partition in degraded mode, I add it the LVM volume group as a new physical volume.

lvm Then I launch LVM’s handy pvmove command, which moves everything off the old RAID array and onto the new one.

Several hours later, I can reduce the volume group and remove the older RAID array. With everything moved onto the newly resize partition, I can then destroy and rebuild the old disk with the same geometry as the new one, pair it up, and BAM! RAID array back in action, and let it sync back up.

This should line things up to do a GRUB2 chroot installation.

With LVM it’s easy to shrink and expand partitions, reclaim some spare space, and move stuff around. But you are nicely decouple from the physical drives.

With RAID1, you have high reliability by mirroring. And as a side effect, you always have a space disk on hand if you need to move data around. I once moved live MythTV video data off the system to reformat my video partition into xfs.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *