]> code.delx.au - monosys/blobdiff - hacks/multiboot-setup
multiboot: Support booting arch with non-default kernels.
[monosys] / hacks / multiboot-setup
index 93842dbbeeb61cc8bc218b4277096052bd8d71f3..8abc2be26cc0023191a351dd33b2c6ed156cd6ae 100755 (executable)
@@ -3,7 +3,7 @@
 set -eu
 
 PARTITION_LABEL="multiboot"
-MULTIBOOT_MNT="/mnt/multiboot"
+MULTIBOOT_MNT="${MULTIBOOT_MNT:-/mnt/multiboot}"
 
 function cmd_format {
     if [ ! -b "${1:-}" ]; then
@@ -58,7 +58,12 @@ function install_grub_efi {
 }
 
 function install_grub_cfg {
-    print_grub_cfg | sudo tee "${MULTIBOOT_MNT}/grub/grub.cfg" > /dev/null
+    if [[ -w "${MULTIBOOT_MNT}/grub/" ]]; then
+        # We already have write access, no need to use sudo
+        print_grub_cfg > "${MULTIBOOT_MNT}/grub/grub.cfg"
+    else
+        print_grub_cfg | sudo tee "${MULTIBOOT_MNT}/grub/grub.cfg" > /dev/null
+    fi
 }
 
 function cmd_mount {
@@ -107,8 +112,10 @@ search --set=root --label $PARTITION_LABEL
 function setup_arch {
   menuentry "\$1" {
     loopback loop \$1
-    linux (loop)/arch/boot/x86_64/vmlinuz img_label=${PARTITION_LABEL} img_loop=\$1 archisobasedir=arch earlymodules=loop
-    initrd (loop)/arch/boot/x86_64/archiso.img
+    echo "Loading kernel..."
+    linux (loop)/arch/boot/x86_64/vmlinuz-* img_label=${PARTITION_LABEL} img_loop=\$1 archisobasedir=arch earlymodules=loop
+    echo "Loading initrd (and microcode if they exist)..."
+    initrd (loop)/arch/boot/*.img (loop)/arch/boot/x86_64/initramfs-*.img
   }
 }
 for iso in /archlinux-*.iso; do