diff mbox series

[v3,4/7] fs/iso9660: add support for hybrid image using Grub bootloader on BIOS and EFI

Message ID 20210923155726.87851-5-kory.maincent@bootlin.com
State Accepted
Headers show
Series Add support for ISO9660 image compatible with Legacy and EFI BIOS | expand

Commit Message

Köry Maincent Sept. 23, 2021, 3:57 p.m. UTC
Add support for building an hybrid ISO9660 image compatible with legacy
and UEFI BIOS.
The option -eltorito-alt-boot need to be used in the xorriso command
to generate the hybrid image.

Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---

Changes in v2:
- Fix typos

Changes in v3:
- Follow changes brougt by modification of the third patch.

 fs/iso9660/Config.in  | 16 +++++++--------
 fs/iso9660/iso9660.mk | 45 ++++++++++++++++++++++++++++---------------
 2 files changed, 36 insertions(+), 25 deletions(-)

Comments

Köry Maincent Sept. 29, 2021, 8:23 a.m. UTC | #1
Yann,

On Mon, 27 Sep 2021 23:05:14 +0200
"Yann E. MORIN" <yann.morin.1998@free.fr> wrote:

> Köry, All,
> 
> On 2021-09-23 17:57 +0200, Kory Maincent spake thusly:
> > Add support for building an hybrid ISO9660 image compatible with legacy
> > and UEFI BIOS.
> > The option -eltorito-alt-boot need to be used in the xorriso command
> > to generate the hybrid image.  
> 
> So I was wondering why you had to rename the variables, and why you
> split the values with -eltorito-alt-boot right in between...
> 
> As I understand it from the xorriso command line, -eltorito-alt-boot
> basically means "OK, we're done with the previous boot parameters, now
> we start a new set of boot parameters", so the order of options *is*
> important.
> 
> Right?

Right

> 
> Furthermore, -eltorito-alt-boot and -no-emul-boot are not conflicting,
> because the former is really this separator as discussed above, while
> the latter specifies the type of the current boot image.
> 
> Right?

Right

> 
> (For my information: how many such alternate boot parameters can we
> define: is it limited to just two, or can we add more?)

According to xorriso manual we can add up to 32 boot catalog entries.

> 
> > Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> > ---  
> [--SNIP--]
> > diff --git a/fs/iso9660/iso9660.mk b/fs/iso9660/iso9660.mk
> > index 921efa1b02..9c2535d102 100644
> > --- a/fs/iso9660/iso9660.mk
> > +++ b/fs/iso9660/iso9660.mk  
> [--SNIP--]
> > @@ -151,24 +156,32 @@ endif # ROOTFS_ISO9660_USE_INITRD
> >  
> >  ROOTFS_ISO9660_OPTS += \
> >  	-J \
> > -	-R \
> > -	-no-emul-boot
> > +	-R
> >  
> > -ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER),y)
> > -ROOTFS_ISO9660_OPTS += \
> > +ROOTFS_ISO9660_BOOTLOADER_OPTS_BIOS = \  
> 
>     ROOTFS_ISO9660_OPTS_BIOS
> 
> > +	-b $(ROOTFS_ISO9660_BOOT_IMAGE) \
> > +	-no-emul-boot \
> >  	-boot-load-size 4 \
> > -	-boot-info-table \
> > -	-b $(ROOTFS_ISO9660_BOOT_IMAGE)
> > -endif
> > +	-boot-info-table  
> 
> You are also reordering the remaining options. Is that really necessary?
> Or is it for symmetry with the EFI case where the "image" option comes
> first?

It was for symmetry.

> 
> > -ifeq ($(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),y)
> > -ROOTFS_ISO9660_OPTS += \
> > -	--efi-boot $(ROOTFS_ISO9660_EFI_PARTITION)
> > +ROOTFS_ISO9660_BOOTLOADER_OPTS_EFI = \  
> 
>     ROOTFS_ISO9660_OPTS_EFI
> 
> > +	--efi-boot $(ROOTFS_ISO9660_EFI_PARTITION) \
> > +	-no-emul-boot
> > +
> > +ifeq
> > ($(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER)$(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),yy)
> > +ROOTFS_ISO9660_BOOTLOADER_OPTS = $(ROOTFS_ISO9660_BOOTLOADER_OPTS_BIOS)
> > +ROOTFS_ISO9660_BOOTLOADER_OPTS += -eltorito-alt-boot
> > +ROOTFS_ISO9660_BOOTLOADER_OPTS += $(ROOTFS_ISO9660_BOOTLOADER_OPTS_EFI)  
> 
> Hmmm This is pretty ugly... What about:
> 
>     ROOTFS_ISO9660_OPTS += \
>         $(ROOTFS_ISO9660_OPTS_BIOS) \
>         -eltorito-alt-boot \
>         $(ROOTFS_ISO9660_OPTS_EFI)
> 
> Also, does BIOS really has to come before EFI? If so, why?

