Here's one for the guru out there.. I use a Raspberry Pi 3B+. It has an SD card with two partitions. So the layout is:
mmcblk0 179:0 0 59.5G 0 disk
├─mmcblk0p1 179:1 0 256M 0 part /boot
└─mmcblk0p2 179:2 0 59.2G 0 part /
I have a USB HDD used as a backup disk. Would like to create an image file from my backup. My USB HDD contains a backup tree , viz:-
/dev/sda1 (ext4 partition)
|
+----------------+
| |
root (dir name) boot (dir name)
| |
| |____ seed.sfs (squashfs filesystem copy of '/boot')
|
|____seed.sfs (squashfs filesystem copy of root '/' )
|
|____rsync1 (rsync backup diff on top of seed.sfs)
|
|____rsync2 (rsync backup diff on top of seed.sfs)
|
|____ . . .
|
|____rsyncX (rsync backup diff on top of previous rsyncs + seed.sfs)
Using the overlay filesystem, I mount root/seed.sfs + rsync1 as the overlay lowerdirs and rsync2 as the overlay upper dir, and I mount the result over /mnt/backups/root. This gives me a read-writeable overlay filesystem that is a copy of the root (mmcblk0p2 partition) of the Pi's SD Card.
(NB: Each time I backup, a new rsync dir (rsyncX where X is just a running count number) is created and added to the lowerdirs/upperdirs as necessary)
So /mnt/backups/root is the full backup of the mmcblk0p2 partition.
The /boot dir on the USB HDD is also a squashfs filesystem file which I mount over /mnt/backups/boot.
So /mnt/backups/boot is the full backup of the mmcblk0p1 partition.
All this works perfectly, so no issues with the method and use.
But... How - if possible - can I create an image file using /mnt/backups/{root and boot} that I can flash to a new SD card and use this SD card to boot the Pi. So
- /mnt/backups/root is the contents of mmcblk0p2 on an SD card.
- /mnt/backups/boot is the contents of mmcblk0p1 on an SD card.
and of course mmcblk0 on the new card would need to have the bootable files on there , extracted from a live booted SD card I guess?
Ideas?