Skip to content

Instantly share code, notes, and snippets.

@debugloop
Last active August 29, 2015 14:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save debugloop/c84542507e1156565a21 to your computer and use it in GitHub Desktop.
Save debugloop/c84542507e1156565a21 to your computer and use it in GitHub Desktop.
Howto make a USB Key bootable, with multiple images and with no fancy tools
  1. Format the stick with FAT32, mount and go to the mountpoint (./ refers to your mountpoint)
  2. Create your grub.cfg (example below) in ./boot/grub/grub.cfg
  3. sudo grub-install --no-floppy --boot-directory=./boot /dev/sdx (use the right device, duh)
  4. Test it with sudo qemu-system-x86_64 -m 512 /dev/sdx

This will show you your menu, but obviously nothing will boot. Create ./iso (or whatever you called it in your grub.cfg) and dump some images into it. The exact versions will not matter (get the paths right), but the distribution most probably will. The grub.cfg below includes the kernel lines GRUB needs to boot Debian, Ubuntu or Archlinux Installers as well as the GRML Live System from http://grml.org/. These are the ones I need, if you want some more/others try the comments below this gist or have fun picking together working GRUB kernel line magic :)

PS: Beware a long-standing bug in the Debian-Installer which causes the bootloader to be written to /dev/sda, which is most likely your shiny bootable device which will need to be fixed thereafter (just do the grub-install ... from above again). The new installation can be saved by going to another virtual terminal, running chroot /target /bin/bash and doing a grub-install /dev/sd[b-z] (again, the right device please) followed by a update-grub before the installer decides on rebooting.

set timeout=30
set default=0
set menu_color_normal=white/black
export menu_color_normal
set menu_color_highlight=white/light-green
export menu_color_highlight
menuentry "Boot from HDD" {
set root=(hd1)
chainloader +1
}
menuentry "GRML 2014.03" {
iso_path="/iso/grml96-full_2014.03.iso"
export iso_path
loopback loop $iso_path
search --set=root --file $iso --no-floppy --fs-uuid
set root=(loop)
configfile /boot/grub/loopback.cfg
}
submenu "Installers ->" {
menuentry "ArchLinux" {
set iso_path="/iso/archlinux-2014.07.03-dual.iso"
loopback loop $iso_path
linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201407 img_label=the_actual_label_of_your_fat32 img_loop=$iso_path
initrd (loop)/arch/boot/x86_64/archiso.img
}
menuentry "Debian Wheezy Installer (amd64)" {
set iso_path="/iso/debian-wheezy-amd64-mini.iso"
loopback loop $iso_path
linux (loop)/linux
initrd (loop)/initrd.gz
}
menuentry "Ubuntu 14.04 LTS Installer (amd64)" {
set iso_path="/iso/ubuntu-14.04-amd64-mini.iso"
loopback loop $iso_path
linux (loop)/linux boot=casper iso-scan/filename=$iso noprompt noeject
initrd (loop)/initrd.gz
}
}
menuentry "Poweroff" {
halt
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment