From: Andrei Borzenkov <arvidjaar@gmail.com>
To: "Alexander E. Patrakov" <patrakov@gmail.com>,
The development of GNU GRUB <grub-devel@gnu.org>,
bug-xorriso@gnu.org
Subject: Re: [Bug-xorriso] grub-mkrescue does not boot on older Macs as USB stick
Date: Thu, 24 Dec 2015 23:17:37 +0300 [thread overview]
Message-ID: <567C52E1.7080603@gmail.com> (raw)
In-Reply-To: <567AF803.7080005@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 719 bytes --]
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!
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mac-mformat.patch --]
[-- Type: text/x-patch; name="mac-mformat.patch", Size: 3125 bytes --]
From: Andrei Borzenkov <arvidjaar@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)
next prev parent reply other threads:[~2015-12-24 20:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-22 20:02 grub-mkrescue does not boot on older Macs as USB stick Andrei Borzenkov
2015-12-23 18:44 ` Andrei Borzenkov
2015-12-23 19:37 ` [Bug-xorriso] " Alexander E. Patrakov
2015-12-24 20:17 ` Andrei Borzenkov [this message]
2015-12-25 17:35 ` Alexander E. Patrakov
2015-12-25 17:44 ` Andrei Borzenkov
2015-12-25 17:50 ` Alexander E. Patrakov
-- strict thread matches above, loose matches on Subject: below --
2015-12-22 20:02 Andrei Borzenkov
2015-12-22 20:42 ` [Bug-xorriso] " Alexander E. Patrakov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=567C52E1.7080603@gmail.com \
--to=arvidjaar@gmail.com \
--cc=bug-xorriso@gnu.org \
--cc=grub-devel@gnu.org \
--cc=patrakov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.