#100 Issue closed
: Make partition bootable, even if we do not format the device¶
Labels: enhancement
dagwieers opened issue at 2012-06-07 09:24:¶
If you like to make a backup to disk, but use a disk with content you want to retain, you cannot format the disk. And that's fine, the formatting of the disk is strictly speaking not necessary (as long as the device's filesystem is acceptable). However in this case if the partition is not in fact marked bootable, the device will not be booted from by extlinux.
We can avoid this problem by marking the partition bootable in case we add syslinux as the bootloader.
dagwieers commented at 2012-06-09 00:19:¶
This is my attempt to do this:
diff --git a/usr/share/rear/output/USB/Linux-i386/85_make_USB_bootable.sh b/usr/share/rear
index e9bf589..6f87811 100644
--- a/usr/share/rear/output/USB/Linux-i386/85_make_USB_bootable.sh
+++ b/usr/share/rear/output/USB/Linux-i386/85_make_USB_bootable.sh
@@ -13,6 +13,13 @@ fi
[ "$RAW_USB_DEVICE" -a "$REAL_USB_DEVICE" ]
BugIfError "RAW_USB_DEVICE and REAL_USB_DEVICE should be already set"
+# Check if partition is bootable, if not, make it so
+if ! parted $RAW_USB_DEVICE print | grep -E "^\s*${REAL_USB_DEVICE: -1:1}" | grep -q boo
+ LogPrint "Marking $REAL_USB_DEVICE bootable"
+ echo "Yes" | parted -s $RAW_USB_DEVICE set ${REAL_USB_DEVICE: -1:1} boot on >&2
+ StopIfError "Could not make partition $REAL_USB_DEVICE bootable"
+fi
+
usb_syslinux_version=$(get_usb_syslinux_version)
syslinux_version=$(get_syslinux_version)
However it fails:
[root@moria rear]# rear -v mkrescue
Relax and Recover 1.13.0 / $Date$
Creating disk layout
Creating root FS layout
Copy files and directories
Copy binaries and libraries
Copying kernel modules
Checking udev
Create initramfs
Marking /dev/sdb1 bootable
ERROR: Could not make partition /dev/sdb1 bootable on '/dev/sdb1'
Aborting due to an error, check /tmp/rear-moria.log for details
Finished in 31 seconds
Terminated
And the log contains:
2012-06-09 02:15:28 Marking /dev/sdb1 bootable
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.
Even though it worked...
[Export of Github issue for rear/rear.]