Why doesn't the dd command produce a bootable clone disk?

etcetera

Active Member
Joined
Mar 10, 2024
Messages
161
Reaction score
37
Credits
1,900
I do not fully get it. dd is supposed to completely clone a disk, bit-by-bit. Yet I could never get it to create a bootable clone and had to resort to apps like Clonezilla, etc.
It runs, completes, but the target disk is not a bootable device.
Seems like it's missing the bootloader or the partition scheme?

Who got dd to work as a complete cloning tool SSD1 to SSD2, both NVME/PCIe? Are there missing steps I need to take after dd completes it's run?
 


I do this frequently. dd has no problem making bootable disks.

A big gotcha is that disk you're copying to, has to be as big or bigger than the one you're copying from.

Let's say you buy a Intel SSD and a Samsung SSD, and they are both 256 GB. At least that's what it says on the box.
But in reality, one is 252GB and the other is 250GB. If you're using the entire disk as your filesystem, even if there's
noithing on that filesystem, it won't work. Sometimes dd will fail with an error, but sometimes it says it completed.

If I know in advance that I may have to do this in the future at some point, I'll make the filesystem slightly smaller,
maybe 248GB or something like that. Of course if you have a bigger disk, like 512 or 1TB then it's not a problem,
the down side is, a lot of wasted disk space.

The other thing is, you can't clone a disk that you are booted from.
What I do is boot from a LiveUSB distro. ( It really doesn't matter which one, just about all of them have dd )
Use gparted or fdisk -l to find out the device names of the disks.

Then I use something like...

dd if=/dev/sdb of=/dev/sdc ibs=2G obs=2G status=progress

( change the sdb and sdc according to your needs ).
Another gotcha with dd. You don't have to do this for standard filesystem partitions,
but if you're using LVM, you can't just dd a single partition, because the device mapping on on the root/boot disk.

Finally, it has to be the "entire" disk if you're planning on booting from it.
You can't copy just from a partition, and you can't copy simply to a partition.

I do have a 2TB disk, that has 5 bootable images on it. I never boot from that disk. But it's simply my archive disk.
For that process, it's a slightly different command.

dd if=/mnt/path/to/mycustom.iso of=/dev/sda ibs=4G obs=4G status=progress
 
That is the syntax I followed.
Of course I ran it from the disk I was currently booted off. Why wouldn't that work? It runs and completes with no errors, just that when I reboot and select the /dev/NVME_target SSD, it does not boot.
The 2 SSDs are obviously identical. They could different in controllers, like Samsung 960 vs 970.
Yes, I got the LVM format and select the entire device obviously.

dd if=/dev/input/NVME_source of=/dev/NVME_target bs=64K
 
Last edited:
Given I run LVM
Maybe there is another approach, clone the root volume group (rhel) to the other SSD.
 
I could do this. The problem is, I have 2 identical SSD's, Samsungs M.2 and when booted off gparted I have no idea which one is the source and which one is the target. I know when physically looking at the machine, the working one is on the left and the one to be wiped out is the one on the right, but not sure how the device files are mapped out in terms of the physical location. They are never consistent, ie. "0" is not on the left.

Use gparted or fdisk -l to find out the device names of the disks.
 
Last edited:
@etcetera wrote:
I have no idea which one is the source and which one is the target
To keep track of the disk's identities you could use their serial numbers with:
Code:
lsblk  --output=NAME,SERIAL
 
Last edited:
Of course I ran it from the disk I was currently booted off. Why wouldn't that work?

It is a basic safety feature. For example GParted will not allow you to resize a partition for which you are in session currently.

Also in #4
dd if=/dev/input/NVME_source of=/dev/NVME_target bs=64K

Typo "input" makes no sense there.

Cheers

Wiz
 

Members online


Top