Question: Can I use dd to clone my luks encrypted lvm os drive?
from harsh3466@lemmy.ml to linux@lemmy.ml on 07 Feb 23:12
https://lemmy.ml/post/25745573

EDIT WITH UPDATE: Operation went off without a hitch! I’m now up and running with the 512GB nvme drive! Next stop is dual booting nixos, which was the whole reason for switching to the larger drive.

ORIGINAL POST:

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?

#linux

threaded - newest

wildbus8979@sh.itjust.works on 07 Feb 23:16 next collapse

Yup, you’re all set. You’ll need to use cryptsetup resize as well

harsh3466@lemmy.ml on 07 Feb 23:32 collapse

That I didn’t know. Thank you!

mark@social.cool110.xyz on 07 Feb 23:17 next collapse

@harsh3466 That should work, as always with dd the potential disaster is getting if and of the wrong way around and wiping the old drive.

harsh3466@lemmy.ml on 07 Feb 23:33 next collapse

No joke! I plan to quadruple check before I hit enter.

unlawfulbooger@lemmy.blahaj.zone on 08 Feb 07:13 collapse

Tip: don’t use /dev/nvme0n1 directly, but use device aliases in /dev/disk/. I prefer /dev/disk/by-id/ but maybe another works better in your case.

# find all aliases for nvme drives (no partitions)
find /dev/disk/ -type l -ilname '*nvme?n?' -printf '%l %p\n' | sed 's!^../../!!' | sort
harsh3466@lemmy.ml on 09 Feb 01:20 collapse

That is actually what I did, by-id. The whole operation went off without a hitch. I’m up and running with my new 512GB nvme!

unlawfulbooger@lemmy.blahaj.zone on 09 Feb 08:20 collapse

Congratulations!

harsh3466@lemmy.ml on 16 Feb 02:18 collapse

Thank you!

furrowsofar@beehaw.org on 08 Feb 01:23 collapse

The other is not having the sync,noerror options and having a disk error. ddrescue is a lot more forgiving.

ZWQbpkzl@hexbear.net on 07 Feb 23:37 next collapse

Look into pvmove. I’d take a backup with dd but try to do the actual move with pvmove. 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@lemmy.ml on 07 Feb 23:43 collapse

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@hexbear.net on 07 Feb 23:56 collapse

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@lemmy.ml on 08 Feb 00:50 collapse

Thanks. I’ll stick with dd then. You are correct, I think. I plan to dd 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@hexbear.net on 08 Feb 03:38 collapse

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@lemmy.ml on 08 Feb 05:41 collapse

The first clone (to the interim usb ssd) was a success! I’ll report back after installing the new nvme and cloning from the ssd to the nvme.

ZWQbpkzl@hexbear.net on 08 Feb 23:07 collapse

<img alt="penguin-dance" src="https://hexbear.net/pictrs/image/672b4192-07d4-4c39-b9ba-407498c16d22.png">

harsh3466@lemmy.ml on 09 Feb 01:22 collapse

Secnd clone was also a success! I cloned from the USB SSD to the NVMe, installed it, updated the UUIDs in fstab, and booted straight up!

ZWQbpkzl@hexbear.net on 09 Feb 02:23 collapse

Filesystem sized is grown fine? If so wow that was easy.

<img alt="club-penguin-dance" src="https://hexbear.net/pictrs/image/d9a24413-0839-454c-b5fd-2679e5fe66e3.gif">

harsh3466@lemmy.ml on 09 Feb 03:09 collapse

I didn’t expand it because I’m planning to dual boot NixOS. I’ve been wanting to wade in to NixOS and see what it’s all about.

darius@lemmy.ml on 07 Feb 23:59 collapse

Is it LVM2? If you need a GUI I recommend: Blivet-GUI from a bootable USB environment so as you said nothing is mounted, hope this helps!

harsh3466@lemmy.ml on 08 Feb 00:54 collapse

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.