From f2aa989c8d279d4123baba83ce793b2b2a78c749 Mon Sep 17 00:00:00 2001 From: Marcelo Politzer Couto Date: Tue, 28 Sep 2021 07:04:06 -0300 Subject: [PATCH] (+) removed drive label dependency + grub update. --- boot/grub/grub.cfg | 35 +++++---- boot/grub/script/autoiso.cfg | 137 +++++++++++++++++++---------------- grub | 2 +- readme.md | 72 +++++++++++------- 4 files changed, 138 insertions(+), 108 deletions(-) diff --git a/boot/grub/grub.cfg b/boot/grub/grub.cfg index 0cba659..2abc066 100755 --- a/boot/grub/grub.cfg +++ b/boot/grub/grub.cfg @@ -1,18 +1,21 @@ -source /boot/grub/script/autoiso.cfg - if loadfont unicode ; then - insmod gfxmenu - insmod gfxterm - insmod jpeg - insmod png - insmod vbe - insmod vga - set gfxmode=1920x1080,auto - set gfxpayload=text - set theme=/boot/grub/themes/starfield/theme.txt - #set theme=/boot/grub/themes/vimix/theme.txt - #set theme=/boot/grub/themes/tela/theme.txt - terminal_output gfxterm - export theme + insmod gfxmenu + insmod gfxterm + insmod jpeg + insmod png + insmod vbe + insmod vga + set gfxmode=1920x1080,auto + set gfxpayload=text + #set theme=/boot/grub/themes/starfield/theme.txt + set theme=/boot/grub/themes/vimix/theme.txt + #set theme=/boot/grub/themes/tela/theme.txt + terminal_output gfxterm + export theme fi -scan_isos /boot/iso GIM + +menuentry "Scan ISOs" "${prefix}/script/autoiso.cfg" { + set iso_dirs="/boot/iso" + export iso_dirs + configfile "$2" +} diff --git a/boot/grub/script/autoiso.cfg b/boot/grub/script/autoiso.cfg index b933c03..ea9bd29 100755 --- a/boot/grub/script/autoiso.cfg +++ b/boot/grub/script/autoiso.cfg @@ -1,6 +1,4 @@ -# Sample GRUB script to autodetect operating systems -# -# Copyright (C) 2017 Marcelo Politzer Couto +# Copyright (C) 2021 Marcelo Politzer Couto # Copyright (C) 2010 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify @@ -16,118 +14,126 @@ # You should have received a copy of the GNU General Public License # along with GRUB. If not, see . -function pathname { regexp -s 2:"$2" '^(\(.*\))?(/.*)$' "$1"; } +function pathname { regexp -s 2:"$2" '^(\(.*\))/*(/.*)$' "$1"; } function devname { regexp -s "$2" '^(\(.*\)).*$' "$1"; } function isolinux_iso_entry { - dev="$1" - iso="$2" - label="$3" - + realdev="$1" + isopath="$2" + loopdev="$3" if test -f /boot/isolinux/isolinux.cfg; then - cfg=/boot/isolinux/isolinux.cfg + cfgpath=/boot/isolinux/isolinux.cfg elif test -f /syslinux/syslinux.cfg; then - cfg=/syslinux/syslinux.cfg + cfgpath=/syslinux/syslinux.cfg elif test -f /isolinux/isolinux.cfg; then - cfg=/isolinux/isolinux.cfg + cfgpath=/isolinux/isolinux.cfg elif test -f /boot/x86_64/loader/isolinux.cfg; then - cfg=/boot/x86_64/loader/isolinux.cfg + cfgpath=/boot/x86_64/loader/isolinux.cfg else return 1; fi - echo isolinux based $iso: yes - menuentry "$iso (isolinux)" "$dev" "$iso" "$cfg" "$label" { - set dev="$2" - set iso="$3" - set cfg="$4" - set label="$5" + echo isolinux based $isopath: yes + probe -s label -l $realdev + menuentry "${indent}${isopath} (isolinux)" "$realdev" "$isopath" "$cfgpath" { + set device="$2" + set isopath="$3" + set cfgpath="$4" - loopback loop "${dev}${iso}" + probe -s rootuuid -u $device + loopback loop "${device}${isopath}" set root=(loop) + # this flag requires a hacked grub!! + + # language settings + set linux_extra="$langset" + # arch based - set linux_extra="${linux_extra} img_dev="/dev/disk/by-label/$label" img_loop=$iso earlymodules=loop" + set linux_extra="${linux_extra} img_dev=/dev/disk/by-uuid/$rootuuid img_loop=$isopath earlymodules=loop" + + # gentoo based + set linux_extra="${linux_extra} isofrom=$isopath" + + # ubuntu based, fedora, opensuse, rosa + set linux_extra="${linux_extra} iso-scan/filename=$isopath" + + # antiX based + set linux_extra="${linux_extra} from=all fromiso=$isopath" + + # Grml Live Linux + set linux_extra="${linux_extra} findiso=$isopath" + + # sysrcd + set linux_extra="${linux_extra} isoloop=$isopath" + + # MagOS Linux (UIRD) + set linux_extra="${linux_extra} uird.from=${isopath},/MagOS uird.force scantimeout=3" + + # TODO: SUSE based + set linux_extra="${linux_extra} isofrom_device=/dev/disk/by-uuid/$rootuuid isofrom_system=$isopath" + + # others? + set linux_extra="${linux_extra} isoboot=$isopath" export linux_extra - syslinux_configfile $cfg + syslinux_configfile $cfgpath } return 0 } -# iso_path is used by the loopback target, do not change! function loopback_iso_entry { realdev="$1" isopath="$2" + loopdev="$3" if test -f /boot/grub/loopback.cfg; then cfgpath=/boot/grub/loopback.cfg elif test -f /grub/loopback.cfg; then cfgpath=/grub/loopback.cfg else - return 1; + return 1 fi echo loopback.cfg $isopath: yes - menuentry "${isopath} (loopback)" "$realdev" "$isopath" "$cfgpath" { + probe -s label -l $realdev + menuentry "${indent}${isopath} (loopback)" "$realdev" "$isopath" "$cfgpath" { set device="$2" - set iso_path="$3" - set cfg="$4" + set isopath="$3" + set cfgpath="$4" - export iso_path - loopback loop "${device}${iso_path}" + loopback loop "${device}${isopath}" set root=(loop) - configfile $cfg - loopback -d loop - } - return 0 -} -function bsdfamily_iso_entry { - realdev="$1" - isopath="$2" + probe -s rootuuid -u $device + set isopath="$isopath $langset" + export isopath - if test -f /FreeNAS-MANIFEST; then kpath=/boot/kernel/kernel; # FreeNAS - elif test -f /boot/zfsloader; then kpath=/boot/kernel/kernel; # FreeBSD - else return 1; fi - - echo bsd-family.cfg $isopath: yes - menuentry "${isopath} (BSD family)" "$realdev" "$isopath" { - set device="$2" - set iso="$3" - - export iso - loopback loop "${device}${iso}" - set root=(loop) - - echo "This may take a while..." - kfreebsd /boot/kernel/kernel - kfreebsd_module "${device}${iso}" type=mfs_root - set kFreeBSD.vfs.root.mountfrom=cd9660:/dev/md0 + configfile $cfgpath + loopback -d loop } return 0 } function scan_isos { isodirs="$1" - label="$2" + echo "scanning ..." for dev in (*); do for dir in $isodirs; do for file in ${dev}${dir}/*.iso ${dev}${dir}/*.ISO; do if ! test -f "$file"; then continue; fi pathname $file isopath - if test -z "$dev" -o -z "$isopath"; then continue; fi if ! loopback loopdev_scan "$file"; then continue; fi saved_root=$root set root=(loopdev_scan) - if loopback_iso_entry $dev $isopath; then true; - elif isolinux_iso_entry $dev $isopath "$label"; then true; - elif bsdfamily_iso_entry $dev $isopath; then true; + if false; then true; + elif loopback_iso_entry $dev $isopath (loopdev_scan); then true; + elif isolinux_iso_entry $dev $isopath (loopdev_scan); then true; else true; fi set root=$saved_root @@ -138,12 +144,15 @@ function scan_isos { return 0 } -# XXX Remove later -insmod serial -serial -terminal_output --append serial -# terminal_input --append serial +insmod part_gpt +insmod part_msdos +insmod regexp langcode="$lang" -insmod regexp +regexp -s langcode '(^..)' "$lang" +langset="lang=${lang} debian-installer/language=${langcode} keyboard-configuration/layoutcode?=${langcode}" +indent=" " #indent for menu entries + +scan_isos "$iso_dirs" +newdir_scan_entry diff --git a/grub b/grub index 3ffd708..710cb5d 160000 --- a/grub +++ b/grub @@ -1 +1 @@ -Subproject commit 3ffd708dd56aebb937b8f09203f9fde8b6fc30c3 +Subproject commit 710cb5da349d9f03f966b19ec4087912f038fbde diff --git a/readme.md b/readme.md index 94833c5..fa8a131 100644 --- a/readme.md +++ b/readme.md @@ -8,12 +8,14 @@ ![preview with vimix](doc/vimix.png?raw=true "vimix") ![preview with starfield](doc/starfield.png?raw=true "starfield") -If your pendrive is already formated to FAT, you only need to change its label -to GIM and then skip step `1`. To use different name changes to the scripts are -required, more on this later (step `3`). +If your pendrive is already formated to FAT skip to `2` ## 1. Installation Guide (clean disk) +``` +export LABEL= +``` + ### 1.1 Create a partition table: ``` # fdisk /dev/sdX @@ -29,7 +31,7 @@ w # write ### 1.2 Format to FAT ``` -# mkfs.fat -n GIM /dev/sdX1 +# mkfs.fat -n $LABEL /dev/sdX1 ``` ## Or with `gparted` @@ -40,34 +42,46 @@ gparted /dev/sdX # Partition -> New -> (configure options) -> Add Create as: Primary Partition File System: fat32 - Label: GIM + Label: $LABEL # Apply all operations # Select partition /dev/sdX1 -> Left click -> Manage Flags -> Enable boot flag ``` ## 2. Installation Guide (formated disk) + +### 2.1a mount ``` -mkdir -p /tmp/GIM -mount /dev/disk/by-label/GIM /tmp/GIM -grub-install --boot-directory=/tmp/GIM/boot /dev/sdX -tar xvf grub-iso-multiboot.tar.gz -C /tmp/GIM -umount /tmp/GIM +mkdir -p /tmp/$LABEL +sudo mount /dev/disk/by-label/$LABEL /tmp/$LABEL ``` -## 3. Adjusts +### 2.1b mount (as a regular user) +``` +pmount /dev/disk/by-label/$LABEL +# adapt destination to the created folder in /media for the following commands +# mount point will look something like this: /media/disk_by-label_$LABEL +``` -### 3.1 I don't want to change the label +### 2.2 install grub & copy release files +``` +grub-install --boot-directory=/tmp/$LABEL/boot /dev/sdX +tar xvf grub-iso-multiboot.tar.gz -C /tmp/$LABEL +``` -If you didn't change your label to `GIM` you will need to change -`/tmp/GIM/boot/grub/grub.cfg` last line: +### 2.3a unmount +``` +umount /tmp/$LABEL +``` -```diff --scan_isos /boot/iso GIM -+scan_isos /boot/iso