Skip to contentSkip to conversation

Mactel integration

RFC PATCH In review Vladimir 'φ-coder/phcoder' Serbinenko 4 participants 11 messages Nov 28, 2011 – Dec 2, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Mactel integration

Hello all. Based on the information from http://mjg59.dreamwidth.org/7468.html I intend to add support for such install. It requires a small HFS+ volume mounted at /boot/mactel. I also simplify handling of EFI directories by adding explicit option to specify it and removing some "compatibility" kludges (they don't make anything compatible with anything since "old behaviour" was mostly not to install at all) which made the code in question difficult to maintain. Patch attached and branch "mactel" pushed. I've tested only as far as to see the appropriate directory structure in place. Can anybody test it on real mac?

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko

=== modified file 'grub-core/fs/iso9660.c'

fs/iso9660.c +5 -3
@@ -533,10 +533,12 @@
   grub_off_t len;
   char *symlink = 0;
 
-  auto void add_part (const char *part, int len);
-
   /* Extend the symlink.  */
-  void add_part (const char *part, int len2)
+  auto inline void  __attribute__ ((always_inline)) add_part (const char *part,
+							      int len2);
+
+  auto inline void  __attribute__ ((always_inline)) add_part (const char *part,
+							      int len2)
     {
       int size = symlink ? grub_strlen (symlink) : 0;
 
#1 lore raw
Quoted 8 lines · Vladimir 'φ-coder/phcoder' Serbinenko

Hello all. Based on the information from
http://mjg59.dreamwidth.org/7468.html I intend to add support for such install. It requires a small HFS+ volume mounted at /boot/mactel. I also simplify handling of EFI directories by adding explicit option to specify it and removing some "compatibility" kludges (they don't make anything compatible with anything since "old behaviour" was mostly not to install at all) which made the code in question difficult to maintain.

Matthew will perhaps give a more thorough response, but I would like to add a few quick comments.

Matthew also created http://www.codon.org.uk/~mjg59/mactel-boot/ , so there seems to be some duplicate work there.

His approach is discussed further on https://bugzilla.redhat.com/show_bug.cgi?id=755093 .

A quick summary is that it (in my opinion) is a bit unclear what Macs _really_ needs. There are several ways grub can be used to boot Macs, and it is not completely clear whether HFS blessing or HFS is necessary at all. The Mac boot loader detects FAT partitions and will by default also boot from /EFI/BOOT - also on the system partition. The OS/X "Startup Drive" configuration is a bit more sensitive, but it seems like what it writes to PRAM/VRAM is more important than the HFS blessing.

/Mads

#2 lore raw
Quoted 10 lines · Mads Kiilerich
Quoted 8 lines · Vladimir 'φ-coder/phcoder' Serbinenko

Hello all. Based on the information from
http://mjg59.dreamwidth.org/7468.html I intend to add support for such install. It requires a small HFS+ volume mounted at /boot/mactel. I also simplify handling of EFI directories by adding explicit option to specify it and removing some "compatibility" kludges (they don't make anything compatible with anything since "old behaviour" was mostly not to install at all) which made the code in question difficult to maintain.

Quoted 4 lines

Matthew will perhaps give a more thorough response, but I would like to add a few quick comments.

Matthew also created http://www.codon.org.uk/~mjg59/mactel-boot/ , so there seems to be some duplicate work there.

Well it's a small thing and I actually already had it since 2009 just it was considered useless given that Macs work with standard EFI tools.

Quoted 1 line

His approach is discussed further on https://bugzilla.redhat.com/show_bug.cgi?id=755093 .

I've glanced a bit and have few comments:
- Having no EFI System partition is asking for trouble since it's hard to tell which kind of bugs in different firmware or software it will trigger. So I'd create one even on single-boot install
- I'd prefer double install (as in both to ESP and own HFS+) to be possible. First one is standards-compliant and compatible with other firmware implementation and second one avoids Apple bugs. So I'd prefer to choose another mounting point for HFS+. I suggest /boot/mactel or /boot/mac (second has advantage of being natural if we choose to do the same on PPC (and I'm inclined to it))
- If you want a grub.efi usable everywhere you need to put modules on embed memdisk and not as preload modules since loading modules takes time and potentially exposes user to bugs in the modules he doesn't really need.
- blessed directory and blessed file are independent. Former is used on ppc, later on intel. Please modify only the one for the platform you install for

Quoted 2 lines

A quick summary is that it (in my opinion) is a bit unclear what Macs _really_ needs. There are several ways grub can be used to boot Macs, and it is not completely clear whether HFS blessing or HFS is necessary at all. The Mac boot loader detects FAT partitions and will by default also boot from /EFI/BOOT - also on the system partition. The OS/X "Startup Drive" configuration is a bit more sensitive, but it seems like what it writes to PRAM/VRAM is more important than the HFS blessing.

I don't see this install as something nice and nifty, more like a way to workaround Apple bugs.

Quoted 3 lines

/Mads

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#3 lore raw
In reply to Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 1 line · Vladimir 'φ-coder/phcoder' Serbinenko

Hello all. Based on the information from http://mjg59.dreamwidth.org/7468.html I intend to add support for such install. It requires a small HFS+ volume mounted at /boot/mactel. I also simplify handling of EFI directories by adding explicit option to specify it and removing some "compatibility" kludges (they don't make anything compatible with anything since "old behaviour" was mostly not to install at all) which made the code in question difficult to maintain. Patch attached and branch "mactel" pushed.

Now attached the right patch.

Quoted 2 lines

I've tested only as far as to see the appropriate directory structure in place. Can anybody test it on real mac?

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko

=== modified file 'Makefile.util.def'

Makefile.util.def +14 -0
@@ -43,6 +43,7 @@
   common_nodist = grub_script.tab.h;
 
   common = grub-core/commands/blocklist.c;
+  common = grub-core/commands/macbless.c;
   common = grub-core/commands/xnu_uuid.c;
   common = grub-core/commands/testload.c;
   common = grub-core/commands/ls.c;
@@ -705,3 +706,16 @@
   ldadd = grub-core/gnulib/libgnu.a;
   ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
 };
+
+program = {
+  name = grub-mactelbless;
+  installdir = sbin;
+  mansection = 1;
+  common = util/grub-mactelbless.c;
+
+  ldadd = libgrubmods.a;
+  ldadd = libgrubgcry.a;
+  ldadd = libgrubkern.a;
+  ldadd = grub-core/gnulib/libgnu.a;
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
+};

=== added file 'docs/man/grub-mactelbless.h2m'

man/grub-mactelbless.h2m +4 -0
@@ -0,0 +1,4 @@
+[NAME]
+grub-mactelbless \- Mactel-style HFS+ bless.
+[SEE ALSO]
+.BR grub-install (1)

=== modified file 'grub-core/Makefile.core.def'

Makefile.core.def +5 -0
@@ -1148,6 +1148,11 @@
 };
 
 module = {
+  name = macbless;
+  common = commands/macbless.c;
+};
+
+module = {
   name = pxe;
   i386_pc = net/drivers/i386/pc/pxe.c;
   enable = i386_pc;

=== added file 'grub-core/commands/macbless.c'

commands/macbless.c +220 -0

220 lines not on this page · raw message

=== modified file 'grub-core/fs/hfsplus.c'

fs/hfsplus.c +3 -145

164 lines not on this page · raw message

=== modified file 'include/grub/fs.h'

grub/fs.h +2 -0
@@ -38,7 +38,9 @@
   unsigned dir:1;
   unsigned mtimeset:1;
   unsigned case_insensitive:1;
+  unsigned inodeset:1;
   grub_int32_t mtime;
+  grub_uint64_t inode;
 };
 
 /* Filesystem descriptor.  */

=== added file 'include/grub/hfsplus.h'

grub/hfsplus.h +182 -0

182 lines not on this page · raw message

=== modified file 'util/grub-install.in'

grub-install.in +152 -95

354 lines not on this page · raw message

=== added file 'util/grub-mactelbless.c'

grub-mactelbless.c +214 -0

214 lines not on this page · raw message

#4 lore raw

Hi,

I *REALLY* REALLY like the grub-install changes -- I was about to propose the --efi-directory option myself! THe rest of the code looks ok to me.

--S

Quoted 1 line · Vladimir 'φ-coder/phcoder' Serbinenko

<mactel.diff>

#5 lore raw
In reply to Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 6 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 1 line · Vladimir 'φ-coder/phcoder' Serbinenko

Hello all. Based on the information from http://mjg59.dreamwidth.org/7468.html I intend to add support for such install. It requires a small HFS+ volume mounted at /boot/mactel. I also simplify handling of EFI directories by adding explicit option to specify it and removing some "compatibility" kludges (they don't make anything compatible with anything since "old behaviour" was mostly not to install at all) which made the code in question difficult to maintain. Patch attached and branch "mactel" pushed.

Now attached the right patch.

Quoted 2 lines

I've tested only as far as to see the appropriate directory structure in place. Can anybody test it on real mac?

The only thing I'd suggest, after some more thought, is to remove --efi-directory and just use the install_device (the non-option arg given to grub-install) as the EFI directory -- this is also most-consistent with the usage a user might expect (IMHO).

--S

#6 lore raw
Quoted 14 lines · Seth Goldberg
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 1 line · Vladimir 'φ-coder/phcoder' Serbinenko

Hello all. Based on the information from

http://mjg59.dreamwidth.org/7468.html I intend to add support for such install. It requires a small HFS+ volume mounted at /boot/mactel. I also simplify handling of EFI directories by adding explicit option to specify it and removing some "compatibility" kludges (they don't make anything compatible with anything since "old behaviour" was mostly not to install at all) which made the code in question difficult to maintain. Patch attached and branch "mactel" pushed.

Quoted 2 lines

Now attached the right patch.

Quoted 1 line

I've tested only as far as to see the appropriate directory structure

Quoted 9 lines

in place. Can anybody test it on real mac?

Quoted 2 lines
Quoted 1 line

The only thing I'd suggest, after some more thought, is to remove
--efi-directory and just use the install_device (the non-option arg given to grub-install) as the EFI directory -- this is also most-consistent with the usage a user might expect (IMHO).

The --efi-directory option does same thing as --root-directory option for specifying mountpoint of UEFISYS partition. At first I thought grub-install now allows specifying the EXACT directory where all the files aka grub.efi , *.mod and grub.cfg should exist.

From my understanding of how grub-install works, if I specify

--efi-directory=/boot/efi --bootloader-id=grub2

grubx64.efi is installed at /boot/efi/efi/grub2/grubx64.efi , but the modules are located at /boot/grub (which is $grubdir aka prefix set in grubx64.efi/core.efi). But this again creates confusion for some users who have to find out the "actual" prefix dir in case he/she wants to modify grub.cfg and grubenv in that dir. The only way to force grub-install to install "everything" in /boot/efi/efi/grub/ is to use

--efi-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=grub

Even if I use

--efi-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=grub2

I get /boot/efi/efi/grub/{core.efi,*.mod} and /boot/efi/efi/grub2/grubx64.efi . Is there any option to specify to exact dir (both for grub-install and grub-mkconfig and other related scripts which use --boot-dir and --root-dir)?

I don't know whether it is okay to compare grub2 with syslinux, but extlinux provides --install option to specify the directory where ALL syslinux related files are present, no --root-dir , --boot-dir , --bootloader-id confusion. I want all files under one dir (/boot/efi/efi/grub2, not referencing to /boot/grub or /boot/efi/efi/grub). Thanks in advance.

Regards.

Keshav

#7 lore raw

Hi,

I do think it's important to support installation of the efi boot application in one place but modules (prefix) in another. That scenario makes sense, at least, for oses that store the prefix on redundant file systems/abstractions.

--S

Quoted 40 lines · Keshav P R

On Tue, Nov 29, 2011 at 12:04, Seth Goldberg <[email protected]> wrote:

Quoted 6 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 1 line · Vladimir 'φ-coder/phcoder' Serbinenko

Hello all. Based on the information from http://mjg59.dreamwidth.org/7468.html I intend to add support for such install. It requires a small HFS+ volume mounted at /boot/mactel. I also simplify handling of EFI directories by adding explicit option to specify it and removing some "compatibility" kludges (they don't make anything compatible with anything since "old behaviour" was mostly not to install at all) which made the code in question difficult to maintain. Patch attached and branch "mactel" pushed.

Now attached the right patch.

Quoted 2 lines

I've tested only as far as to see the appropriate directory structure in place. Can anybody test it on real mac?

The only thing I'd suggest, after some more thought, is to remove --efi-directory and just use the install_device (the non-option arg given to grub-install) as the EFI directory -- this is also most-consistent with the usage a user might expect (IMHO).

The --efi-directory option does same thing as --root-directory option for specifying mountpoint of UEFISYS partition. At first I thought grub-install now allows specifying the EXACT directory where all the files aka grub.efi , *.mod and grub.cfg should exist.

From my understanding of how grub-install works, if I specify

--efi-directory=/boot/efi --bootloader-id=grub2

grubx64.efi is installed at /boot/efi/efi/grub2/grubx64.efi , but the modules are located at /boot/grub (which is $grubdir aka prefix set in grubx64.efi/core.efi). But this again creates confusion for some users who have to find out the "actual" prefix dir in case he/she wants to modify grub.cfg and grubenv in that dir. The only way to force grub-install to install "everything" in /boot/efi/efi/grub/ is to use

--efi-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=grub

Even if I use

--efi-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=grub2

I get /boot/efi/efi/grub/{core.efi,*.mod} and /boot/efi/efi/grub2/grubx64.efi . Is there any option to specify to exact dir (both for grub-install and grub-mkconfig and other related scripts which use --boot-dir and --root-dir)?

I don't know whether it is okay to compare grub2 with syslinux, but extlinux provides --install option to specify the directory where ALL syslinux related files are present, no --root-dir , --boot-dir , --bootloader-id confusion. I want all files under one dir (/boot/efi/efi/grub2, not referencing to /boot/grub or /boot/efi/efi/grub). Thanks in advance.

Regards.

Keshav

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#8 lore raw
In reply to Keshav P R
Quoted 1 line · Keshav P R

grubx64.efi is installed at /boot/efi/efi/grub2/grubx64.efi , but the modules are located at /boot/grub (which is $grubdir aka prefix set in grubx64.efi/core.efi). But this again creates confusion for some users who have to find out the "actual" prefix dir in case he/she wants to modify grub.cfg and grubenv in that dir. The only way to force grub-install to install "everything" in /boot/efi/efi/grub/ is to us

The modules and configuration files form platform-independent part as far as install is concerned (it's always handles the same way). The grub.efi is the EFI specific part which needs to go where EFI expects it. /efi directory on ESP as its name implies stores files for EFI, perhaps some small config files, it is not to store our bunch of modules. It's ok to use ESP to store modules unless they go into /efi directory but it's hard to say if such a long list of files will trigger any bugs in firmware implementation but in any case platform-independent part shouldn't go into firmware-specific directories. We've already had issues with IEEE1275 when we did something similar

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#9 lore raw

2011/11/29 Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]>

Quoted 11 lines · Keshav P R
Quoted 8 lines

grubx64.efi is installed at /boot/efi/efi/grub2/grubx64.**efi , but the modules are located at /boot/grub (which is $grubdir aka prefix set in grubx64.efi/core.efi). But this again creates confusion for some users who have to find out the "actual" prefix dir in case he/she wants to modify grub.cfg and grubenv in that dir. The only way to force grub-install to install "everything" in /boot/efi/efi/grub/ is to us

Quoted 11 lines

The modules and configuration files form platform-independent part as far
as install is concerned (it's always handles the same way). The grub.efi is the EFI specific part which needs to go where EFI expects it. /efi directory on ESP as its name implies stores files for EFI, perhaps some small config files, it is not to store our bunch of modules. It's ok to use ESP to store modules unless they go into /efi directory but it's hard to say if such a long list of files will trigger any bugs in firmware implementation but in any case platform-independent part shouldn't go into firmware-specific directories. We've already had issues with IEEE1275 when we did something similar

The problem i have is installing both grub2 i386-pc and x86_64-efi . Both have /boot/grub as $grubdir . I use /boot/grub for all grub2-bios stuff and /boot/efi/efi/grub for all grub2-efi-x86_64 related stuff. I have not seen any issue with having modules in <UEFISYS>/efi/grub dir itself. AFAIK the modules are platform dependent since one can't use i386-pc modules in i386-efi and vice-versa. x86_64-efi is out of question since its a different arch. I guess for now doing

sed 's|/boot/grub|/boot/efi/efi/grub|g' -i grub-mkconfig

will do, until you implement the platform specific subdir idea you mentioned. Thanks for clarifying this. For me this is not an issue. But I also maintain grub2 packages in Archlinux. What should I tell the users (those who have both grub2-bios and grub2-efi-x86_64), use /boot/efi/efi/grub for everything or do the sed stuff for grub-{install,mkconfig}?

sed 's|/boot/grub|/boot/grub-efi|g' -i grub-{install,mkconfig}

TIA.

Regards.

Keshav

Quoted 6 lines

--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko

#10 lore raw
Quoted 25 lines · Keshav P R

2011/11/29 Vladimir 'φ-coder/phcoder' Serbinenko <[email protected] <mailto:[email protected]>>

On 29.11.2011 08:25, Keshav P R wrote:

grubx64.efi is installed at /boot/efi/efi/grub2/grubx64.efi ,
but the modules are located at /boot/grub (which is $grubdir
aka prefix set in grubx64.efi/core.efi). But this again creates confusion for some users who have to find out the "actual" prefix dir in case he/she wants to modify grub.cfg and grubenv in that dir. The only way to force grub-install to install "everything" in /boot/efi/efi/grub/ is to us

The modules and configuration files form platform-independent part as far as install is concerned (it's always handles the same way). The grub.efi is the EFI specific part which needs to go where EFI expects it. /efi directory on ESP as its name implies stores files for EFI, perhaps some small config files, it is not to store our bunch of modules. It's ok to use ESP to store modules unless they go into /efi directory but it's hard to say if such a long list of files will trigger any bugs in firmware implementation but in any case platform-independent part shouldn't go into firmware-specific directories. We've already had issues with IEEE1275 when we did something similar

Quoted 6 lines

The problem i have is installing both grub2 i386-pc and x86_64-efi . Both have /boot/grub as $grubdir . I use /boot/grub for all grub2-bios stuff and /boot/efi/efi/grub for all grub2-efi-x86_64 related stuff. I have not seen any issue with having modules in <UEFISYS>/efi/grub dir itself. AFAIK the modules are platform dependent since one can't use i386-pc modules in i386-efi and vice-versa. x86_64-efi is out of question since its a different arch. I guess for now doing

sed 's|/boot/grub|/boot/efi/efi/grub|g' -i grub-mkconfig

will do, until you implement the platform specific subdir idea you mentioned. Thanks for clarifying this. For me this is not an issue. But I also maintain grub2 packages in Archlinux. What should I tell the users (those who have both grub2-bios and grub2-efi-x86_64), use /boot/efi/efi/grub for everything or do the sed stuff for grub-{install,mkconfig}?

--boot-directory=/boot-bios and --boot-directory=/boot-efi

Quoted 14 lines

sed 's|/boot/grub|/boot/grub-efi|g' -i grub-{install,mkconfig}

TIA.

Regards.

Keshav

--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko