#2171 Issue closed: OUTPUT=USB neither works with BACKUP_URL=nfs://... nor with whole disk USB_DEVICE=/dev/sdc

Labels: enhancement, needs sponsorship, no-issue-activity

sidrew opened issue at 2019-07-02 20:40:

Relax-and-Recover (ReaR) Issue Template

Fill in the following items before submitting a new issue
(quick response is not guaranteed with free support):

  • ReaR version ("/usr/sbin/rear -V"):
    2.5

  • OS version ("cat /etc/rear/os.conf" or "lsb_release -a" or "cat /etc/os-release"):
    OS_VENDOR=RedHatEnterpriseServer
    OS_VERSION=7.6

  • ReaR configuration files ("cat /etc/rear/site.conf" and/or "cat /etc/rear/local.conf"):

BACKUP=NETFS
BACKUP_PROG=tar
BACKUP_TYPE=differential
BACKUP_URL=nfs://some-server/some-path
BACKUP_PREFIX="$HOSTNAME"
BACKUP_PROG_EXCLUDE=("${BACKUP_PROG_EXCLUDE[@]}" '/media' '/var/crash')
FULLBACKUPDAY="Sun"

OUTPUT=USB

USB_DEVICE=`readlink -f /dev/disk/by-id/usb-*`
USB_DEVICE_FILESYSTEM_LABEL='REAR-TSM'
USB_DEVICE_FILESYSTEM=ext4

export TMPDIR=/some/temp/path/`hostname`
  • Hardware (PC or PowerNV BareMetal or ARM) or virtual machine (KVM guest or PoverVM LPAR):
    PC

  • System architecture (x86 compatible or PPC64/PPC64LE or what exact ARM device):
    x86_64

  • Firmware (BIOS or UEFI or Open Firmware) and bootloader (GRUB or ELILO or Petitboot):
    UEFI

  • Storage (local disk or SSD) and/or SAN (FC or iSCSI or FCoE) and/or multipath (DM or NVMe):
    Local disk

  • Description of the issue (ideally so that others can reproduce it):

When trying to create a rescue disk on USB, if we pass in a raw device, ala /dev/sdk ... we're unable to confirm it via udevadm in usr/share/rear/prep/USB/Linux-i386/350_check_usb_disk.sh since this returns "block"

TEMP_USB_DEVICE=$(basename $(dirname $(my_udevinfo -q path -n "$REAL_USB_DEVICE")))
  • Workaround, if any:

Simplest way to fix this is to modify the aforementioned script... since RAW_USB_DEVICE won't be set, we can assert it in the third conditional... since the udevadm info will actually return "sdk" for example.

@@ -21,7 +21,7 @@ if [ "$TEMP_USB_DEVICE" -a -b "/dev/$TEMP_USB_DEVICE" ]; then
    RAW_USB_DEVICE="/dev/$(my_udevinfo -q name -n "$TEMP_USB_DEVICE")"
elif [ "$TEMP_USB_DEVICE" -a -d "/sys/block/$TEMP_USB_DEVICE" ]; then
    RAW_USB_DEVICE="/dev/$(my_udevinfo -q name -p "$TEMP_USB_DEVICE")"
- elif [ -z "$TEMP_USB_DEVICE" ]; then
+ elif [ -z "$TEMP_USB_DEVICE" ] || [ -z "$RAW_USB_DEVICE" ] ; then
    RAW_USB_DEVICE="/dev/$(my_udevinfo -q name -n "$REAL_USB_DEVICE")"
else
    BugError "Unable to determine raw USB device for $REAL_USB_DEVICE"
  • Attachments, as applicable ("rear -D mkrescue/mkbackup/recover" debug log files):
    Pull request incoming.

jsmeix commented at 2019-07-03 07:30:

@sidrew
thank you for your explanatory issue report and your fix!

jsmeix commented at 2019-07-04 07:47:

According to
https://github.com/rear/rear/pull/2172#issuecomment-508201529
it seems the root cause of this issue was that
"rear mkrescue" with OUTPUT=USB was called
without having done "rear format" before, cf.
https://github.com/rear/rear/pull/2172#issuecomment-508376871

@sidrew
is my above assumption right?
If yes, do things work for you after you did "rear format" once
before you call "rear mkrescue"?

FYI:
I think I never used OUTPUT=USB with BACKUP_URL=nfs://...
(at least I cannot find an older issue where I had used that).
I had only used OUTPUT=USB with BACKUP_URL=usb://...
and for BACKUP_URL=usb://... a "rear format" is mandatory.

sidrew commented at 2019-07-05 14:59:

According to
#2172 (comment)
it seems the root cause of this issue was that
"rear mkrescue" with OUTPUT=USB was called
without having done "rear format" before, cf.
#2172 (comment)

No, I had already formatted it...

@sidrew
is my above assumption right?
If yes, do things work for you after you did "rear format" once
before you call "rear mkrescue"?

Actually, no... I had formatted the drive... the workflow just takes USB_DEVICE and assumes it's a partition on which to install the rescue disk... from what I can tell. My pull request modified the script that determines what to assign to RAW_USB_DEVICE, in order to figure out where to put the bootloader, but otherwise uses USB_DEVICE for putting rescue and other backup data.

jsmeix commented at 2019-07-08 09:05:

@sidrew
thank you for the explanation.

As time permits I will have a look and try to reproduce your use case
but no promises that I will work on that stuff soon
"quick response is not guaranteed with free support", cf.
https://github.com/rear/rear/blob/master/.github/ISSUE_TEMPLATE.md

@sidrew
of course we would appreciate more pull requests from you that
make OUTPUT=USB work with BACKUP_URL=nfs://... and
with a whole disk like USB_DEVICE=/dev/sdc

I never used a whole disk like USB_DEVICE=/dev/sdc

For me things had worked with

OUTPUT=USB
USB_DEVICE=/dev/sdb1
BACKUP=NETFS
BACKUP_URL=usb:///dev/sdb1

cf. https://github.com/rear/rear/issues/1532#issuecomment-339625278

A side note:

That OUTPUT=USB stuff drives me nuts - I already spent so much time
on various weird issues with that USB stuff. The root cause is that
the whole USB stuff is basically some kind of "add-on hack" for a special
use case that is not well integrated with how the rest of ReaR works,
see in particular https://github.com/rear/rear/issues/1164 and
https://github.com/rear/rear/issues/1166#issuecomment-272868388

The more I work on OUTPUT=USB issues the more I wished I could
implement a new OUTPUT=DISK that cleanly works in compliance
with how rest of ReaR works and afterwards remove the old
OUTPUT=USB stuff, cf. https://github.com/rear/rear/issues/1390

jsmeix commented at 2019-07-11 11:22:

Only a short notice for now:

OUTPUT=USB together with BACKUP_URL=nfs://...
does not work for me but I did not find time for an analysis.

I guess with current ReaR OUTPUT=USB may be only
meant to be used with BACKUP_URL=usb://...

jsmeix commented at 2019-10-02 17:29:

https://github.com/rear/rear/pull/2172
is only a first step to make OUTPUT=USB work with a whole disk USB_DEVICE=/dev/sdc
see https://github.com/rear/rear/pull/2172#issuecomment-508201529

github-actions commented at 2020-06-27 01:33:

Stale issue message


[Export of Github issue for rear/rear.]