grub-install revamp
Hello, all. It was a Robert's idea of having grub-install to install all available (as in: the ones which were make install'ed) ports in a single grub-install w/o having to keep and run one grub-install per port. This has an advantage of making the disk bootable in various ways including ability to move it from one computer to another.
The first problem is the files collision. To resolve this the modification will be to load modules from $prefix/$cpu-$platform/$modname.mod. Also 2 new script constants will be defined: $cpu and $platform. The problem then is that different firmwares require different kind of arrangements in order to be bootable.
i386-pc requires 55AA signature, some code in MBR and embedding zone. A dummy msdos active partition is required on some systems.
*-efi require files on ESP and some nvram entries
i386-qemu, i386-coreboot, i386-qemu_mips and loongsoon-firmware are firmware ports and we don't use grub-install for those but grub-mkstandalone.
i386-multiboot just has to be readable by whatever is a coreboot payload.
mipsel-loongson has to be on ext2 msdos partition.
sparc64 requires SUN partition map and the code in sector 1
Powerpc (Apple) requires a file on HFS and nvram modification
PowerPC (IBM) uses PreP partition
ARC uses a special entry in the dvh partition table
I have no idea what i386-ieee1275 requires but I guess it's a fat partition with special file + nvram modification.
So I propose following strategy: grub-install does the following platform-specific installations:
- if /boot/efi is on fat, copy grub to /boot/efi/efi/$boot_id/grub[ia32|x64|ia64].efi (replace $boot_id and grub with boot if --removable is specified) and update nvram if no --removable is specified and currently running EFI version matches the installed one.
- if /boot/mac is on HFS or HFS+, create there a structure recognized by both PPC and Intel macs and update nvram if architecture matches
- If /boot/ext2 is on ext*, put mipsel-loongson and i386-multiboot there.
- If /boot/olpc is on fat, install i386-ieee1275 there and update nvram if architecture matches.
- For every argument that is an msdos or gpt disk, install i386-pc bootsector.
- For every argument that is a sun disk, install sun bootsector.
- For every argument that is a dvh disk, install mips-arc.
- For every argument that is a prep partition install powerpc-ieee1275
While the copying to partitions is harmless and updating nvram is done only if architecture and platform matches, the disk operations may be harmful. While none of the current 4 configuration usually come in contradictory combinations, it's possible to purposedly create a disk of multiple types and it will confuse this logic. Also if we throw e.g. hppa into the mix which requires just a signature on bytes 0-1 and some info in 0xf4-0xff then we can't know if msdos disk is for BIOS or hppa install. So we need a way to specify them more precisely. PreP and ARC came in only after 1.99 so we can make them accept only the new way whatever it will be. In case of old way we can easily distinguish sparc64-ieee1275 and i386-pc with e.g. uname -i. I propose either of:
--device-bios=/dev/xyz --device-sun=/dev/xyz --device-arc=/dev/xyz --device-prep=/dev/xyz
Or: bios:/dev/xyz sun:/dev/xyz arc:/dev/xyz prep:/dev/xyz
Also it may happen that installation of some port is undesirable. So we need options --install-only=...
--exclude=...
Any further ideas?
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 1 line · Vladimir 'φ-coder/phcoder' Serbinenko
Hello, all. It was a Robert's idea of having grub-install to install all available (as in: the ones which were make install'ed) ports in a single grub-install w/o having to keep and run one grub-install per port.
I've tried to write such a thing. I have met some problems in practice:
- I wanted also to integrate mactelbless in the same time. Unfortunately Apple uses the same pointer for both i386 and x86_64 efi. So hfs(+) partitions can hold only either 32-bit or 64-bit EFI binary. We could use "FAT Binary" to workaround this but not all macs support this.
- If one of platform specific installs fail the script doesn't install other platforms.
- When modifying nvram on EFI where to point it to? ESP or HFS? This is easy: HFS if it's a mac and ESP otherwise. Or just always ESP.
- The same problem for ieee1275. While distinguishing between mac and non-mac is easy (check vendor string), I don't know how to distinguish the ones using PreP partition and the ones using a file on a FAT fs.
I would appreciate any input both on these specific problems and the idea in general. Perhaps it's better to abandon it and have something easier like auto-detect firmware and use it as default and specify it manually if you need a different install. The attached patch is just a small illustration to discuss about. It doesn't work
Quoted 40 lines
This has an advantage of making the disk bootable in various ways including ability to move it from one computer to another.
The first problem is the files collision. To resolve this the modification will be to load modules from $prefix/$cpu-$platform/$modname.mod. Also 2 new script constants will be defined: $cpu and $platform. The problem then is that different firmwares require different kind of arrangements in order to be bootable.
i386-pc requires 55AA signature, some code in MBR and embedding zone. A dummy msdos active partition is required on some systems.
*-efi require files on ESP and some nvram entries
i386-qemu, i386-coreboot, i386-qemu_mips and loongsoon-firmware are firmware ports and we don't use grub-install for those but grub-mkstandalone.
i386-multiboot just has to be readable by whatever is a coreboot payload.
mipsel-loongson has to be on ext2 msdos partition.
sparc64 requires SUN partition map and the code in sector 1
Powerpc (Apple) requires a file on HFS and nvram modification
PowerPC (IBM) uses PreP partition
ARC uses a special entry in the dvh partition table
I have no idea what i386-ieee1275 requires but I guess it's a fat partition with special file + nvram modification.So I propose following strategy: grub-install does the following platform-specific installations:
- if/boot/efiis on fat, copy grub to
/boot/efi/efi/$boot_id/grub[ia32|x64|ia64].efi (replace $boot_id and grub with boot if --removable is specified) and update nvram if no --removable is specified and currently running EFI version matches the
installed one.
- if/boot/macis on HFS or HFS+, create there a structure recognized
by both PPC and Intel macs and update nvram if architecture matches
- If/boot/ext2is on ext*, put mipsel-loongson and i386-multiboot there.
- If/boot/olpcis on fat, install i386-ieee1275 there and update
nvram if architecture matches.
- For every argument that is an msdos or gpt disk, install i386-pc
bootsector.
- For every argument that is a sun disk, install sun bootsector.
- For every argument that is a dvh disk, install mips-arc.
- For every argument that is a prep partition install powerpc-ieee1275While the copying to partitions is harmless and updating nvram is done only if architecture and platform matches, the disk operations may be harmful. While none of the current 4 configuration usually come in contradictory combinations, it's possible to purposedly create a disk of multiple types and it will confuse this logic. Also if we throw e.g. hppa into the mix which requires just a signature on bytes 0-1 and some info in 0xf4-0xff then we can't know if msdos disk is for BIOS or hppa install. So we need a way to specify them more precisely. PreP and ARC came in only after 1.99 so we can make them accept only the new way whatever it will be. In case of old way we can easily distinguish sparc64-ieee1275 and i386-pc with e.g. uname -i. I propose either of:
--device-bios=/dev/xyz --device-sun=/dev/xyz --device-arc=/dev/xyz
--device-prep=/dev/xyz
Or: bios:/dev/xyz sun:/dev/xyz arc:/dev/xyz prep:/dev/xyzAlso it may happen that installation of some port is undesirable. So we need options --install-only=...
--exclude=...
Any further ideas?
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
=== modified file 'Makefile.util.def'
Makefile.util.def +33 -22
@@ -309,39 +309,51 @@ }; program = { - name = grub-setup; - installdir = sbin; - mansection = 8; - common = util/grub-setup.c; - common = util/lvm.c; - common = grub-core/lib/reed_solomon.c; - - sparc64_ieee1275 = util/ieee1275/ofpath.c; - - ldadd = libgrubmods.a; - ldadd = libgrubkern.a; - ldadd = libgrubgcry.a; - ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; - - enable = i386_pc; - enable = sparc64_ieee1275; + name = grub-bios-setup; + installdir = sbin; + mansection = 8; + common = util/grub-setup.c; + common = util/lvm.c; + common = grub-core/lib/reed_solomon.c; + + ldadd = libgrubmods.a; + ldadd = libgrubkern.a; + ldadd = libgrubgcry.a; + ldadd = grub-core/gnulib/libgnu.a; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; + cppflags = '-DGRUB_SETUP_BIOS=1'; +}; + +program = { + name = grub-sparc64-setup; + installdir = sbin; + mansection = 8; + common = util/grub-setup.c; + common = util/lvm.c; + common = grub-core/lib/reed_solomon.c; + + common = util/ieee1275/ofpath.c; + + ldadd = libgrubmods.a; + ldadd = libgrubkern.a; + ldadd = libgrubgcry.a; + ldadd = grub-core/gnulib/libgnu.a; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; + cppflags = '-DGRUB_SETUP_SPARC64=1'; }; program = { name = grub-ofpathname; installdir = sbin; mansection = 8; - ieee1275 = util/ieee1275/grub-ofpathname.c; - ieee1275 = util/ieee1275/ofpath.c; + common = util/ieee1275/grub-ofpathname.c; + common = util/ieee1275/ofpath.c; ldadd = libgrubmods.a; ldadd = libgrubgcry.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBGEOM)'; - - enable = sparc64_ieee1275; }; program = {
@@ -461,7 +473,6 @@ name = grub-install; common = util/grub-install.in; - enable = noemu; }; script = {
=== modified file 'configure.ac'
configure.ac +0 -3
@@ -187,9 +187,6 @@ AC_SUBST(host_os) AC_SUBST(host_kernel) -AC_SUBST(target_cpu) -AC_SUBST(platform) - # Define default variables case "$host_os" in netbsd* | openbsd*)
=== modified file 'util/grub-install.in'
grub-install.in +507 -338
965 lines not on this page · raw message
=== modified file 'util/grub-setup.c'
grub-setup.c +18 -18
@@ -33,7 +33,7 @@#include <grub/term.h> #include <grub/i18n.h> #include <grub/util/lvm.h> -#ifdef GRUB_MACHINE_IEEE1275 +#ifdef GRUB_SETUP_SPARC64 #include <grub/util/ofpath.h> #endif
@@ -77,14 +77,14 @@#define DEFAULT_BOOT_FILE "boot.img"#define DEFAULT_CORE_FILE "core.img" -#ifdef GRUB_MACHINE_SPARC64 +#ifdef GRUB_SETUP_SPARC64 #define grub_target_to_host16 (x) grub_be_to_cpu16(x)#define grub_target_to_host32 (x) grub_be_to_cpu32(x)#define grub_target_to_host64 (x) grub_be_to_cpu64(x)#define grub_host_to_target16 (x) grub_cpu_to_be16(x)#define grub_host_to_target32 (x) grub_cpu_to_be32(x)#define grub_host_to_target64 (x) grub_cpu_to_be64(x) -#elif defined (GRUB_MACHINE_PCBIOS ) +#elif defined (GRUB_SETUP_BIOS )#define grub_target_to_host16 (x) grub_le_to_cpu16(x)#define grub_target_to_host32 (x) grub_le_to_cpu32(x)#define grub_target_to_host64 (x) grub_le_to_cpu64(x)
@@ -99,7 +99,7 @@ write_rootdev (char *core_img, grub_device_t root_dev, char *boot_img, grub_uint64_t first_sector) { -#ifdef GRUB_MACHINE_PCBIOS +#ifdef GRUB_SETUP_BIOS {grub_uint8_t *boot_drive;grub_disk_addr_t *kernel_sector;
@@ -113,7 +113,7 @@ *kernel_sector =grub_cpu_to_le64 (first_sector); }#endif -#ifdef GRUB_MACHINE_IEEE1275 +#ifdef GRUB_SETUP_SPARC64 {grub_disk_addr_t *kernel_byte; kernel_byte = (grub_disk_addr_t *) (boot_img
@@ -124,7 +124,7 @@#endif } -#ifdef GRUB_MACHINE_IEEE1275 +#ifdef GRUB_SETUP_SPARC64 #define BOOT_SECTOR 1#else #define BOOT_SECTOR 0
@@ -145,7 +145,7 @@char *tmp_img;int i;grub_disk_addr_t first_sector; -#ifdef GRUB_MACHINE_PCBIOS +#ifdef GRUB_SETUP_BIOS grub_uint16_t current_segment =GRUB_BOOT_MACHINE_KERNEL_SEG + (GRUB_DISK_SECTOR_SIZE >>4 );#endif
@@ -192,7 +192,7 @@ { block->start =grub_host_to_target64 (sector); block->len =grub_host_to_target16 (1 ); -#ifdef GRUB_MACHINE_PCBIOS +#ifdef GRUB_SETUP_BIOS block->segment =grub_host_to_target16 (current_segment);#endif
@@ -202,7 +202,7 @@ } last_length = length; -#ifdef GRUB_MACHINE_PCBIOS +#ifdef GRUB_SETUP_BIOS current_segment +=GRUB_DISK_SECTOR_SIZE >>4 ;#endif }
@@ -222,7 +222,7 @@ >> GRUB_DISK_SECTOR_BITS);if (core_size <GRUB_DISK_SECTOR_SIZE )grub_util_error (_ ("the size of `%s' is too small" ), core_path); -#ifdef GRUB_MACHINE_PCBIOS +#ifdef GRUB_SETUP_BIOS if (core_size >0xFFFF *GRUB_DISK_SECTOR_SIZE )grub_util_error (_ ("the size of `%s' is too large" ), core_path);#endif
@@ -250,14 +250,14 @@if (grub_env_set ("root" , root) !=GRUB_ERR_NONE )grub_util_error ("%s" ,_ (grub_errmsg)); -#ifdef GRUB_MACHINE_PCBIOS +#ifdef GRUB_SETUP_BIOS /* Read the original sector from the disk. */ tmp_img =xmalloc (GRUB_DISK_SECTOR_SIZE );if (grub_disk_read (dest_dev->disk,0 ,0 ,GRUB_DISK_SECTOR_SIZE , tmp_img))grub_util_error ("%s" ,_ (grub_errmsg));#endif -#ifdef GRUB_MACHINE_PCBIOS +#ifdef GRUB_SETUP_BIOS {grub_uint16_t *boot_drive_check; boot_drive_check = (grub_uint16_t *) (boot_img
@@ -276,7 +276,7 @@ }#endif -#ifdef GRUB_MACHINE_PCBIOS +#ifdef GRUB_SETUP_BIOS {grub_partition_map_t dest_partmap =NULL ;grub_partition_t container = dest_dev->disk->partition;
@@ -331,7 +331,7 @@ is_ldm =grub_util_is_ldm (dest_dev->disk); -#ifdef GRUB_MACHINE_PCBIOS +#ifdef GRUB_SETUP_BIOS if (fs_probe) {if (!fs && !dest_partmap)
@@ -502,7 +502,7 @@ unable_to_embed: -#ifdef GRUB_MACHINE_PCBIOS +#ifdef GRUB_SETUP_BIOS if (dest_dev->disk->id != root_dev->disk->id || dest_dev->disk->dev->id != root_dev->disk->dev->id) grub_util_error (_("embedding is not possible, but this is required for "
@@ -603,7 +603,7 @@ { block->start =0 ; block->len =0 ; -#ifdef GRUB_MACHINE_PCBIOS +#ifdef GRUB_SETUP_BIOS block->segment =0 ;#endif
@@ -630,7 +630,7 @@ != (grub_ssize_t) core_size - GRUB_DISK_SECTOR_SIZE)grub_util_error (_ ("failed to read the rest sectors of the core image" )); -#ifdef GRUB_MACHINE_IEEE1275 +#ifdef GRUB_SETUP_SPARC64 {char *boot_devpath; boot_devpath = (char *) (boot_img
@@ -889,7 +889,7 @@exit (1 ); } -#ifdef GRUB_MACHINE_IEEE1275 +#ifdef GRUB_SETUP_SPARC64 arguments.force =1 ;#endif
=== modified file 'util/powerpc/ieee1275/grub-mkrescue.in'
powerpc/ieee1275/grub-mkrescue.in +1 -3
@@ -27,9 +27,7 @@ PACKAGE_NAME=@PACKAGE_NAME@ PACKAGE_TARNAME=@PACKAGE_TARNAME@ PACKAGE_VERSION=@PACKAGE_VERSION@ -target_cpu=@target_cpu@ -platform=@platform@ -pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}` +pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/powerpc-ieee1275 | sed ${transform}` self=`basename $0`
Status of mactel bless in grub2 v2.00 code freeze?
- Keshav
Quoted 92 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 3 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Hello, all. It was a Robert's idea of having grub-install to install all available (as in: the ones which were make install'ed) ports in a single grub-install w/o having to keep and run one grub-install per port.
I've tried to write such a thing. I have met some problems in practice:
- I wanted also to integrate mactelbless in the same time. Unfortunately Apple uses the same pointer for both i386 andx86_64efi. So hfs(+) partitions can hold only either 32-bit or 64-bit EFI binary. We could use "FAT Binary" to workaround this but not all macs support this.
- If one of platform specific installs fail the script doesn't install other platforms.
- When modifying nvram on EFI where to point it to? ESP or HFS? This is
easy: HFS if it's a mac and ESP otherwise. Or just always ESP.
- The same problem for ieee1275. While distinguishing between mac and non-mac is easy (check vendor string), I don't know how to distinguish the ones using PreP partition and the ones using a file on a FAT fs. I would appreciate any input both on these specific problems and the idea in general. Perhaps it's better to abandon it and have something easier like auto-detect firmware and use it as default and specify it manually if you need a different install.
The attached patch is just a small illustration to discuss about. It doesn't workQuoted 57 lines
This has an advantage of making the disk bootable in various ways including ability to move it from one computer to another. The first problem is the files collision. To resolve this the modification will be to load modules from $prefix/$cpu-$platform/$modname.mod. Also 2 new script constants will be defined: $cpu and $platform.
The problem then is that different firmwares require different kind of arrangements in order to be bootable.
i386-pc requires 55AA signature, some code in MBR and embedding zone. A dummy msdos active partition is required on some systems. *-efi require files on ESP and some nvram entries
i386-qemu, i386-coreboot, i386-qemu_mips and loongsoon-firmware are firmware ports and we don't use grub-install for those but grub-mkstandalone.
i386-multiboot just has to be readable by whatever is a coreboot payload. mipsel-loongson has to be on ext2 msdos partition.
sparc64 requires SUN partition map and the code in sector 1 Powerpc (Apple) requires a file on HFS and nvram modification PowerPC (IBM) uses PreP partition
ARC uses a special entry in the dvh partition table
I have no idea what i386-ieee1275 requires but I guess it's a fat partition with special file + nvram modification.So I propose following strategy: grub-install does the following platform-specific installations:
- if/boot/efiis on fat, copy grub to /boot/efi/efi/$boot_id/grub[ia32|x64|ia64].efi (replace $boot_id and grub with boot if --removable is specified) and update nvram if no --removable is specified and currently running EFI version matches the installed one.
- if/boot/macis on HFS or HFS+, create there a structure recognized by both PPC and Intel macs and update nvram if architecture matches
- If/boot/ext2is on ext*, put mipsel-loongson and i386-multiboot there.
- If/boot/olpcis on fat, install i386-ieee1275 there and update nvram if architecture matches.
- For every argument that is an msdos or gpt disk, install i386-pc bootsector.
- For every argument that is a sun disk, install sun bootsector.
- For every argument that is a dvh disk, install mips-arc.
- For every argument that is a prep partition install powerpc-ieee1275While the copying to partitions is harmless and updating nvram is done only if architecture and platform matches, the disk operations may be harmful. While none of the current 4 configuration usually come in contradictory combinations, it's possible to purposedly create a disk of multiple types and it will confuse this logic. Also if we throw e.g. hppa into the mix which requires just a signature on bytes 0-1 and some info in 0xf4-0xff then we can't know if msdos disk is for BIOS or hppa install. So we need a way to specify them more precisely. PreP and ARC came in only after 1.99 so we can make them accept only the new way whatever it will be. In case of old way we can easily distinguish sparc64-ieee1275 and i386-pc with e.g. uname -i. I propose either of:
--device-bios=/dev/xyz --device-sun=/dev/xyz --device-arc=/dev/xyz --device-prep=/dev/xyz
Or: bios:/dev/xyz sun:/dev/xyz arc:/dev/xyz prep:/dev/xyzQuoted 6 lines
Also it may happen that installation of some port is undesirable. So we need options
--install-only=...
--exclude=...
Any further ideas?--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko