summaryrefslogtreecommitdiff
path: root/target/linux/x86
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-10-07 23:01:52 +0000
committerFelix Fietkau <nbd@openwrt.org>2012-10-07 23:01:52 +0000
commita1bcd25082fd6780d6eb9184acb1813bf723841f (patch)
tree0b1632d204e304ccf1e2596952e4910f1e5d7865 /target/linux/x86
parent53cc34e517329fbc2ce90a356e2f97f7aa727c69 (diff)
downloadmtk-20170518-a1bcd25082fd6780d6eb9184acb1813bf723841f.zip
mtk-20170518-a1bcd25082fd6780d6eb9184acb1813bf723841f.tar.gz
mtk-20170518-a1bcd25082fd6780d6eb9184acb1813bf723841f.tar.bz2
x86: add grub2 iso support
SVN-Revision: 33639
Diffstat (limited to 'target/linux/x86')
-rw-r--r--target/linux/x86/base-files/lib/preinit/20_check_iso5
-rw-r--r--target/linux/x86/image/Makefile32
-rw-r--r--target/linux/x86/image/grub-iso.cfg10
3 files changed, 44 insertions, 3 deletions
diff --git a/target/linux/x86/base-files/lib/preinit/20_check_iso b/target/linux/x86/base-files/lib/preinit/20_check_iso
new file mode 100644
index 0000000..beff6eb
--- /dev/null
+++ b/target/linux/x86/base-files/lib/preinit/20_check_iso
@@ -0,0 +1,5 @@
+check_for_iso() {
+ grep -qE '/dev/root.*iso9660' /proc/mounts && ramoverlay
+}
+
+boot_hook_add preinit_mount_root check_for_iso
diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile
index 547f083..17e300d 100644
--- a/target/linux/x86/image/Makefile
+++ b/target/linux/x86/image/Makefile
@@ -10,6 +10,7 @@ include $(INCLUDE_DIR)/image.mk
export PATH=$(TARGET_PATH):/sbin
GRUB2_MODULES = at_keyboard biosdisk boot chain configfile ext2 linux ls part_msdos reboot serial vga
+GRUB2_MODULES_ISO = at_keyboard biosdisk boot chain configfile iso9660 linux ls part_msdos reboot serial vga
GRUB_TERMINALS =
GRUB_SERIAL_CONFIG =
GRUB_TERMINAL_CONFIG =
@@ -45,7 +46,7 @@ ifneq ($(CONFIG_X86_GRUB_IMAGES),)
define Image/cmdline/ext4
root=$(ROOTPART) rootfstype=ext4 rootwait
endef
-
+
define Image/cmdline/jffs2-64k
block2mtd.block2mtd=$(ROOTPART),65536,rootfs root=/dev/mtdblock0 rootfstype=jffs2 rootwait
endef
@@ -159,7 +160,31 @@ define Image/Build/squashfs
$(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
endef
-define Image/Build/iso
+ifdef CONFIG_X86_USE_GRUB2
+ define Image/Build/iso
+ $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2
+ $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
+ grub-mkimage \
+ -o $(KDIR)/grub2/eltorito.img \
+ -O i386-pc \
+ -c ./grub-early.cfg \
+ $(GRUB2_MODULES_ISO)
+ cat \
+ $(STAGING_DIR_HOST)/lib/grub/i386-pc/cdboot.img \
+ $(KDIR)/grub2/eltorito.img \
+ > $(KDIR)/root.grub/boot/grub/eltorito.img
+ sed \
+ -e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
+ -e 's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \
+ -e 's#@CMDLINE@#root=/dev/sr0 rootfstype=iso9660 rootwait $(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \
+ -e 's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \
+ ./grub-iso.cfg > $(KDIR)/root.grub/boot/grub/grub.cfg
+ $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
+ mkisofs -R -b boot/grub/eltorito.img -no-emul-boot -boot-info-table \
+ -o $(KDIR)/root.iso $(KDIR)/root.grub $(TARGET_DIR)
+ endef
+else
+ define Image/Build/iso
$(INSTALL_DIR) $(KDIR)/root.grub/boot/grub
$(CP) \
$(KDIR)/stage2_eltorito \
@@ -173,7 +198,8 @@ define Image/Build/iso
$(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table \
-o $(KDIR)/root.iso $(KDIR)/root.grub
-endef
+ endef
+endif
ifneq ($(CONFIG_X86_VDI_IMAGES),)
define Image/Build/vdi
diff --git a/target/linux/x86/image/grub-iso.cfg b/target/linux/x86/image/grub-iso.cfg
new file mode 100644
index 0000000..4d5d697
--- /dev/null
+++ b/target/linux/x86/image/grub-iso.cfg
@@ -0,0 +1,10 @@
+@SERIAL_CONFIG@
+@TERMINAL_CONFIG@
+
+set default="0"
+set timeout="@TIMEOUT@"
+set root='(cd)'
+
+menuentry "OpenWrt" {
+ linux /boot/vmlinuz @CMDLINE@ noinitrd reboot=bios
+}