Question: Can I use dd to clone my luks encrypted lvm os drive?
I’ve got a laptop running Arch (btw), with a 128GB nvme in it. The nvme has two partitions. EFI boot, and a luks encrypted lvm.
I’ve got a 512GB nvme I want to swap in. I think I can clone the device with dd, update the uuids, expand the lvm, and drop in the 512 nvme, but my searching hasn't given me a clear confirmation of this. Am I correct in my thought process, or am I setting myself up for disaster?
Mark
in reply to harsh3466 • •like this
Squiddlioni likes this.
Linux reshared this.
harsh3466
in reply to Mark • • •unlawfulbooger
in reply to harsh3466 • • •/dev/nvme0n1
directly, but use device aliases in/dev/disk/
. I prefer/dev/disk/by-id/
but maybe another works better in your case.flatbield
in reply to Mark • • •wildbus8979
in reply to harsh3466 • • •cryptsetup resize
as wellharsh3466
in reply to wildbus8979 • • •ZWQbpkzl [none/use name]
in reply to harsh3466 • • •Look into
pvmove
. I'd take a backup withdd
but try to do the actual move withpvmove
. This might involve multiple steps if you can't have both nvme's installed at the same time. In that case I hope you have other drives.Edit: I think what you're doing won't be a disaster because you're not writing anything to the old nvme so that data is still there. So you won't bork anything if the new drive doesn't work.
harsh3466
in reply to ZWQbpkzl [none/use name] • • •I'll take a look at pvmove.
I can't have both installed. Plan is to dd the 128 nvme to a USB SSD I have, then dd the SSD to the 512 once it's installed in the laptop. All the xloning will be done by booting a USB ISO so no drives are in active use while being cloned.
ZWQbpkzl [none/use name]
in reply to harsh3466 • • •I suspect your plan might be safer and less of a pain than pvmove. I've just never done that before so I can't say for sure.
Be sure you can open and mount the USB ssd after the first dd. Also check the status of the disk size of the luks container. I'm assuming your dd'ing the encrypted partition not the data inside.
harsh3466
in reply to ZWQbpkzl [none/use name] • • •Thanks. I’ll stick with
dd
then. You are correct, I think. I plan todd
the whole disk. The plan is:dd if=/dev/nvme0n1 of=/dev/sdb bs=4M status=progress oflag=sync
unless that's the wrong idea. once the usb ssd is done I will definitely check the luks container on the ssd. Size and data availability.
ZWQbpkzl [none/use name]
in reply to harsh3466 • • •I recently read that luks containers don't actually know their size they will always adapt to the size of the entire disk (it makes shrinking them dangerous). So you should be good unless your SSD is bigger than your new nvme.
Very curious about how this goes. It might not work but it won't wipe the original nvme. I'd love to hear how it goes.
harsh3466
in reply to ZWQbpkzl [none/use name] • • •darius
in reply to harsh3466 • • •harsh3466
in reply to darius • • •It is lvm2. Thank you for the recommendation! I'll check it out though I think I'm going to stick to the CLI for this one. I kind of want to do it manually.
I do plan to work from a bootsble USB for all the
dd
work so that nothing is mounted/in use.