Page 1 of 1

LVM for Dummies

Posted: 2021/01/05 18:22:56
by lee_mackey
I'm setting up a server for my students with very limited funds (and Linux expertise). To that end I installed CentOS 8 as a KVM hypervisor on an old desktop and spun up a few VMs. All that's working well. And I'm backing up the VMs every night to a network drive via iSCSI.

But I got paranoid about the single point of failure that is the server's hard drive. So I hooked up an el cheapo USB external drive adapter, and can clone the server hard drive to the external using dd. Pretty old school, but it works. But then I thought, hey, there's a second internal drive bay, why not just stick the clone drive in there?

Well, it definitely does not like having two (essentially identical) internal drives installed. The system boots, but LVM gets very confused and can't find its volumes cl-root, cl-home etc. While I vaguely understand the purpose of LVM, I don't know jack about the details, or configuring it for that matter. Why does the mere presence of a boot disk clone cause it to fail? Is there any way around this? Is it a horrible idea from the start?

Ultimately I suppose the right thing to do (besides get a real server, but no $$) is to start over with 2 internal drives in a RAID 1. But I'm trying to save a day or two of drudgery...

Thank you for any schooling and/or insights.

Re: LVM for Dummies

Posted: 2021/01/05 20:57:34
by TrevorH
If you cloned the entire disk then you cloned everything including all the LVs in the VG. Each of those has an internal uuid and those are identical between original and copy and which one is used is pretty much random. Not a good plan.

If what you want to do is back up the VM's disks then backup each LV in turn with dd and dd it to a file on a filesystem on your backup drive.

Re: LVM for Dummies

Posted: 2021/01/05 21:40:11
by lee_mackey
Yes, I did in fact want to copy the entire disk, so that I'd have an exact, bootable clone of the original in case the main drive failed. My hope was that even with identical UUIDs, the system would simply boot from the first bootable device found, and proceed from there. I think in a non-LVM context it would probably be OK.

Backing up the LVs themselves to a file (disk image) using dd makes sense. I haven't really used LVM much, so: if I later had to do a clean restore, I'd need to boot from a Live disk; format the new hard disk; recreate the LG and LVs on it; then restore with dd from the .img files? Also I'm assuming I need to back up the /boot partition as well as the /dev/mapper ones. Thanks.