You are not logged in.

#1 2016-10-30 07:19:11

crankshaft
Member
Registered: 2013-04-29
Posts: 20

Disk Cloning and Persistent Partition Names

Spent the whole weekend on this and still have not solved it.

I need to be able to clone a complete disk using dd and be able to plug it in (into an identical specification machine) and use it without any further mods.

But I am unable to do this without first having to chroot into the disk and run mkinitcpio to rebuild the initramfs.

Now I understand that I cannot use UUIDs as each new disk will have a different UUID, so instead I am using labels:

ls -l /dev/disk/by-label

/dev/disk/by-label:
total 0
lrwxrwxrwx 1 root root 10 Oct 30 06:43 bios -> ../../sda1
lrwxrwxrwx 1 root root 10 Oct 30 06:43 boot -> ../../sda2
lrwxrwxrwx 1 root root 10 Oct 30 06:43 root -> ../../sda3

My fstab is also using /dev/disk/by-label and my kernel root in syslinux is using the label i.e.:

options root=LABEL=root rw quiet

After running mkinitcpio -p linux and rebuilding the initramfs, I then shut down and externally clone this drive to a new disk using dd.

All of that works fine, but when I come to boot the new disk It refuses to boot saying it is unable to find the root device, dropping me back into the recover shell.

So what am I doing wrong ? - I am using labels to identify the partitions and as far as I understand from the archlinux wiki regarding persistent boot devices, bootloaders and mkinitcpio this should work ?!

Any help or suggestions greatly appreciated !

Offline

#2 2016-10-30 08:46:24

Fixxer
Member
From: Poland
Registered: 2011-08-29
Posts: 217

Re: Disk Cloning and Persistent Partition Names

It doens't matter if it is label or UUID identification in /etc/fstab. When you CLONE all filesystems - whole disk - filesystems are just duplicated. Just change label or UUID on cloned filesystem and make appropriate changes in /etc/fstab. Then run mkinitcpio command.

Offline

#3 2016-10-30 09:40:30

frostschutz
Member
Registered: 2013-11-15
Posts: 1,418

Re: Disk Cloning and Persistent Partition Names

dd the entire disk and everything is duplicated, partition table, partition uuids, filesystem uuids, labels, doesn't matter.

problems start if you have both disks in the same pc at the same time, everything relies on uuid being unique but with cloned disks it's not.

what changes is the disk name serial number and possibly size, so if anything relies on /dev/disk/by-{id,path}/ where such things are recorded, it might fail. But that's usually not the case.

what is the exact dd command you are using? there are pitfalls for example, conv=noerror,sync corrupts data, never use this option, if your source disk has errors go for ddrescue instead.

is it a different type of disk, connected in a different way, then your linux kernel / initramfs might be missing a module and not find the hardware in the first place.

If your initcpio is using the autodetect hook maybe get rid of it. makes the initrd much much larger but at least it has all the modules

]# mkinitcpio -H autodetect
==> Help for hook 'autodetect':
This hook shrinks your initramfs to a smaller size by autodetecting the needed
modules. Be sure to verify included modules are correct and none are missing.

Last edited by frostschutz (2016-10-30 09:42:01)

Offline

Board footer

Powered by FluxBB