#1153 Issue closed: USB device with partition table type gpt not bootable

Labels: enhancement, bug, fixed / solved / done

dwerner1 opened issue at 2017-01-05 10:11:

  • rear version - 1.19-git201612161033
  • OS version - Debian GNU/Linux testing (stretch)
  • file /etc/rear/local.conf is empty, /etc/rear/site.conf is like
BACKUP=NETFS
OUTPUT=USB
USB_DEVICE=/dev/disk/by-label/REAR-000
BACKUP_URL=/dev/disk/by-label/REAR-000

In file /usr/share/rear/conf/default.conf I have set

USB_DEVICE_PARTED_LABEL=gpt

and created the rescue system with

rear -v format /dev/sdb
rear -d -D mkbackup

The resulting device is not bootable - I get the message 'Missing operating system'

With USB_DEVICE_PARTED_LABEL=msdos everything works as expected, I cannot see anything spurious in /var/log/rear/rear-debianrear.log

jsmeix commented at 2017-01-05 11:47:

I did not check any detail - for now only a blind guess:
See in usr/share/rear/conf/default.conf the
section about "USING_UEFI_BOOTLOADER".

gozora commented at 2017-01-05 12:12:

@jsmeix, @gdha
Maybe you could consider extending ReaR issue templete with:

  • Boot type: [ Legacy BIOS | UEFI ]

dwerner1 commented at 2017-01-05 12:26:

Setting USING_UEFI_BOOTLOADER=0 in /usr/share/rear/conf/default.conf did not change the behaviour

jsmeix commented at 2017-01-05 12:51:

I meant setting USING_UEFI_BOOTLOADER=1
according to what default.conf describes:

USING_UEFI_BOOTLOADER=1  means we want UEFI ISO image ...

jsmeix commented at 2017-01-05 12:52:

@gozora
what do you mean with "extending ReaR issue template"?

gozora commented at 2017-01-05 12:59:

@jsmeix
Just to add another question for user that submits new issue. Because it is not always obvious from configuration if user have Legacy or UEFI boot.
Let me demonstrate :-) :

@dwerner1
Are you using Legacy BIOS of UEFI boot?

jsmeix commented at 2017-01-05 13:32:

I added a "Are you using legacy BIOS of UEFI boot?" item to
https://github.com/rear/rear/blob/master/.github/ISSUE_TEMPLATE.md

gozora commented at 2017-01-05 13:53:

Thanks @jsmeix !

dwerner1 commented at 2017-01-05 14:21:

I'm using legacy BIOS

gozora commented at 2017-01-05 16:05:

Got it!

For me this is bug in ReaR.
The problem is that gpt needs different mbr code and flags than msdos .

Try following (I'm assuming your USB device uses /dev/sdb if not please change it accordingly)

  • Plug your USB device (no need to mount it)
  • Backup your current MBR
    dd if=/dev/sdb bs=440 count=1 of=./usb_mbr_backup.img
  • Locate file called gptmbr.bin . Something like this should work for you:
    dpkg -L syslinux | grep gptmbr.bin
  • Replace current MBR (created by ReaR) like:
    dd if=<full_path_to_gptmbr>/gptmbr.bin of=/dev/sdb bs=440 count=1 conv=notrunc
  • Set correct flags for USB boot partition
    parted -s /dev/sdb set 1 boot off
    parted -s /dev/sdb set 1 legacy_boot on

Final output should look something like this:

# parted /dev/sdb print
Model: Kingston DT microDuo (scsi)
Disk /dev/sdb: 7751MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      17,4kB  7751MB  7751MB  ext3         primary  legacy_boot

Now you should be able to boot.

V.

dwerner1 commented at 2017-01-05 16:06:

Just to make this a bit clearer for me -

I had started this issue with

.... and created the rescue system with

rear -v format /dev/sdb
rear -d -D mkbackup

If I had been creating an UEFI enabled USB device, I had rather started the issue with these lines

rear -v format -- --efi /dev/sdb
rear -d -D mkbackup

Don't wanna be the inch pincher here :-)

I'm a bit confused now - is there something I can do to get this working? Or is there something that needs to be fixed/enhanced in rear?
I have just installed rear_1.19-0git201701041156

@jsmeix @gozora
many thanks for your attention!

gozora commented at 2017-01-05 16:08:

I like to have "clean table", that is why I'm asking that much ;-).
https://github.com/rear/rear/issues/1153#issuecomment-270681129 should help you.

dwerner1 commented at 2017-01-05 16:10:

@gozora
:-) no doubt - it's a pleasure to communicate with you!

