See
- from Journey towards a maintenance free system multi booting
- to Maintenance free system multi booting
This is the conclusion part and latest code repo.
| # nix | |
| *~ |
| # == fundementals | |
| set menu_color_normal=cyan/blue | |
| set menu_color_highlight=white/blue | |
| set timeout=3 | |
| # == loadfont | |
| font=unicode | |
| set locale_dir=$prefix/locale | |
| set lang=en_US | |
| # -- load_video | |
| insmod gettext | |
| insmod gfxterm | |
| insmod all_video | |
| # load common modules | |
| insmod gzio | |
| insmod part_gpt | |
| insmod ext2 |
| ## grub2 configuration | |
| source /boot/grub/grub-header.cfg | |
| insmod regexp | |
| for config in /boot/grub/*_default.cfg ; do source "$config" ; done | |
| for config in /boot/grub/*_options.cfg ; do source "$config" ; done | |
| if [ -f /boot/grub/grub-addons.cfg ] ; then | |
| source "/boot/grub/grub-addons.cfg" | |
| fi | |
| source /boot/grub/grub-footer.cfg |
| source /boot/grub/grub-main.cfg |
| /^submenu .Advanced options for /,/^}/d | |
| /^menuentry /{ s/^/\n/; s/--\(class\|id\) .*$/{/ } | |
| /load_video\|insmod/d | |
| # remove entire if block | |
| /feature_platform_search_hint/{ N; N; N; N; d; } | |
| s/^\( \|\t\)/ / | |
| sed -En ' | |
| 1{s/^.*$/OS:/; p} | |
| /^submenu .Advanced options for /,/^}/d | |
| # WinOS | |
| /^menuentry .*Windows/{ | |
| s/^menuentry /\n - Name: / | |
| s/ --(class|id) .*$/\n Type: WinOS/ | |
| p | |
| } | |
| # LinOS | |
| /^menuentry /{ | |
| s/^menuentry /\n - Name: / | |
| s/ --(class|id) .*$/\n Type: LinOS/ | |
| p | |
| } | |
| # Root | |
| /set root=/{ | |
| s/^\s*set root=/ Root: / | |
| p | |
| } | |
| ' "$@" |
| set default=0 |
| set iso_root= | |
| export iso_root | |
| source /boot/grub/iso-inc.cfg |
| set iso_root='(hd0,2)' | |
| export iso_root | |
| source /boot/grub/iso-inc.cfg |
| set iso_root='(hd0,3)' | |
| export iso_root | |
| source /boot/grub/iso-inc.cfg |
| submenu "Boot from ISO ... >" { | |
| set menu_color_normal=black/light-gray | |
| set menu_color_highlight=yellow/dark-gray | |
| if [ x$iso_root != x ]; then set root=$iso_root; fi | |
| insmod regexp | |
| for isofile in /iso/*.iso; do | |
| regexp --set=isoname "/iso/(.*)" "$isofile" | |
| #export isoname | |
| bootoptions="noeject noprompt nomce net.ifnames=0" | |
| # more failsafe bootoptions | |
| # memtest noapic noapm nodma nolapic nomodeset nosmp nosplash vga=normal | |
| export bootoptions | |
| submenu "$isoname >" "$isofile" { | |
| set menu_color_normal=black/light-red | |
| set menu_color_highlight=yellow/light-red | |
| iso_path="$2" | |
| loopback loop "$iso_path" | |
| menuentry 'Live (ISO)' { | |
| #echo 'Boot ISO $isoname ...' | |
| echo 'Loading kernel...' | |
| linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$iso_path $bootoptions | |
| echo 'Loading initrd...' | |
| initrd (loop)/casper/initrd | |
| # == debian-live | |
| # linux (loop)/live/vmlinuz boot=live findiso=$iso_path components $bootoptions | |
| # initrd (loop)/live/initrd.img | |
| # == grml | |
| # echo 'Loading kernel...' | |
| # linux /boot/grml64full/vmlinuz apm=power-off boot=live findiso=$iso_path ${kernelopts} live-media-path=/live/grml64-full/ $bootoptions bootid=20bcd9c7-ec57-49c4-9f58-2a90493229af | |
| # echo 'Loading initrd...' | |
| # initrd /boot/grml64full/initrd.img | |
| } | |
| } | |
| done | |
| } |
| menuentry 'Debian GNU/Linux' { | |
| set root='hd0,gpt2' | |
| probe -u $root --set=rootuuid | |
| echo 'Loading Linux ...' | |
| linux /vmlinuz root=UUID=$rootuuid ro text net.ifnames=0 | |
| echo 'Loading initial ramdisk ...' | |
| initrd /initrd.img | |
| } |
| menuentry 'Debian 11 bullseye' { | |
| set root='hd0,gpt2' | |
| probe -u $root --set=rootuuid | |
| echo 'Booting - Debian 11 bullseye' | |
| echo 'Loading Linux Kernel ...' | |
| linux /vmlinuz root=UUID=$rootuuid ro text net.ifnames=0 | |
| echo 'Loading initial ramdisk ...' | |
| initrd /initrd.img | |
| } | |
| os2grub.tmpl |
| OS: | |
| - # Name - Name of the boot entry | |
| Name: Debian 11 bullseye | |
| # Type - Type of the boot entry | |
| # Values can be LinOS, WinOS | |
| Type: LinOS | |
| # Root - Partition to set grub root with | |
| Root: hd0,gpt2 | |
| # Disk - Optional, Disk label of the partition | |
| Disk: |
| menuentry 'Ubuntu 20.04 LTS (20.04) (on /dev/sda3)' { | |
| set root='hd0,gpt3' | |
| probe -u $root --set=rootuuid | |
| echo 'Booting - Ubuntu 20.04 LTS (20.04) (on /dev/sda3)' | |
| echo 'Loading Linux Kernel ...' | |
| linux /boot/vmlinuz root=UUID=$rootuuid ro text net.ifnames=0 zswap.enabled=1 zswap.compressor=lz4 zswap.zpool=z3fold zswap.max_pool_percent=52 | |
| echo 'Loading initial ramdisk ...' | |
| initrd /boot/initrd.img | |
| } | |
| menuentry 'Ubuntu 19.04 (19.04) (on /dev/sda7)' { | |
| set root='hd0,gpt7' | |
| probe -u $root --set=rootuuid | |
| echo 'Booting - Ubuntu 19.04 (19.04) (on /dev/sda7)' | |
| echo 'Loading Linux Kernel ...' | |
| linux /boot/vmlinuz root=UUID=$rootuuid ro text net.ifnames=0 zswap.enabled=1 zswap.compressor=lz4 zswap.zpool=z3fold zswap.max_pool_percent=52 | |
| echo 'Loading initial ramdisk ...' | |
| initrd /boot/initrd.img | |
| } | |
| menuentry 'Ubuntu 18.04 LTS (18.04) (on /dev/sda6)' { | |
| set root='hd0,gpt6' | |
| probe -u $root --set=rootuuid | |
| echo 'Booting - Ubuntu 18.04 LTS (18.04) (on /dev/sda6)' | |
| echo 'Loading Linux Kernel ...' | |
| linux /boot/vmlinuz root=UUID=$rootuuid ro text net.ifnames=0 zswap.enabled=1 zswap.compressor=lz4 zswap.zpool=z3fold zswap.max_pool_percent=52 | |
| echo 'Loading initial ramdisk ...' | |
| initrd /boot/initrd.img | |
| } | |
| menuentry 'Ubuntu 17.04 (17.04) (on /dev/sda8)' { | |
| set root='hd0,gpt8' | |
| probe -u $root --set=rootuuid | |
| echo 'Booting - Ubuntu 17.04 (17.04) (on /dev/sda8)' | |
| echo 'Loading Linux Kernel ...' | |
| linux /boot/vmlinuz root=UUID=$rootuuid ro text net.ifnames=0 zswap.enabled=1 zswap.compressor=lz4 zswap.zpool=z3fold zswap.max_pool_percent=52 | |
| echo 'Loading initial ramdisk ...' | |
| initrd /boot/initrd.img | |
| } | |
| menuentry 'Windows Boot Manager (on /dev/sda13)' { | |
| set root='hd0,gpt13' | |
| echo 'Booting - Windows Boot Manager (on /dev/sda13)' | |
| chainloader /EFI/Microsoft/Boot/bootmgfw.efi | |
| } | |
| {{range .OS}} | |
| {{if eq .Type "LinOS" -}} | |
| menuentry '{{.Name}}' { | |
| set root='{{.Root}}' | |
| probe -u $root --set=rootuuid | |
| echo 'Booting - {{.Name}}' | |
| echo 'Loading Linux Kernel ...' | |
| linux /boot/vmlinuz root=UUID=$rootuuid ro text net.ifnames=0 zswap.enabled=1 zswap.compressor=lz4 zswap.zpool=z3fold zswap.max_pool_percent=52 | |
| echo 'Loading initial ramdisk ...' | |
| initrd /boot/initrd.img | |
| }{{else}}{{if eq .Type "WinOS" -}} | |
| menuentry '{{.Name}}' { | |
| set root='{{.Root}}' | |
| echo 'Booting - {{.Name}}' | |
| chainloader /EFI/Microsoft/Boot/bootmgfw.efi | |
| }{{end}}{{end}} | |
| {{end}} |
| OS: | |
| - Name: 'Ubuntu 20.04 LTS (20.04) (on /dev/sda3)' | |
| Type: LinOS | |
| Root: 'hd0,gpt3' | |
| - Name: 'Ubuntu 19.04 (19.04) (on /dev/sda7)' | |
| Type: LinOS | |
| Root: 'hd0,gpt7' | |
| - Name: 'Ubuntu 18.04 LTS (18.04) (on /dev/sda6)' | |
| Type: LinOS | |
| Root: 'hd0,gpt6' | |
| - Name: 'Ubuntu 17.04 (17.04) (on /dev/sda8)' | |
| Type: LinOS | |
| Root: 'hd0,gpt8' | |
| - Name: 'Windows Boot Manager (on /dev/sda13)' | |
| Type: WinOS | |
| Root: 'hd0,gpt13' |