23.12.2015 22:37, Alexander E. Patrakov пишет: > Bytes 0x3e .. 0x1fe: x86 bootstrap code, which is not executed and thus > is likely not significant. >
Wanna bet? Could you test if the attached patch works for you on newer Mac? Note, that it still does not detect EFI bootable USB stick if it is inserted before power on - only when you stop in boot manager and insert stick. It also still does not boot from the second (unknown) EFI suggested for CD. But this second choice is also present only when CD is inserted before power on - it is not shown if CD is inserted in boot manager. I also do not get "Windows" menu choice on USB. May be because there is no active partition. Merry Christmas to everybody!
From: Andrei Borzenkov <arvidj...@gmail.com> Subject: [PATCH] grub-mkrescue: overwrite mtools bootstrap code with one from dosfstools With ESP created by mtools Mac boot manager hangs. Tested on MacBook 3,1 and iMac 9,1. It was determined that using bootstrap code from dosfstools avoids this. This patch explicitly overwrites bootstrap code with dosfstools version. --- util/grub-mkrescue.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index 4511826..66ae085 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -53,6 +53,35 @@ static char **xorriso_argv; static char *iso_uuid; static char *iso9660_dir; +/* The following bootstrap code is from dosfstools distributed under + GPL Version 3 license. + */ +#define BOOTCODE_OFFSET 62 +#define BOOTCODE_SIZE 448 + +static char dummy_boot_code[BOOTCODE_SIZE] = + "\x0e" /* push cs */ + "\x1f" /* pop ds */ + "\xbe\x5b\x7c" /* mov si, offset message_txt */ + /* write_msg: */ + "\xac" /* lodsb */ + "\x22\xc0" /* and al, al */ + "\x74\x0b" /* jz key_press */ + "\x56" /* push si */ + "\xb4\x0e" /* mov ah, 0eh */ + "\xbb\x07\x00" /* mov bx, 0007h */ + "\xcd\x10" /* int 10h */ + "\x5e" /* pop si */ + "\xeb\xf0" /* jmp write_msg */ + /* key_press: */ + "\x32\xe4" /* xor ah, ah */ + "\xcd\x16" /* int 16h */ + "\xcd\x19" /* int 19h */ + "\xeb\xfe" /* foo: jmp foo */ + /* message_txt: */ + "This is not a bootable disk. Please insert a bootable floppy and\r\n" + "press any key to try again ... \r\n"; + static void xorriso_push (const char *val) { @@ -793,6 +822,29 @@ main (int argc, char *argv[]) xorriso_push ("-efi-boot-part"); xorriso_push ("--efi-boot-image"); + /* Mac fails to boot from ESP created by mformat; it was found that using + different bootstrap code in bootblock avoids this problem. + Tested on MacBook 3,1 (late 2007) and iMac 9.1 (2009). + */ + { + int efiimgfatfd; + + efiimgfatfd = grub_util_fd_open (efiimgfat, GRUB_UTIL_FD_O_WRONLY); + if (efiimgfatfd == -1) + grub_util_error (_("cannot open `%s': %s"), efiimgfat, + strerror (errno)); + + if (grub_util_fd_seek (efiimgfatfd, BOOTCODE_OFFSET) == -1) + grub_util_error (_("cannot seek `%s': %s"), efiimgfat, + strerror (errno)); + + if (grub_util_fd_write (efiimgfatfd, dummy_boot_code, BOOTCODE_SIZE) != BOOTCODE_SIZE) + grub_util_error (_("cannot write to `%s': %s"), efiimgfat, + strerror (errno)); + + close (efiimgfatfd); + } + grub_util_unlink_recursive (efidir); free (efiimgfat); free (efidir_efi); -- tg: (a9399f2..) t/mtools-bad-boot-sector (depends on: master)
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel