Relax-and-Recover (ReaR) image as container image
Relax-and-Recover (ReaR) root file system creation
You know (or don’t know) that with Relax-and-Recover (Rear) program you can keep the root file system generated by rear for debugging purposes. Simple use the
-d flag with the
rear command and that’s it. At the end of a
rear mkrescue or
rear mkbackup run you will see a message like:
You should also rm -Rf /tmp/rear.GZnPEjAbYT5mP4Y
That is the temporary workspace of ReaR that you can examine if needed. It is rare that somebody does this, but it is there if you ever need it for deeper investigation of an issue or whatever you want to see in-depth.
Another purpose is to
chroot the temporary root file system created by ReaR to see if all required libraries are there and so on. This is now automatically performed by ReaR if you use a recent version of rear (2.5 or higher).
Running the rear2docker.sh script
Well, instead of simple using
chroot to inspect or debug the root file system created by ReaR why not creat a container image? Just for the fun of it! Script rear2docker.sh  does this for you. Of course, it requires that
docker are installed on your system. Just download the script (or git clone the mismas project ) and execute it:
$ sudo ./rear2docker.sh Running "rear -d mkrescue" Relax-and-Recover 2.3 / Git Using log file: /var/log/rear/rear-noc.log Using backup archive '/tmp/rear.GZnPEjAbYT5mP4Y/outputfs/noc/backup.tar.gz' Creating disk layout Using guessed bootloader 'GRUB' Creating root filesystem layout 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-noc.log into initramfs as '/tmp/rear-noc-partial-2021-05-05T17:20:38+02:00.log' Copying files and directories Copying binaries and libraries Copying kernel modules Copying all files in /lib*/firmware/ Creating recovery/rescue system initramfs/initrd initrd.cgz with gzip default compression Created initrd.cgz with gzip default compression (251008115 bytes) in 52 seconds Making ISO image Wrote ISO image: /var/lib/rear/output/rear-noc.iso (249M) Copying resulting files to nfs location Saving /var/log/rear/rear-noc.log as rear-noc.log to nfs location You should also rm -Rf /tmp/rear.GZnPEjAbYT5mP4Y ReaR image created - continue to create a container image rear-2.3-noc:20210505 with id=sha256:6f9ecfdae914912dfe30bf23ef1724144965c882825ff647128d8959670bca05 created! To explore run: docker run -it rear-2.3-noc:20210505 /bin/bash Entering the container image rear-2.3-noc:20210505 It behaves the same as "chroot /tmp/rear.GZnPEjAbYT5mP4Y/rootfs" Type "exit" to go back to the normal shell. Container rear-2.3-noc:20210505 will be removed automatically. Welcome to Relax-and-Recover. Run "rear recover" to restore your system ! RESCUE 4668d09dc1c5:/ # ls bin boot dev etc init lib lib64 mnt proc root run sbin selinux sys tmp usr var
After exiting the docker shell the container is automatically removed, but the image is still there:
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE rear-2.3-noc 20210505 6f9ecfdae914 32 minutes ago 573MB
To remove the container image you need to run
docker rmi 6f9ecfdae914 (the IMAGE ID will be different in your environment).
However, when you exited the container image the script continued with the following:
RESCUE 4668d09dc1c5:/ # exit exit Press "y" key to chroot $ROOTFS - any other will remove the temporary rear workspace [time-out 5 sec]: Welcome to Relax-and-Recover. Run "rear recover" to restore your system ! RESCUE noc:/ # ls bin boot dev etc init lib lib64 mnt proc root run sbin selinux sys tmp usr var
chrooted into the temporary root file system of the ReaR rescue image. As you can see it is exactly the same as we saw in the container image. That makes sense as it is the same root file system. When you exit this
chroot environment the temporary workspace of rear will be removed.
RESCUE noc:/ # exit exit Removing temporary rear workspace /tmp/rear.GZnPEjAbYT5mP4Y
- Initial posted on 5 May 2021