Skip to content

Instantly share code, notes, and snippets.

@jamiekurtz
Last active September 3, 2024 15:38
Show Gist options
  • Save jamiekurtz/26c46b3e594f8cdd453a to your computer and use it in GitHub Desktop.
Save jamiekurtz/26c46b3e594f8cdd453a to your computer and use it in GitHub Desktop.
Grub config for creating my own bootable USB stick
# This grub.cfg file was created by Jamie Kurtz
# Detailed instructions for use will soon be found here: http://www.jamiekurtz.com
# Simplified instructions below
# Sample grub entries... https://wiki.archlinux.org/index.php/Multiboot_USB_drive
# Inspiration from here: http://www.pendrivelinux.com/boot-multiple-iso-from-usb-via-grub2-using-linux/
# Simplified instructions...
# Make sure grub, grub-efi, and xorriso packages are installed and up-to-date
# In your terminal go to directory where want to create the USB image contents
# Run the following to create the necessary folder structure:
# $ mkdir -p multiboot/boot/{grub,iso}
# Copy ISOs into the new iso folder
# Create grub.cfg in the boot/grub folder... for example:
# $ wget https://gist.githubusercontent.com/jamiekurtz/26c46b3e594f8cdd453a/raw/grub.cfg -o multiboot/boot/grub/grub.cfg
# Create the ISO image
# (Debian/Ubuntu) $ grub-mkrescue -o multiboot.iso multiboot
# (Fedora) $ grub2-mkrescue -o multiboot.iso multiboot
# At this point you can use VirtualBox to boot a new virtual machine using that multiboot.iso file; this is great for testing your multiboot image
# You now have two different choices for creating the USB stick itself...
# ...
# One, you can write the ISO file to a FAT32 formatted USB stick (after unmounting a USB stick that was recently inserted into the computer)
# This will completely wipe existing content on the USB stick!!
# BE SURE TO USE CORRECT DEVICE PATH BELOW!!! Your USB stick might not be /dev/sdc1 !!
# $ sudo umount /dev/sdc1
# $ sudo dd if=multiboot.iso of=/dev/sdc # (this will take a while!)
# ...
# Or, two, if you don't want to completely wipe out your USB stick, you can do the following:
# Copy the contents of the multiboot folder (created above) to a USB stick
# Then run grub-install against the USB stick to install the grub bootloader - which will use the ISO files and grub.cfg file we just copied:
# BE SURE TO USE CORRECT DEVICE PATH BELOW!!! Your USB stick might not be /dev/sdc1 !!
# $ sudo umount /dev/sdc1
# $ mkdir -p /home/$USER/mnt/usb
# $ sudo mount /dev/sdc2 /home/$USER/mnt/usb
# $ sudo cp -r multiboot/boot /home/$USER/mnt/usb
# $ (Fedora) sudo mv /home/$USER/mnt/usb/boot/grub /home/$USER/mnt/usb/boot/grub2
# $ sudo grub-install --target=i386-pc --boot-directory=/home/$USER/mnt/usb/boot /dev/sdc
# (that would be grub2-install on Fedora)
# ...
# Once the bootable USB stick is created, you can easily add/remove ISOs and simply update the grub.cfg file (i.e. no need to do this all over again)
# Help with formatting USB stick:
# $ sudo parted /dev/sdc rm 1
# $ sudo parted /dev/sdc mklabel msdos
# $ sudo parted /dev/sdc mkpart primary 0% 100%
# $ sudo mkfs.vfat -F 32 -n MULTIBOOT /dev/sdc1
set timeout=20
set default=0
menuentry 'kali-linux-1.1.0-amd64' {
set isofile='/boot/iso/kali-linux-1.1.0a-amd64.iso'
loopback loop $isofile
linux (loop)/live/vmlinuz boot=live findiso=$isofile noconfig=sudo username=root hostname=kali
initrd (loop)/live/initrd.img
}
menuentry 'ubuntu-14.04.2-desktop-amd64' {
set isofile='/boot/iso/ubuntu-14.04.2-desktop-amd64.iso'
loopback loop $isofile
linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile locale=en_US.UTF-8
initrd (loop)/casper/initrd.lz
}
menuentry 'ubuntu-15.04-desktop-amd64' {
set isofile='/boot/iso/ubuntu-15.04-desktop-amd64.iso'
loopback loop $isofile
linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile locale=en_US.UTF-8
initrd (loop)/casper/initrd.lz
}
menuentry 'Fedora-Live-Workstation-x86_64-21-5' {
set isofile='/boot/iso/Fedora-Live-Workstation-x86_64-21-5.iso'
loopback loop $isofile
linux (loop)/isolinux/vmlinuz0 root=live:CDLABEL=Fedora-Live-WS-x86_64-21-5 iso-scan/filename=$isofile rd.live.image
initrd (loop)/isolinux/initrd0.img
}
menuentry 'debian-live-8.0.0-amd64-cinnamon-desktop' {
set isofile='/boot/iso/debian-live-8.0.0-amd64-cinnamon-desktop.iso'
loopback loop $isofile
linux (loop)/live/vmlinuz boot=live config findiso=$isofile
initrd (loop)/live/initrd.img
}
menuentry "Try elementary OS without installing" {
set isofile='/boot/iso/elementaryos-freya-amd64.20150411.iso'
loopback loop $isofile
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet splash --
initrd (loop)/casper/initrd.lz
}
menuentry "linuxmint-17.1-xfce-64bit" {
set isofile='/boot/iso/linuxmint-17.1-xfce-64bit.iso'
loopback loop $isofile
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile live-config quiet splash noeject noprompt
initrd (loop)/casper/initrd.lz
}
menuentry "gparted-live-0.22.0-1-i586" {
set isofile="/boot/iso/gparted-live-0.22.0-1-i586.iso"
loopback loop $isofile
linux (loop)/live/vmlinuz boot=live username=user config components quiet noswap noeject findiso=$isofile toram=filesystem.squashfs nosplash
initrd (loop)/live/initrd.img
}
@Pysis868
Copy link

Pysis868 commented Aug 3, 2015

Jackpot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment