What went wrong
Use dd to clone running system onto spare hard disc.
As has been mentioned in comments, you can't use dd
or anything similar to clone a running system! The contents of the disk are changing while the system is running, so the copy gets inconsistent content and is corrupted. Your copy is unusable, you need to make a correct one.
By the way, this is not the fault of dd
. dd
has many faults but here cat
or pv
or any would not have worked any better. The problem is that the source that the tools copy from is not in a consistent state.
It seems the corruption affected an area that Grub looks at, and the developers of Grub thought that if the software saw unrecognizable data at this point, the most likely explanation was that someone was trying to use an encrypted disk without proper support or without having the correct decryption key available. But that's not the explanation in your case.
How to do the copy
You can use cat
(or pv
if you want a progress display) to copy partitions or a whole disk as long as they're only mounted read-only, or not mounted at all.
If your system is on LVM, you can leverage LVM to clone it onto another drive, even from a live system. The general process is:
- Take a snapshot of your current LVM logical volume(s) using
lvcreate --snapshot
. This requires spare capacity on the disk; you may want to temporarily create a physical volume on the new disk for that purpose and add it to your current volume group.
- Set up LVM physical volume(s), a volume group and logical volume(s) on the new drive, with logical volume(s) that are the same size(s) as what you currently have.
- Use
cat
(or pv
or whatever) to copy the snapshot to the new logical volume. Repeat for each logical volume. Once you've copied a logical volume, you can remove its snapshot to save space.
- Mount the new system and update
/etc/fstab
to the UUIDs on the new disk, if applicable.
- This process only the contents of LVM partitions, so you need to copy the rest. Install the bootloader on the new drive (the details depend on exactly how Grub is set up). Also copy
/boot
separately if it's on a non-LVM partition.
There might well be tools that automate this process, but I don't know of one offhand.
See also Moving Linux install to a new computer and https://askubuntu.com/questions/25633/how-to-migrate-user-settings-and-data-to-new-machine/5025#5025 (but beware that they might be a bit dated).
dd
does not create a valid, consistent backup. You should instead boot a live system and create the image from there. – Panki May 05 '23 at 11:23dd
. Instead usepv
- for example instead ofdd if=/dev/sda of=/dev/sdc
usepv /dev/sda >/dev/sdc
. Replacepv
withcat
if you don't havepv
installed – Chris Davies May 05 '23 at 11:55