Sunday, 16 February 2014 08:40

Cloning multiple hard disks from a source drive (bit for bit)

1) Attach all your disks on the machine /dev/sda being the source drive
2) Boot Linux (Ghost for Linux over PXE in my case, but whatever works). A live USB distro maybe so you have free SATA ports.
3) Enter the command:-
dd if=/dev/sda | tee >(dd of=/dev/sdb) >(dd of=/dev/sdc) | (dd of=/dev/sdd)
4) On another console you can do:-
ps | grep "dd if=dev"
To get the PID of the input dd process, and then
kill -USR1 xxxx
where xxxx is the PID you got out of the ps grep.
This makes dd dump a progress report out on the console it's running on.
I was getting about 40MB/s out of this on some SanDisk SSDs. Took about 20 minutes to image the three 128GB drives. Something tells me this should be faster, but heh.

Using it with a disk image over the network

I then wanted to image drives simultaneously from an image created with Ghost for Linux.
G4L has no udev so the fd fifos (whatever they are) were not created, so create them manually with:-

ln -s /proc/self/fd /dev/fd
You can then do
ncftpget -c -u ghost -p ghost "ftp://192.168.129.5/img/imagename.img.lzop" | lzop -d | tee >(dd of=/dev/sda) >(dd of=/dev/sdb) >(dd of=/dev/sdc) | dd of=/dev/sdd
To extract to all drives at once.
To make life easier I wrote a couple of scripts (very quick and dirty):-
clonetoall.sh  Parse the image filename as parameter 1
                                                  
#!/bin/bash
ln -s /proc/self/fd /dev/fd
ncftpget -c -u ghost -p ghost "ftp://192.168.129.5/img/$1" | lzop -d | tee >(dd of=/dev/sda) >(dd of=/dev/sdb) >(dd of=/dev/sdc) | dd of=/dev/sdd
status.sh  Will show on the console that dd is running on. Seriously rough but you can see what's going on.
#!/bin/sh
PID1=`pidof dd | awk '{print $1}'`
PID2=`pidof dd | awk '{print $2}'`
PID3=`pidof dd | awk '{print $3}'`
PID4=`pidof dd | awk '{print $4}'`

while(`kill -USR1 "$PID1"`) do
kill -USR1 "$PID2"
kill -USR1 "$PID3"
kill -USR1 "$PID4"
sleep 10
done;
Last modified on Sunday, 16 February 2014 13:48

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.