From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1aCCKc-0000Tv-OC for mharc-grub-devel@gnu.org; Thu, 24 Dec 2015 15:17:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aCCKZ-0000TM-Um for grub-devel@gnu.org; Thu, 24 Dec 2015 15:17:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aCCKY-00052M-P9 for grub-devel@gnu.org; Thu, 24 Dec 2015 15:17:47 -0500 Received: from mail-lf0-x22b.google.com ([2a00:1450:4010:c07::22b]:33341) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aCCKT-0004z6-A1; Thu, 24 Dec 2015 15:17:41 -0500 Received: by mail-lf0-x22b.google.com with SMTP id p203so168723208lfa.0; Thu, 24 Dec 2015 12:17:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type; bh=8hfikYf0zXIz+h6s8iFUxM+znQKT5UkqThW1O/M5v+E=; b=Lp+IW1wg88iUeI0xSkX7/YjuJoGogq/ERZXfr7OsHt9ykU9knvXZ6MP0Zu5vV6nx29 bZ26+ODnstgrcPnX20Qa7E5t7w6f+xsUklTDQG6VThVz+05Ok62+guyX+kDTdQhWY1xv twHg/0YYYBY2DWUcKrXvMwWWTnSAUteWSpIdoI01H579nm5IDTqEYx6Kndicp4OldugC 5rI2mfkhupjHhJhDJrnzVoygUTGMKSzVwWsCAG/ClDOzCaHbSocAw6AcCruWShWi9lYm YRSzZiBqjpx2E5LjPfI9e025NsiQocr3a9JVTMZSJ3IWQtD0Iv22bahObQcl3AyN1geN nlIw== X-Received: by 10.25.211.209 with SMTP id k200mr13114252lfg.125.1450988260299; Thu, 24 Dec 2015 12:17:40 -0800 (PST) Received: from [192.168.1.41] (ppp91-76-25-247.pppoe.mtu-net.ru. [91.76.25.247]) by smtp.gmail.com with ESMTPSA id pl2sm7501379lbc.8.2015.12.24.12.17.38 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 24 Dec 2015 12:17:39 -0800 (PST) Subject: Re: [Bug-xorriso] grub-mkrescue does not boot on older Macs as USB stick To: "Alexander E. Patrakov" , The development of GNU GRUB , bug-xorriso@gnu.org References: <5679AC5E.2080300@gmail.com> <567AEB71.7020208@gmail.com> <567AF803.7080005@gmail.com> From: Andrei Borzenkov X-Enigmail-Draft-Status: N1110 Message-ID: <567C52E1.7080603@gmail.com> Date: Thu, 24 Dec 2015 23:17:37 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <567AF803.7080005@gmail.com> Content-Type: multipart/mixed; boundary="------------080400040609010309010109" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::22b X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Dec 2015 20:17:49 -0000 This is a multi-part message in MIME format. --------------080400040609010309010109 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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! --------------080400040609010309010109 Content-Type: text/x-patch; name="mac-mformat.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="mac-mformat.patch" From: Andrei Borzenkov 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 dosfstool= s 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; =20 +/* 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] =3D + "\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"); =20 + /* Mac fails to boot from ESP created by mformat; it was found tha= t using + different bootstrap code in bootblock avoids this problem. + Tested on MacBook 3,1 (late 2007) and iMac 9.1 (2009). + */ + { + int efiimgfatfd; + + efiimgfatfd =3D grub_util_fd_open (efiimgfat, GRUB_UTIL_FD_O_WRONLY); + if (efiimgfatfd =3D=3D -1) + grub_util_error (_("cannot open `%s': %s"), efiimgfat, + strerror (errno)); + + if (grub_util_fd_seek (efiimgfatfd, BOOTCODE_OFFSET) =3D=3D -1) + grub_util_error (_("cannot seek `%s': %s"), efiimgfat, + strerror (errno)); + + if (grub_util_fd_write (efiimgfatfd, dummy_boot_code, BOOTCODE_SIZE) !=3D= 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); --=20 tg: (a9399f2..) t/mtools-bad-boot-sector (depends on: master) --------------080400040609010309010109--