I know very little when it comes to linux but I'm looking to construct a cheap disk duplicator out of an old server that we have. The server is currently running Ubuntu 12.04LTS and has 8 hot swappable disk bays. Ideally this is what I would like to happen.
I would like to have any new disk that is plugged into the server imaged from a master disk, lets say /dev/SDB. I know I can run the following command to initiate the copy but I would like to know if there is a way to automate it. If a new drive is connected/detected, have it run the command to image using a variable for the new drive. The source drive will always be sdb and the destination would theoretically be /dev/sdc to /dev/sdg depending on how many drives are in the server at that time.
dd if=/dev/sdb of=- | tee >(dd of=/dev/sdc) >(dd of=/dev/sdd) >(dd of=/dev/sde)
If an action/script could run on new hardware/hard drive detections, could it do something like this...
if /dev/sdc/ connected/detected sleep 5 minutes -gives time to connect multiple drives before imaging Check for /dev/sdc (if /dev/sdc not exist) -if not connected goto exit Check for /dev/sdd (if /dev/sdd not exist) -if not connected command1 Check for /dev/sde (if /dev/sde not exist) -if not connected command2 and so on :command1 dd if=/dev/sdb of=- | tee >(dd of=/dev/sdc) goto exit :command2 dd if=/dev/sdb of=- | tee >(dd of=/dev/sdc) >(dd of=/dev/sdd) goto exit
any and all help would be appreciated. I don't know if there is a way to execute a script on new hardware/drive detection.