Hi
I think that the disk utility "parted" is broken with regard to
making hard drive partitions bootable. At least when syslinux
gptmbr.bin file is used to format it. This is causing the
livecd-iso-to-disk utility to incorrectly create a USB stick that
is capable of UEFI boot but not Legacy BIOS boot.
Question:
*Can we get parted to write the bootable flag on the gptmbr.bin
partition in the same way that sgdisk accomplishes this?
*Or can we use the better tool in this situation (sgdisk) and
patch the livecd-iso-to-disk script to enable the use of sgdisk
when making USB sticks with the gptmbr.bin file from syslinux?
For this test you need ...
UEFI 2.1 compliant system
Legacy BIOS bootable system
Livecd ISO image the was correctly mastered as a UEFI and Legacy
Bootable system.
livecd-tools-16.3
parted
gdisk
syslinux (with gptmbr.bin)
Run bash -x /usr/bin/livecd-iso-to-disk --reset-mbr --format --efi
image.iso /dev/sdb and save the output.
###SAMPLE Output shows sgdisk does not see partition as bootable
after parted does its work.
### Then after sgdisk does its work, it shows the partition as
bootable.
...
...
Press Enter to continue or ctrl-c to abort
+ read
+ umount /dev/sdb /dev/sdb1
+ :
+ /sbin/parted --script /dev/sdb mklabel gpt
++ LC_ALL=C
++ /sbin/parted --script -m /dev/sdb 'unit b print'
++ grep '^/dev/sdb:'
+ partinfo='/dev/sdb:8019509248B:scsi:512:512:gpt:hp v165w;'
++ echo /dev/sdb:8019509248B:scsi:512:512:gpt:hp 'v165w;'
++ cut -d : -f 2
++ sed -e 's/B$//'
+ size=8019509248
+ /sbin/parted --script /dev/sdb unit b mkpart '"EFI System
Partition"' fat32 1048576 8018460672 set 1 boot on
+ '[' -x /usr/sbin/sgdisk ']'
+ SGDISK=
++ /usr/sbin/sgdisk /dev/sdb --attributes=1:show
+ SGDISK=
+ echo 'SGDISK reports /dev/sdb attributes: '
SGDISK reports /dev/sdb attributes:
+ echo
+ egrep -i 'bios boot'
+ echo 'parted failed to make the partition Legacy BIOS bootable;
USING SGDISK '
parted failed to make the partition Legacy BIOS bootable; USING
SGDISK
+ /usr/sbin/sgdisk /dev/sdb --attributes=1:set:2
The operation has completed successfully.
++ /usr/sbin/sgdisk /dev/sdb --attributes=1:show
+ SGDISK='1:2:1 (legacy BIOS bootable)'
+ echo 'SGDISK reports /dev/sdb attributes: 1:2:1 (legacy BIOS
bootable)'
SGDISK reports /dev/sdb attributes: 1:2:1 (legacy BIOS bootable)
...
...
+ echo 'Target device is now set up with a Live image!'
Target device is now set up with a Live image!
+ exitclean
+ RETVAL=0
+ '[' -d /media/srctmp.NpEBDs ']'
+ '[' -d /media/tgttmp.ui8qin ']'
+ exit 0
Notice that parted is supposed to create a "bootable Flag" for the
partition on the gptmbr.bin formatted USB stick.
If we reboot from the stick in legacy mode, we get the syslinux
error "Missing Operating System"
see
http://syslinux.zytor.com/wiki/index.php/Common_Problems#Missing_Operating_System_.28mbr.bin.29
http://syslinux.zytor.com/wiki/index.php/Common_Problems#Missing_OS_.28gptmbr.bin.29
If we patch the script like below and use it to re-create the USB
stick ( make it use the gdisk package's "sgdisk" util to make the
partition bootable), then we can reboot from the USB stick in
Legacy Mode and we have a proper Legacy/UEFI bootable USB stick
that was formatted with syslinux gptmbr.bin.
##Patch to prove this out
--- livecd-iso-to-disk 2011-04-28 09:52:40.000000000 -0400
+++ livecd-iso-to-disk_oracle 2011-04-28 09:52:41.000000000
-0400
@@ -422,6 +422,20 @@
partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b
print" |grep ^$device:)
size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
/sbin/parted --script $device unit b mkpart '"EFI System
Partition"' fat32 1048576 $(($size - 1048576)) set 1 boot on
+ #parted may not properly set the gptmbr partition as
bootable.
+ #Use sgdisk to check and fix
+ if [ -x /usr/sbin/sgdisk ] ; then
+ SGDISK=""
+ SGDISK=$(/usr/sbin/sgdisk $device --attributes=1:show)
+ echo "SGDISK reports $device attributes: $SGDISK"
+ if ! echo $SGDISK | egrep -i 'bios boot' ; then
+ echo "parted failed to make the partition Legacy BIOS
bootable; USING SGDISK "
+ /usr/sbin/sgdisk $device --attributes=1:set:2
+ SGDISK=$(/usr/sbin/sgdisk $device --attributes=1:show)
+ echo "SGDISK reports $device attributes: $SGDISK"
+ fi
+ fi
+
# Sometimes automount can be
_really_ annoying.
echo "Waiting for devices to settle..."
/sbin/udevadm settle
Thanks
Gregory Fowler