#!/bin/bash # Clone our OS disk to sdb only if it is the same size as sda # Same for sdc # sdb1 (and sdc1) must already be formatted echo "sdb1 not mounted error message is normal..." if [[ "`cat /sys/block/sda/size`" == "`cat /sys/block/sdb/size`" ]]; then umount /dev/sdb1 mkdir -p /mnt/sdb1 mount /dev/sdb1 /mnt/sdb1 rsync -avx --exclude '/boot' --exclude 'PARTITIONTABLE.img' --delete / /mnt/sdb1/ rsync -avx --delete /boot/ /mnt/sdb1/boot/ dd if=/dev/sda bs=512 count=1 of=/mnt/sdb1/PARTITIONTABLE.img umount /dev/sdb1 fi if [[ "`cat /sys/block/sda/size`" == "`cat /sys/block/sdc/size`" ]]; then umount /dev/sdc1 mkdir -p /mnt/sdc1 mount /dev/sdc1 /mnt/sdc1 rsync -avx --exclude '/boot' --exclude 'PARTITIONTABLE.img' --delete / /mnt/sdc1/ rsync -avx --delete /boot/ /mnt/sdc1/boot/ dd if=/dev/sda bs=512 count=1 of=/mnt/sdc1/PARTITIONTABLE.img umount /dev/sdc1 fi