PDA

View Full Version : Using "data destroyer" commands to clone multiple disks...



FunkY
14-08-11, 00:58
Little project I'm working on involves running Ubuntu off a 4GB thumb drive, which in itself is a doddle... No problems there.

Logged in as root, using the command:
dd if=/dev/sda of=/dev/sdb bs=4096 I can clone disk 1 (sda) to disk 2 (sdb).

This is easy for a couple of drives, but what if I have a job lot to do? 50 or 100? I can't just copy the image of the drive over for some reason, they not bootable once done.

Doing one at a time is time consuming and boring, I need to be able to produce something like 20 an hour/bunches of 5s, then I only waste a couple of hours every month doing it... So I thought I'd try and be clever...


dd if=/dev/sda of=/dev/sdb of=/dev/sdc of=/dev/sdd of=/dev/sde of=/dev/sdf bs=4096Looks like it's doing it, but once it's complete only disk 2 has picked up the image.


dd if=/dev/sda of=/dev/sdb bs=4096 if=/dev/sda of=/dev/sdc bs=4096 if=/dev/sda of=/dev/sdd bs=4096 if=/dev/sda of=/dev/sde bs=4096Almost the same problem, looks like it's doing it but this time none of the disks pick up the image...

Is there a better way of doing this? An easier way? Have I just missed a step that's stopping it from writing to 5 drives at once?

Spaceboy
14-08-11, 10:44
surely the easiest way of doing it would be to write a script and run each process in the background ?



dd if=/dev/sda of=/dev/sdb bs=4096 &
dd if=/dev/sda of=/dev/sdc bs=4096 &
dd if=/dev/sda of=/dev/sdd bs=4096 &
dd if=/dev/sda of=/dev/sde bs=4096 &

etc

FunkY
14-08-11, 13:52
Doh! I had a feeling I was overcomplicating it. Cheers Spaceboy :thumb:

I'll still have to run through it manually, for some reason some disks get picked up by the system as a different assignment than others sometimes (unless I reboot every time which is a pain in the **** on the system we have set up for doing, it's so sloooow) so occasionally I'll get a curveball like sdj, but I'll just save the script in a text document, run fdisk -l and edit the script as needed.

Spaceboy
14-08-11, 15:23
There's probably some clever stuff you could do with awk and piping that into the script...

fdisk -l | awk '{print $4}' > disklist.txt

ddscript.sh
while read disklist.txt
do
dd if=/dev/sda of=$1 bs=4096 &
done

where "$4" is the /dev/sdx bit of fdisk output ;)