This page was created after digging for information in order to boot multiple linux distros from downloaded isos on a local machine and USBs. The information provided should demystify the process of modifying GRUB.
https://opensource.com/article/17/2/linux-boot-and-startup
Load the linux kernel:
-
Find the "vmlinuz" file (most likely in: )
- /live/vmlinuz (Tails, Linux Mint, Kali)
- /casper/vmlinuz (Ubuntu, Peppermint)
- /isolinux/vmlinuz (REHL)
- /boot/vmlinuz-x86_64 (Manjaro)
-
Load kernel:
linux [vmlinuz file location] [kernel boot options]
Example: (Ubuntu)
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=${isofile} quiet splash
-
Find "initrd" file (most likely in: )
- /casper/initrd* (Ubuntu)
- /live/initrd.img-*-amd64 (Kali, Manjaro)
- /isolinux/vmlinuz (Fedora)
-
Execute initrd command:
initrd +[vmlinuz file location]
-
Execute
boot
command
Check file locations for mainstream distros in: https://github.com/thias/glim/tree/master/grub2
Source:
https://www.gnu.org/software/grub/manual/grub/grub.html#GNU_002fLinux
What is grub.cfg file? Contains "menuentrys" which act as mini scripts similar to .sh files but for grub.
List of valid commands in GRUB: https://www.gnu.org/software/grub/manual/grub/grub.html#Command_002dline-and-menu-entry-commands
Example of Ubuntu's autogenerated menuentry after flashing drive:
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-9a6801b1-a23c-43d9-8162-563760407db3' {
recordfail
savedefault
load_video
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_gpt
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 9a6801b1-a23c-43d9-8162-563760407db3
else
search --no-floppy --fs-uuid --set=root 9a6801b1-a23c-43d9-8162-563760407db3
fi
linux /boot/vmlinuz-5.10.0-051000-generic root=UUID=9a6801b1-a23c-43d9-8162-563760407db3 ro quiet splash $vt_handoff
initrd /boot/initrd.img-5.10.0-051000-generic
}
Find current linux boot params when booted:
cat /proc/cmdline
https://www.cyberciti.biz/faq/display-view-linux-kernel-parameters-for-booted/
-
modify:
- /boot/grub/grub.cfg (main)
or - /etc/grub.d/40_custom (designed for user-added custom boot entries. Combined into grub.cfg after
update-grub
)
- /boot/grub/grub.cfg (main)
-
sudo update-grub
What boot options/parameters should I use?
You can view the defualt options used after iso burn/flash by viewing either grub.cfg or syslinux.cfg files depending on your config. Use 7zip to find file without extracting iso as I have found this may hide/delete file. Some distros seem to use boot options that are not included in linux master boot options list and no documentation to be found which is why looking at these files may be helpfull.
Example:
(Ubuntu 20.04)
Location: (ubuntu-20.04.1-desktop-amd648-21-2020.iso\boot\grub\grub.cfg)
Boot Options: (located after linux vmlinuz ):
file=/cdrom/preseed/ubuntu.seed maybe-ubiquity quiet splash ---
Example:
(Tails)
Location: (tails-amd64-4.3.iso\EFI\BOOT\syslinux.cfg --> live64.cfg)
Boot Options: (located after linux vmlinuz ):
initrd=/live/initrd.img boot=live config live-media=removable nopersistence noprompt timezone=Etc/UTC block.events_dfl_poll_msecs=1000 splash noautologin module=Tails slab_nomerge slub_debug=FZP mce=0 vsyscall=none page_poison=1 init_on_alloc=1 init_on_free=1 mds=full,nosmt union=aufs quiet
Example:
(Debian)
Location: (debian-10.5.0-amd64-xfce-8-20-2020.iso\boot\grub\grub.cfg)
Boot Options: (located after linux vmlinuz ):
/install.amd/vmlinuz desktop=xfce vga=788 --- quiet (Graphical Install)
Summary:
To create your grub file copy and modify information in grub.cfg/syslinux.cfg and GLIM github repository: https://github.com/thias/glim.
Extensive list of linux kernel boot params:
https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html
More sources for kernel boot params:
Ubuntu wiki:
https://manpages.ubuntu.com/manpages/groovy/en/man7/bootparam.7.html
https://wiki.ubuntu.com/Kernel/KernelBootParameters
Archwiki:
https://wiki.archlinux.org/index.php/Kernel_module#Using_files_in_/etc/modprobe.d/
Default boot options: syslinux.cfg
if 64 bit system:
Options listed in live64.cfg
if 32 bit system:
Display:
We are sorry!
Tails can not work on this computer:
Tails now requires a 64-bit computer.
Boot options from syslinux.cfg:
initrd=/live/initrd.img boot=live config live-media=removable nopersistence noprompt timezone=Etc/UTC block.events_dfl_poll_msecs=1000 splash noautologin module=Tails slab_nomerge slub_debug=FZP mce=0 vsyscall=none page_poison=1 init_on_alloc=1 init_on_free=1 mds=full,nosmt union=aufs noapic noapm nodma nomce nolapic nomodeset nosmp vga=normal
For booting iso from local machine (not flashed USB), use the following boot options: (taken from combination of GLIM and syslinux.cfg)
root=(loop) boot=live findiso=${isofile} config apparmor=1 nopersistence noprompt timezone=Etc/UTC block.events_dfl_poll_msecs=1000 splash noautologin module=Tails slab_nomerge slub_debug=FZP mce=0 vsyscall=none page_poison=1 init_on_alloc=1 init_on_free=1 mds=full,nosmt quiet
Whole menuentry:
menuentry "Tails ISO" --class tails {
set isofile="/images/tails-amd64-4.14.iso"
loopback loop $isofile
linux (loop)/live/vmlinuz root=(loop) boot=live findiso=${isofile} config apparmor=1 nopersistence noprompt timezone=Etc/UTC block.events_dfl_poll_msecs=1000 splash noautologin module=Tails slab_nomerge slub_debug=FZP mce=0 vsyscall=none page_poison=1 init_on_alloc=1 init_on_free=1 mds=full,nosmt quiet
initrd (loop)/live/initrd.img
}
Source:
https://www.howtogeek.com/196933/how-to-boot-linux-iso-images-directly-from-your-hard-drive/
If you want to boot an iso without flashing iage to usb/dvd, use following instructions:
- Download isos (move them to easy-to-find location such as root)
- GRUB:
- Create/Modify "40_custom" file located in: /etc/grub.d/
- Add desired menuentries using above instructions for your distros
- Execute
update-grub
Examples:
menuentry "Ubuntu ISO" --class ubuntu {
set isofile="/images/ubuntu-20.04.2.0-desktop-amd64.iso"
loopback loop $isofile
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=${isofile} quiet splash
initrd (loop)/casper/initrd*
}
menuentry "Tails ISO" --class tails {
set isofile="/images/tails-amd64-4.15.1.iso"
loopback loop $isofile
linux (loop)/live/vmlinuz root=(loop) boot=live findiso=${isofile} config apparmor=1 nopersistence noprompt timezone=Etc/UTC block.events_dfl_poll_msecs=1000 splash noautologin module=Tails slab_nomerge slub_debug=FZP mce=0 vsyscall=none page_poison=1 init_on_alloc=1 init_on_free=1 mds=full,nosmt quiet
initrd (loop)/live/initrd.img
}
menuentry "Kali Live" {
set isofile="/images/kali-linux-2020.4-live-amd64.iso"
loopback loop $isofile
linux (loop)/live/vmlinuz-5.9.0-kali1-amd64 boot=live components quiet splash noeject findiso=${isofile}
initrd (loop)/live/initrd.img-5.9.0-kali1-amd64
}
- Test your configuration
- Ensure you use GPT partition table
- Create ~500MB+ partition formatted in FAT32 for EFI parition (will contain grub's EFI and /boot)
- Create EXT4 partition to store all isos
- mount EFI partition
- execute:
grub-install --efi-directory=(directory of mounted drive) --boot-directory=(directory of mounted drive)/boot --removable
eg.grub-install --efi-directory=/mnt/usb --boot-directory=/mnt/usb/boot --removable
- Open (directory of mounted drive)/EFI/BOOT/grub.cfg
- Add menuentries using instructions above
Ensure "loopback loop" line references your iso using GRUB's drive numbering scheme
eg.loopback loop (hd0,gpt2)/ubuntu.iso
- You may need multiple tries to get everything set up properly and boot iso. If you get to initramfs and error: "unable to find medium containing live filesystem", check your
loopback loop
line. This had me stuck for days due to lack of documentation.