I am trying to create a script to create an image of an entire partition, restore the image in another partition and boot from the new partition.
I am having problems with the last part, i.e. making the changes to boot from the new partition.
For this I install ubuntu/debian using auto partitioning and configuring the hdd like this
- /dev/sda1 - /boot/efi
- /dev/sda2 - / (Ubuntu/debian)
- /dev/sda3 - SWAP
- /dev/sda4 - Not mounted - Target partition to copy/restore the image of sda2
So what I want to do is to create an image of
dev/sda2 and restoring it to
/dev/sda4 and booting then from
The reason for this is to be able to supply complete images of an unix installation and "update" some IOT devices without internet connection. So every time we supply a new image, this image gets restored in one of the partitions and this partition becomes the boot partition. This process applies everytime we supply a new image, i.e. everytime the boot partition switches. If something goes wrong by applying/installing the new image, the boot partition should not change and instead boot from the "old working" partition.
As for now I succeeded creating the image using
dump and restoring it to the target partition.
I am having problems with the changes to tell the grub to boot from the other partition, where the dump was restored.
I tried various things, like
update-grub and chrooting into the restored installation and running those commands, but I never got it working.
Could someone explain what is to be done to achieve what I am looking for?