It seems BIOS need to be the first boot option. I have not found any
information about it but if I invert BIOS and EFI options it doesn't boot. 

Regards,
Köry
Yann E. MORIN Sept. 29, 2021, 9:26 p.m. UTC | #2
Köry, All,

On 2021-09-23 17:57 +0200, Kory Maincent spake thusly:
> Add support for building an hybrid ISO9660 image compatible with legacy
> and UEFI BIOS.
> The option -eltorito-alt-boot need to be used in the xorriso command
> to generate the hybrid image.
> 
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>

Applied to master, thanks, with the folowing changes;

  - note about hybrid vs. (iso)hybrid
  - explain -eltorito-alt-boot
  - explain duplication of -no-emul-boot
  - rename the variables
  - note about the BIOS-EFI ordering

Since I had done a few changes in the previous patches, of course I had
to resolve the conflicts when applying this patch... I've tried to be as
carefull as I could, but I may have (again!) let some issues slip
theough...

Could you please review/test that it is till works as expected?

I don't think the remaining patches need rebasing, though, so I hope I
can handle more than one next evening... :-/

Regards,
Yann E. MORIN.

> ---
> 
> Changes in v2:
> - Fix typos
> 
> Changes in v3:
> - Follow changes brougt by modification of the third patch.
> 
>  fs/iso9660/Config.in  | 16 +++++++--------
>  fs/iso9660/iso9660.mk | 45 ++++++++++++++++++++++++++++---------------
>  2 files changed, 36 insertions(+), 25 deletions(-)
> 
> diff --git a/fs/iso9660/Config.in b/fs/iso9660/Config.in
> index f8f577506d..8c4e7badf8 100644
> --- a/fs/iso9660/Config.in
> +++ b/fs/iso9660/Config.in
> @@ -27,6 +27,10 @@ choice
>  config BR2_TARGET_ROOTFS_ISO9660_GRUB2
>  	bool "grub2"
>  	depends on BR2_TARGET_GRUB2
> +	select BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER \
> +		if BR2_TARGET_GRUB2_I386_PC
> +	select BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER \
> +		if (BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI)
>  	help
>  	  Use Grub 2 as the bootloader for the ISO9660 image. Make
>  	  sure to enable the 'iso9660' module in
> @@ -39,21 +43,15 @@ config BR2_TARGET_ROOTFS_ISO9660_GRUB2
>  config BR2_TARGET_ROOTFS_ISO9660_ISOLINUX
>  	bool "isolinux"
>  	depends on BR2_TARGET_SYSLINUX_ISOLINUX
> +	select BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER
>  
>  endchoice
>  
> -choice
> -	prompt "Boot payload"
> -
>  config BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER
> -	bool "legacy bios"
> -	depends on BR2_TARGET_GRUB2_I386_PC || BR2_TARGET_ROOTFS_ISO9660_ISOLINUX
> +	bool
>  
>  config BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER
> -	bool "UEFI"
> -	depends on BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI
> -
> -endchoice
> +	bool
>  
>  config BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU
>  	string "Boot menu config file"
> diff --git a/fs/iso9660/iso9660.mk b/fs/iso9660/iso9660.mk
> index 921efa1b02..9c2535d102 100644
> --- a/fs/iso9660/iso9660.mk
> +++ b/fs/iso9660/iso9660.mk
> @@ -67,18 +67,20 @@ ROOTFS_ISO9660_DEPENDENCIES += grub2
>  ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \
>  	$(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub.cfg
>  ROOTFS_ISO9660_BOOT_IMAGE = boot/grub/grub-eltorito.img
> -define ROOTFS_ISO9660_INSTALL_BOOTLOADER
> +define ROOTFS_ISO9660_INSTALL_BOOTLOADER_BIOS
>  	$(INSTALL) -D -m 0644 $(BINARIES_DIR)/grub-eltorito.img \
>  		$(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub-eltorito.img
>  endef
> -else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2)$(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),yy)
> +endif
> +
> +ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2)$(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),yy)
>  ROOTFS_ISO9660_DEPENDENCIES += grub2 host-dosfstools host-mtools
>  ROOTFS_ISO9660_EFI_PARTITION = boot/fat.efi
>  ROOTFS_ISO9660_EFI_PARTITION_PATH = $(ROOTFS_ISO9660_TMP_TARGET_DIR)/$(ROOTFS_ISO9660_EFI_PARTITION)
>  ROOTFS_ISO9660_EFI_PARTITION_CONTENT = $(BINARIES_DIR)/efi-part
>  ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \
>  	$(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub.cfg
> -define ROOTFS_ISO9660_INSTALL_BOOTLOADER
> +define ROOTFS_ISO9660_INSTALL_BOOTLOADER_EFI
>  	rm -rf $(ROOTFS_ISO9660_EFI_PARTITION_PATH)
>  	mkdir -p $(dir $(ROOTFS_ISO9660_EFI_PARTITION_PATH))
>  	dd if=/dev/zero of=$(ROOTFS_ISO9660_EFI_PARTITION_PATH) bs=1M count=1
> @@ -87,12 +89,14 @@ define ROOTFS_ISO9660_INSTALL_BOOTLOADER
>  	$(HOST_DIR)/bin/mcopy -p -m -i $(ROOTFS_ISO9660_EFI_PARTITION_PATH) -s \
>  		$(ROOTFS_ISO9660_EFI_PARTITION_CONTENT)/* ::/
>  endef
> -else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_ISOLINUX),y)
> +endif
> +
> +ifeq ($(BR2_TARGET_ROOTFS_ISO9660_ISOLINUX),y)
>  ROOTFS_ISO9660_DEPENDENCIES += syslinux
>  ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \
>  	$(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/isolinux.cfg
>  ROOTFS_ISO9660_BOOT_IMAGE = isolinux/isolinux.bin
> -define ROOTFS_ISO9660_INSTALL_BOOTLOADER
> +define ROOTFS_ISO9660_INSTALL_BOOTLOADER_BIOS
>  	$(INSTALL) -D -m 0644 $(BINARIES_DIR)/syslinux/* \
>  		$(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/
>  	$(INSTALL) -D -m 0644 $(HOST_DIR)/share/syslinux/ldlinux.c32 \
> @@ -105,7 +109,8 @@ define ROOTFS_ISO9660_PREPARATION
>  		$(ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH)
>  	$(SED) "s%__KERNEL_PATH__%/boot/$(LINUX_IMAGE_NAME)%" \
>  		$(ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH)
> -	$(ROOTFS_ISO9660_INSTALL_BOOTLOADER)
> +	$(ROOTFS_ISO9660_INSTALL_BOOTLOADER_BIOS)
> +	$(ROOTFS_ISO9660_INSTALL_BOOTLOADER_EFI)
>  endef
>  
>  ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_PREPARATION
> @@ -151,24 +156,32 @@ endif # ROOTFS_ISO9660_USE_INITRD
>  
>  ROOTFS_ISO9660_OPTS += \
>  	-J \
> -	-R \
> -	-no-emul-boot
> +	-R
>  
> -ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER),y)
> -ROOTFS_ISO9660_OPTS += \
> +ROOTFS_ISO9660_BOOTLOADER_OPTS_BIOS = \
> +	-b $(ROOTFS_ISO9660_BOOT_IMAGE) \
> +	-no-emul-boot \
>  	-boot-load-size 4 \
> -	-boot-info-table \
> -	-b $(ROOTFS_ISO9660_BOOT_IMAGE)
> -endif
> +	-boot-info-table
>  
> -ifeq ($(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),y)
> -ROOTFS_ISO9660_OPTS += \
> -	--efi-boot $(ROOTFS_ISO9660_EFI_PARTITION)
> +ROOTFS_ISO9660_BOOTLOADER_OPTS_EFI = \
> +	--efi-boot $(ROOTFS_ISO9660_EFI_PARTITION) \
> +	-no-emul-boot
> +
> +ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER)$(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),yy)
> +ROOTFS_ISO9660_BOOTLOADER_OPTS = $(ROOTFS_ISO9660_BOOTLOADER_OPTS_BIOS)
> +ROOTFS_ISO9660_BOOTLOADER_OPTS += -eltorito-alt-boot
> +ROOTFS_ISO9660_BOOTLOADER_OPTS += $(ROOTFS_ISO9660_BOOTLOADER_OPTS_EFI)
> +else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER),y)
> +ROOTFS_ISO9660_BOOTLOADER_OPTS = $(ROOTFS_ISO9660_BOOTLOADER_OPTS_BIOS)
> +else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),y)
> +ROOTFS_ISO9660_BOOTLOADER_OPTS = $(ROOTFS_ISO9660_BOOTLOADER_OPTS_EFI)
>  endif
>  
>  define ROOTFS_ISO9660_CMD
>  	$(HOST_DIR)/bin/xorriso -as mkisofs \
>  		$(ROOTFS_ISO9660_OPTS) \
> +		$(ROOTFS_ISO9660_BOOTLOADER_OPTS) \
>  		-o $@ $(ROOTFS_ISO9660_TMP_TARGET_DIR)
>  endef
>  
> -- 
> 2.25.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@lists.buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
Köry Maincent Sept. 30, 2021, 9:12 a.m. UTC | #3
Hello Yann,

Thanks for the merge.

On Wed, 29 Sep 2021 23:26:14 +0200
"Yann E. MORIN" <yann.morin.1998@free.fr> wrote:

> Köry, All,
> 
> On 2021-09-23 17:57 +0200, Kory Maincent spake thusly:
> > Add support for building an hybrid ISO9660 image compatible with legacy
> > and UEFI BIOS.
> > The option -eltorito-alt-boot need to be used in the xorriso command
> > to generate the hybrid image.
> > 
> > Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>  
> 
> Applied to master, thanks, with the folowing changes;
> 
>   - note about hybrid vs. (iso)hybrid
>   - explain -eltorito-alt-boot
>   - explain duplication of -no-emul-boot
>   - rename the variables
>   - note about the BIOS-EFI ordering
> 
> Since I had done a few changes in the previous patches, of course I had
> to resolve the conflicts when applying this patch... I've tried to be as
> carefull as I could, but I may have (again!) let some issues slip
> theough...
> 
> Could you please review/test that it is till works as expected?

I do not see any issue in your change, the bench of tests (last patch) ends
well.

> 
> I don't think the remaining patches need rebasing, though, so I hope I
> can handle more than one next evening... :-/

They indeed don't need rebasing.

Regards,
diff mbox series

Patch

diff --git a/fs/iso9660/Config.in b/fs/iso9660/Config.in
index f8f577506d..8c4e7badf8 100644
--- a/fs/iso9660/Config.in
+++ b/fs/iso9660/Config.in
@@ -27,6 +27,10 @@  choice
 config BR2_TARGET_ROOTFS_ISO9660_GRUB2
 	bool "grub2"
 	depends on BR2_TARGET_GRUB2
+	select BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER \
+		if BR2_TARGET_GRUB2_I386_PC
+	select BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER \
+		if (BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI)
 	help
 	  Use Grub 2 as the bootloader for the ISO9660 image. Make
 	  sure to enable the 'iso9660' module in
@@ -39,21 +43,15 @@  config BR2_TARGET_ROOTFS_ISO9660_GRUB2
 config BR2_TARGET_ROOTFS_ISO9660_ISOLINUX
 	bool "isolinux"
 	depends on BR2_TARGET_SYSLINUX_ISOLINUX
+	select BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER
 
 endchoice
 
-choice
-	prompt "Boot payload"
-
 config BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER
-	bool "legacy bios"
-	depends on BR2_TARGET_GRUB2_I386_PC || BR2_TARGET_ROOTFS_ISO9660_ISOLINUX
+	bool
 
 config BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER
-	bool "UEFI"
-	depends on BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI
-
-endchoice
+	bool
 
 config BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU
 	string "Boot menu config file"
diff --git a/fs/iso9660/iso9660.mk b/fs/iso9660/iso9660.mk
index 921efa1b02..9c2535d102 100644
--- a/fs/iso9660/iso9660.mk
+++ b/fs/iso9660/iso9660.mk
@@ -67,18 +67,20 @@  ROOTFS_ISO9660_DEPENDENCIES += grub2
 ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \
 	$(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub.cfg
 ROOTFS_ISO9660_BOOT_IMAGE = boot/grub/grub-eltorito.img
-define ROOTFS_ISO9660_INSTALL_BOOTLOADER
+define ROOTFS_ISO9660_INSTALL_BOOTLOADER_BIOS
 	$(INSTALL) -D -m 0644 $(BINARIES_DIR)/grub-eltorito.img \
 		$(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub-eltorito.img
 endef
-else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2)$(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),yy)
+endif
+
+ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2)$(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),yy)
 ROOTFS_ISO9660_DEPENDENCIES += grub2 host-dosfstools host-mtools
 ROOTFS_ISO9660_EFI_PARTITION = boot/fat.efi
 ROOTFS_ISO9660_EFI_PARTITION_PATH = $(ROOTFS_ISO9660_TMP_TARGET_DIR)/$(ROOTFS_ISO9660_EFI_PARTITION)
 ROOTFS_ISO9660_EFI_PARTITION_CONTENT = $(BINARIES_DIR)/efi-part
 ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \
 	$(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub.cfg
-define ROOTFS_ISO9660_INSTALL_BOOTLOADER
+define ROOTFS_ISO9660_INSTALL_BOOTLOADER_EFI
 	rm -rf $(ROOTFS_ISO9660_EFI_PARTITION_PATH)
 	mkdir -p $(dir $(ROOTFS_ISO9660_EFI_PARTITION_PATH))
 	dd if=/dev/zero of=$(ROOTFS_ISO9660_EFI_PARTITION_PATH) bs=1M count=1
@@ -87,12 +89,14 @@  define ROOTFS_ISO9660_INSTALL_BOOTLOADER
 	$(HOST_DIR)/bin/mcopy -p -m -i $(ROOTFS_ISO9660_EFI_PARTITION_PATH) -s \
 		$(ROOTFS_ISO9660_EFI_PARTITION_CONTENT)/* ::/
 endef
-else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_ISOLINUX),y)
+endif
+
+ifeq ($(BR2_TARGET_ROOTFS_ISO9660_ISOLINUX),y)
 ROOTFS_ISO9660_DEPENDENCIES += syslinux
 ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \
 	$(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/isolinux.cfg
 ROOTFS_ISO9660_BOOT_IMAGE = isolinux/isolinux.bin
-define ROOTFS_ISO9660_INSTALL_BOOTLOADER
+define ROOTFS_ISO9660_INSTALL_BOOTLOADER_BIOS
 	$(INSTALL) -D -m 0644 $(BINARIES_DIR)/syslinux/* \
 		$(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/
 	$(INSTALL) -D -m 0644 $(HOST_DIR)/share/syslinux/ldlinux.c32 \
@@ -105,7 +109,8 @@  define ROOTFS_ISO9660_PREPARATION
 		$(ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH)
 	$(SED) "s%__KERNEL_PATH__%/boot/$(LINUX_IMAGE_NAME)%" \
 		$(ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH)
-	$(ROOTFS_ISO9660_INSTALL_BOOTLOADER)
+	$(ROOTFS_ISO9660_INSTALL_BOOTLOADER_BIOS)
+	$(ROOTFS_ISO9660_INSTALL_BOOTLOADER_EFI)
 endef
 
 ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_PREPARATION
@@ -151,24 +156,32 @@  endif # ROOTFS_ISO9660_USE_INITRD
 
 ROOTFS_ISO9660_OPTS += \
 	-J \
-	-R \
-	-no-emul-boot
+	-R
 
-ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER),y)
-ROOTFS_ISO9660_OPTS += \
+ROOTFS_ISO9660_BOOTLOADER_OPTS_BIOS = \
+	-b $(ROOTFS_ISO9660_BOOT_IMAGE) \
+	-no-emul-boot \
 	-boot-load-size 4 \
-	-boot-info-table \
-	-b $(ROOTFS_ISO9660_BOOT_IMAGE)
-endif
+	-boot-info-table
 
-ifeq ($(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),y)
-ROOTFS_ISO9660_OPTS += \
-	--efi-boot $(ROOTFS_ISO9660_EFI_PARTITION)
+ROOTFS_ISO9660_BOOTLOADER_OPTS_EFI = \
+	--efi-boot $(ROOTFS_ISO9660_EFI_PARTITION) \
+	-no-emul-boot
+
+ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER)$(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),yy)
+ROOTFS_ISO9660_BOOTLOADER_OPTS = $(ROOTFS_ISO9660_BOOTLOADER_OPTS_BIOS)
+ROOTFS_ISO9660_BOOTLOADER_OPTS += -eltorito-alt-boot
+ROOTFS_ISO9660_BOOTLOADER_OPTS += $(ROOTFS_ISO9660_BOOTLOADER_OPTS_EFI)
+else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER),y)
+ROOTFS_ISO9660_BOOTLOADER_OPTS = $(ROOTFS_ISO9660_BOOTLOADER_OPTS_BIOS)
+else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),y)
+ROOTFS_ISO9660_BOOTLOADER_OPTS = $(ROOTFS_ISO9660_BOOTLOADER_OPTS_EFI)
 endif
 
 define ROOTFS_ISO9660_CMD
 	$(HOST_DIR)/bin/xorriso -as mkisofs \
 		$(ROOTFS_ISO9660_OPTS) \
+		$(ROOTFS_ISO9660_BOOTLOADER_OPTS) \
 		-o $@ $(ROOTFS_ISO9660_TMP_TARGET_DIR)
 endef