In order to clone a disk, you absolutely should unmount all partitions. All modern desktop OS' have many services running in the background that write to the OS partition, and may also periodically write to other mounted partitions (even those on other disks) for whatever reason. The writes may be small and few, but any writes -- especially those involving filesystem metadata -- will wreck havoc with your cloning.
Typically one clones entire drives by booting a Linux Live CD/DVD/USB Key (pick any distribution you like, I prefer Mint for this kind of thing). This way your hard drives can remain unmounted.
The command you've got there will work fine, but as it stands, if a sector can't be read for any reason, dd
will stop. You may want that behavior, or you may want it to continue... up to you. Arch has excellent documentation on disk cloning and they recommend something like this:
# dd if=/dev/sdX of=/dev/sdY bs=512 conv=noerror,sync
But read the documentation, especially around adjusting bs
to higher values, as that can have a significant impact on cloning speed. If you want dd
to stop if it encounters an error, remove the conv=noerror,sync
part.
Best Answer
Actually, there is a way to do this: it involves
udev
, and it is the simplest possible use of its rules.Create a file /etc/udev/rules.d/10-local.rules and insert into it this single line:
This rule simply takes anything which would be called sda1, or sdb1, or sdc1,... and renames it to a name of your choice, in this case `my_hdd1'. The device node will appear at
If you wish you can do this with devices, not with partitions, whichever you like best:
The above rules will be applied to the first disk to be discovered, which is normally the root disk, /dev/sda. If you prefer to continue calling this disk /dev/sda, but you wish to apply this rule to all other disks, then these rules become:
again as per your wishes.
Restart udev, or reboot, and that's it.