#2538 PR merged: RAWDISK: Add local rescue partition installation capability

Labels: enhancement, fixed / solved / done

OliverO2 opened issue at 2020-12-10 22:01:

Relax-and-Recover (ReaR) Pull Request Template

Please fill in the following items before submitting a new pull request:

Pull Request Details:
  • Type: New Feature

  • Impact: Normal

  • Reference to related issue (URL):

  • How was this pull request tested? On Ubuntu 20.04 LTS Server

  • Brief description of the changes in this pull request:

This PR enables rear mkrescue when used with the RAWDISK output method to install the rescue/recovery system directly to one or more local disk partitions.

This is particularly useful on systems with redundant disks where a malfunction of one disk can be recovered via a rescue system available on another disk. It is also useful for testing as a separate rescue/recovery medium is no longer necessary.

Usage
  1. Enable RAWDISK output.
  2. Prepare one or more rescue partitions on local disk(s)

    • with an appropriate size (e.g. 1 GiB),
    • either empty or with a VFAT file system (which will be overwritten),
    • ideally identified as EFI system partition, sgdisk --typecode=$partnum:ef00 ...

    • with a specific partition name like Rescue System, e.g. via sgdisk --change-name="$partnum:Rescue System" ...

    • Set the configuration variable accordingly, e.g. in local.conf: RAWDISK_INSTALL_GPT_PARTITION_NAME='Rescue System'
  3. When configured like this, each rear mkrescue invocation will install the rescue/recovery system to the respective disk partitions. This occurs in addition to creating and distributing the disk image as directed by the OUTPUT_URL variable.

Example Configuration
OUTPUT=RAWDISK
OUTPUT_URL=null
RAWDISK_INSTALL_GPT_PARTITION_NAME='Rescue System'

OliverO2 commented at 2020-12-11 18:54:

At some point during testing, code blocks apparently switched their position. The section

### Unmount the boot partition, release the loop device

appeared before

### Copy the EFI boot partition to local disk partitions named "$RAWDISK_INSTALL_GPT_PARTITION_NAME" if configured

5aceaa5 fixes this, adds error checking for dd, and provides more output in the log file. This is a simulation of the previous situation (loop device missing) but with the fixed code output:

Installing the EFI rescue system to partitions labeled 'Rescue System'
Installing the EFI rescue system to partition '/dev/sda2'
ERROR: Could not copy the EFI rescue system to partition '/dev/sda2'
Some latest log messages since the last called script 280_create_bootable_disk_image.sh:
  Number  Start (sector)    End (sector)  Size       Code  Name
     1            2048          782302   381.0 MiB   EF00  Rescue System
  2020-12-11 18:37:31.489433539 Raw disk boot partition capacity after copying:
  Filesystem      Size  Used Avail Use% Mounted on
  /dev/loop6p1    381M  356M   26M  94% /tmp/rear.IiiTTfJAdpks7sU/tmp/boot
  2020-12-11 18:37:31.494484413 Installing the EFI rescue system to partitions labeled 'Rescue System'
  2020-12-11 18:37:31.509370807 Installing the EFI rescue system to partition '/dev/sda2'
  dd: failed to open '/dev/loop6p1': No such file or directory
Aborting due to an error, check /root/rear/var/log/rear/rear-test-u20-04-s.log for details

Previously, I had relied on ReaR's former behavior of stderr output appearing in the log file at all times. So I checked the log file to convince myself that all was working well. However, since #2498 stderr no longer appears in the log unless debugscript mode is turned on, and I missed to spot the problem.


[Export of Github issue for rear/rear.]