I need to clone a bootable disk to multiple disks (of different sizes) on different computers and it needs to be scriptable, but I can't find a way to do it.
I'm using Ubuntu 16.04 on everything.
First I tried
dd, I ran (with the disk unmounted):
$ dd if=/dev/sda bs=1K count=10000000 status=progress | gzip -c > os.img
That's about 10GB, the compressed file is about 3.8GB, the source disk is 120GB, the destination disk I'm testing on is 16GB, so I'm sure that it's going to work on all sizes, I wrote to disk with:
$ gunzip -c os.img | dd bs=1K of=/dev/sda status=progress
But it doesn't boot, I get:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown block(0,0)
no idea what that means, so I googled it but I didn't find a solution. Then I tried to mount the disk on a live OS to see if at least that worked, but I get:
$ sudo mount /dev/sda1 /mnt
EXT4-fs (sda1): bad geometry: block count 29306624 exceeds size of device (14653670 blocks)
which doesn't make sense to me. Anyone know if I can fix this or if there's a better method to do it? I see people recommending clonezilla but I can't find a scriptable version, it looks like I can only use it with "terminal GUI".