I'm creating a bash script that will allow me to clone disks, and allow the user to select the input disk to clone and the output disk to clone to. I've almost finished, but I just have one hang up. dd doesn't recognize the variable names for the disks. Supposing srcDisk and destDisk are defined as existing disks (these variables are called elsewhere in my script and work with utilities such as sfdisk and fdisk), here is what I've tried:
dd if=/dev/$srcDisk of=/dev/$destDisk
I have also wondered if I need to specify partitions, and since number of partitions may vary, I tried a do until loop, with the iterator variable (i) specifying the partition number. This still didn't work:
until [ $i -gt srcPartNum ] do dd if=/dev/$srcDisk$i of=/dev/$destDisk$i conv=notrunc & pid=$! while kill -USR1 $pid; do sleep 1; done done
I'm not sure how to fix this or any workarounds.