gozora commented at 2017-01-05 16:15:

Damn!
New achievement unlocked! (communication skill +10) :-)

Hope it helps!

dwerner1 commented at 2017-01-05 16:19:

parted -s /dev/sdb set 1 boot_legacy off

tells me

parted: invalid token: boot_legacy

But it is bootable and shows the menu!! Cool input @gozora ;-)

gozora commented at 2017-01-05 16:21:

Yes, because that is wrong, who told you to set such flag? :-)

It should be:

parted -s /dev/sdb set 1 boot off
parted -s /dev/sdb set 1 legacy_boot on

Sorry for that!

V.

dwerner1 commented at 2017-01-05 16:22:

Perfect!

gozora commented at 2017-01-09 09:37:

@dwerner1
With https://github.com/rear/rear/pull/1157 merged, current ReaR code should work for you without modifications mentioned in https://github.com/rear/rear/issues/1153#issuecomment-270681129.

jsmeix commented at 2017-01-09 09:37:

With
https://github.com/rear/rear/pull/1157
merged into current ReaR GitHub master code
it should now "just work".

@dwerner1
I would appreciate it if you coud test if it really
"just works" with current ReaR GitHub master code
and provide feedback.

How to test the currently newest rear GitHub master code:

Basically "git clone" it into a directory and
then run rear from within that directory like:

# git clone https://github.com/rear/rear.git

# cd rear

# vi etc/rear/local.conf

# usr/sbin/rear -v format /dev/sdX

# usr/sbin/rear -d -D mkbackup

(replace /dev/sdX with your acual device file).

gozora commented at 2017-01-09 09:38:

@jsmeix :-)

jsmeix commented at 2017-01-09 09:40:

o.k. o.k. you are faster but less words so no clear winner ;-)

gozora commented at 2017-01-09 09:41:

OK, it's a draw :-)

jsmeix commented at 2017-01-09 09:44:

Ha! - I won!
GitHub tells right now about your
https://github.com/rear/rear/issues/1153#issuecomment-271242302
"gozora commented 5 minutes ago"
and mine
https://github.com/rear/rear/issues/1153#issuecomment-271242304
"jsmeix commented 5 minutes ago"
so same time but I have more words!
:-)

gozora commented at 2017-01-09 09:46:

Yep, I think we clicked "Comment" at nearly same time, but my packets arrived earlier.

dwerner1 commented at 2017-01-09 10:28:

I can confirm that the just pulled git version runs as expected! I would like to install that on a remote server as soon as possible. Are you gonna publish a deb package of Relax-and-Recover 2.00 / Git in the closer future?

gozora commented at 2017-01-09 11:22:

@dwerner1
Just note, I don't believe that this fix will be available in ReaR 2.0 as it was released prior this issue. ReaR 2.1 looks more likely ...

dwerner1 commented at 2017-01-09 11:59:

Ok, thanks for the information! I can do all I need with the actual git version, that's most important for me :-)

jsmeix commented at 2017-01-09 12:18:

According to
https://github.com/rear/rear/issues/1153#issuecomment-271251746
the issue is solved so that I close it.

@gozora
as always your contribution to ReaR is very valuable!


[Export of Github issue for rear/rear.]