Clone disks with dd
0. !!! WARNING !!! ‘dd’ may damage your system …
Please use disks with no data or non critical data, and use dd with extreme caution. Test things first, Disks, Flash Drivers and operating systems differ so be carefull.
1. Before clonning let’s check the state our original disk sdc, see the rw flag bellow RO.
# blockdev -v --getro /dev/sdc
get read-only: 0
# blockdev -v --getro /dev/sdc1
get read-only: 0
# blockdev --report /dev/sdc
RO RA SSZ BSZ StartSec Size Device
rw 256 512 4096 0 1000204886016 /dev/sdc
# blockdev --report /dev/sdc1
RO RA SSZ BSZ StartSec Size Device
rw 256 512 4096 2048 1000203091968 /dev/sdc1
# hdparm -r1 /dev/sdc
2. Lock property of device sdc, this will set the device and partition to read-only mode
blockdev --setro /dev/sdc
blockdev --setro /dev/sdc1
# blockdev -v --getro /dev/sdc
get read-only: 1
# blockdev -v --getro /dev/sdc1
get read-only: 1
We also can use the hdparm instead of blockdev
hdparm -r1 /dev/sdc
/dev/sdc:
setting readonly to 1 (on)
readonly = 1 (on)
# hdparm -r /dev/sde
/dev/sde:
readonly = 1 (on)
3. Insert the clean device
dmesg -T
[Tue Jul 5 13:13:41 2016] sdg: sdg1
[Tue Jul 5 13:13:41 2016] sd 5:0:0:0: [sdg] Attached SCSI disk
4. Clone the devices with dd
Used device ids instead of sda, sdX, etc it’s safer. :-)
ls -lh /dev/disk/by-id/* | grep -i kingston | awk '{ print $9}'
/dev/disk/by-id/usb-Kingston_DT_HyperX_000000-0:0 -> ../../sde
option 1 ( safer )
sudo dd status=progress if=/dev/disk/by-id/usb-Kingston_DT_HyperX_0011100-0:0 /dev/disk/by-id/ata-Hitachi_HDT000_XXX
option 2 ( risky )
sudo dd status=progress if=/dev/sdc /dev/sdg
In my Arch Linux i have progress with dd version 8.25,
# dd --version
dd (coreutils) 8.25
On some of Debian/Ubuntu or other Linux Distro the option is to use dd_rescue, that has progress and other nice features for data recovery.
dd_rescue /dev/sdc /dev/sdg
After using deftlinux for some data recovery, i found that is possible to set devices in read only mode. You can check details in the here deft-quickguide.