#3333 Issue open: Is it possible to build a IMG File of a SDcard from a running Raspberry PI ?

Labels: enhancement, special hardware or VM

schlomo opened issue at 2024-10-21 08:01:

Discussed in https://github.com/rear/rear/discussions/3325

Originally posted by **ds2k5** October 3, 2024 Hi, is it possible to build a IMG to a USB-Disk that is connected do Raspberry PI. So that if the SDCard died can rebuild with the IMG to a new SDCard. ARM64 /etc/rear/local.conf OUTPUT=PXE BACKUP=NETFS BACKUP_URL="file:///mnt/backup" OUTPUT_URL="file:///mnt/backup" root@orangepizero2:~# rear -v mkbackup Relax-and-Recover 2.7 / Git Running rear mkbackup (PID 61405 date 2024-10-19 23:22:16) Using log file: /var/log/rear/rear-orangepizero2.log Running workflow mkbackup on the normal/original system Using backup archive '/mnt/backup/orangepizero2/backup.tar.gz' Using autodetected kernel '/boot/vmlinuz-4.9.318-legacy-sun50iw9' as kernel in the recovery system Creating disk layout Excluding component fs:/mnt in EXCLUDE_RECREATE Disabling component 'disk /dev/sda' in /var/lib/rear/layout/disklayout.conf Disabling component 'part /dev/sda' in /var/lib/rear/layout/disklayout.conf Disabling component 'fs ... /mnt' in /var/lib/rear/layout/disklayout.conf Using guessed bootloader 'ARM'. Skipping bootloader backup, see default.conf about 'BOOTLOADER' Verifying that the entries in /var/lib/rear/layout/disklayout.conf are correct Created disk layout (check the results in /var/lib/rear/layout/disklayout.conf) Creating recovery system root filesystem skeleton layout Adding 'console=ttyS0,115200' to KERNEL_CMDLINE Skipping 'dummy0': not bound to any physical interface. Skipping 'eth0': not yet supported. Failed to handle network interface 'eth0'. Skipping 'gre0': not bound to any physical interface. Skipping 'gretap0': not bound to any physical interface. Skipping 'ip6_vti0': not bound to any physical interface. Skipping 'ip6tnl0': not bound to any physical interface. Skipping 'ip_vti0': not bound to any physical interface. Skipping 'lo': not bound to any physical interface. Skipping 'sit0': not bound to any physical interface. Skipping 'tunl0': not bound to any physical interface. To log into the recovery system via ssh set up /root/.ssh/authorized_keys or specify SSH_ROOT_PASSWORD Copying logfile /var/log/rear/rear-orangepizero2.log into initramfs as '/tmp/rear-orangepizero2-partial-2024-10-19T23:22:32+02:00.log' Copying files and directories Copying binaries and libraries Copying all kernel modules in /lib/modules/4.9.318-legacy-sun50iw9 (MODULES contains 'all_modules') Copying all files in /lib*/firmware/ Testing that the ReaR recovery system in '/var/tmp/rear.8dU5rsamLS4s549/rootfs' contains a usable system Creating recovery/rescue system initramfs/initrd initrd.cgz with gzip default compression Created initrd.cgz with gzip default compression (45 MiB) in 29 seconds Copied kernel+initrd 69M to /var/lib/rear/output Created PXELINUX config 'rear-orangepizero2' and symlinks for MAC addresses in /var/lib/rear/output Copying resulting files to file location Saving /var/log/rear/rear-orangepizero2.log as rear-orangepizero2.log to file location Copying result files '/var/lib/rear/output/orangepizero2.kernel /var/lib/rear/output/orangepizero2.initrd.cgz /var/lib/rear/output/orangepizero2.message /var/lib/rear/output/rear-orangepizero2 /var/tmp/rear.8dU5rsamLS4s549/tmp/VERSION /var/tmp/rear.8dU5rsamLS4s549/tmp/README /var/tmp/rear.8dU5rsamLS4s549/tmp/rear-orangepizero2.log' to /mnt/backup/orangepizero2 at file location Making backup (using backup method NETFS) Creating tar archive '/mnt/backup/orangepizero2/backup.tar.gz' Archived 1094 MiB [avg 2237 KiB/sec] OK WARNING: tar ended with return code 1 and below output (last 5 lines): ---snip--- tar: /sys: file changed as we read it ---------- This means that files have been modified during the archiving process. As a result the backup may not be completely consistent or may not be a perfect copy of the system. Relax-and-Recover will continue, however it is highly advisable to verify the backup in order to be sure to safely recover this system. Archived 1094 MiB in 502 seconds [avg 2233 KiB/sec] Exiting rear mkbackup (PID 61405) and its descendant processes ... Running exit tasks ```
#### <img src="https://avatars.githubusercontent.com/u/888633?u=cdaeb31efcc0048d3619651aa18dd4b76e636b21&v=4" width="50">[gdha](https://github.com/gdha) commented at [2024-11-17 09:47](https://github.com/rear/rear/issues/3333#issuecomment-2481086195):

Is that not something we can do with the BLOCKCLONE workflow? Instead of partition based a whole disk?

#### <img src="https://avatars.githubusercontent.com/u/888633?u=cdaeb31efcc0048d3619651aa18dd4b76e636b21&v=4" width="50">[gdha](https://github.com/gdha) commented at [2024-11-21 12:51](https://github.com/rear/rear/issues/3333#issuecomment-2491057388):

The `sudo usr/sbin/rear -v -C blockclone mkbackuponly` seemed successful with below configuration:
```bash
# cat blockclone.conf
BACKUP=BLOCKCLONE                                        # Define BLOCKCLONE as backup method
BACKUP_PROG_ARCHIVE="silverblue"                              # Name of image file
BACKUP_PROG_SUFFIX=".img"                             # Suffix of image file
BACKUP_PROG_COMPRESS_SUFFIX=""                           # Don't use additional suffixes

BLOCKCLONE_PROG=dd                                       # Use dd for image creation
BLOCKCLONE_PROG_OPTS="bs=4k"                             # Additional options that will be passed to dd
BLOCKCLONE_PROG_COMPRESS="gzip"                          # Compress the image
BLOCKCLONE_PROG_COMPRESS_OPTIONS="-9"                    # Options needed by the compress program (default empty)
BLOCKCLONE_SOURCE_DEV="/dev/sda"                        # Device that should be backed up

BLOCKCLONE_SAVE_MBR_DEV=""                       # Device where partitioning information is stored (optional)
BLOCKCLONE_MBR_FILE=""               # Output filename for boot strap code
BLOCKCLONE_PARTITIONS_CONF_FILE=""  # Output filename for partition configuration

BLOCKCLONE_ALLOW_MOUNTED="yes"                           # Device can be mounted during backup (default NO)

schlomo commented at 2024-11-21 13:31:

Nice, would you consider adding a Raspberry Pi section to our docs?


[Export of Github issue for rear/rear.]