Skip to content

Commit f2aa989

Browse files
author
Marcelo Politzer Couto
committed
(+) removed drive label dependency + grub update.
1 parent 8351d85 commit f2aa989

File tree

4 files changed

+138
-108
lines changed

4 files changed

+138
-108
lines changed

boot/grub/grub.cfg

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
source /boot/grub/script/autoiso.cfg
2-
31
if loadfont unicode ; then
4-
insmod gfxmenu
5-
insmod gfxterm
6-
insmod jpeg
7-
insmod png
8-
insmod vbe
9-
insmod vga
10-
set gfxmode=1920x1080,auto
11-
set gfxpayload=text
12-
set theme=/boot/grub/themes/starfield/theme.txt
13-
#set theme=/boot/grub/themes/vimix/theme.txt
14-
#set theme=/boot/grub/themes/tela/theme.txt
15-
terminal_output gfxterm
16-
export theme
2+
insmod gfxmenu
3+
insmod gfxterm
4+
insmod jpeg
5+
insmod png
6+
insmod vbe
7+
insmod vga
8+
set gfxmode=1920x1080,auto
9+
set gfxpayload=text
10+
#set theme=/boot/grub/themes/starfield/theme.txt
11+
set theme=/boot/grub/themes/vimix/theme.txt
12+
#set theme=/boot/grub/themes/tela/theme.txt
13+
terminal_output gfxterm
14+
export theme
1715
fi
18-
scan_isos /boot/iso GIM
16+
17+
menuentry "Scan ISOs" "${prefix}/script/autoiso.cfg" {
18+
set iso_dirs="/boot/iso"
19+
export iso_dirs
20+
configfile "$2"
21+
}

boot/grub/script/autoiso.cfg

Lines changed: 73 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# Sample GRUB script to autodetect operating systems
2-
#
3-
# Copyright (C) 2017 Marcelo Politzer Couto
1+
# Copyright (C) 2021 Marcelo Politzer Couto
42
# Copyright (C) 2010 Free Software Foundation, Inc.
53
#
64
# GRUB is free software: you can redistribute it and/or modify
@@ -16,118 +14,126 @@
1614
# You should have received a copy of the GNU General Public License
1715
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
1816

19-
function pathname { regexp -s 2:"$2" '^(\(.*\))?(/.*)$' "$1"; }
17+
function pathname { regexp -s 2:"$2" '^(\(.*\))/*(/.*)$' "$1"; }
2018
function devname { regexp -s "$2" '^(\(.*\)).*$' "$1"; }
2119

2220
function isolinux_iso_entry {
23-
dev="$1"
24-
iso="$2"
25-
label="$3"
26-
21+
realdev="$1"
22+
isopath="$2"
23+
loopdev="$3"
2724

2825
if test -f /boot/isolinux/isolinux.cfg; then
29-
cfg=/boot/isolinux/isolinux.cfg
26+
cfgpath=/boot/isolinux/isolinux.cfg
3027
elif test -f /syslinux/syslinux.cfg; then
31-
cfg=/syslinux/syslinux.cfg
28+
cfgpath=/syslinux/syslinux.cfg
3229
elif test -f /isolinux/isolinux.cfg; then
33-
cfg=/isolinux/isolinux.cfg
30+
cfgpath=/isolinux/isolinux.cfg
3431
elif test -f /boot/x86_64/loader/isolinux.cfg; then
35-
cfg=/boot/x86_64/loader/isolinux.cfg
32+
cfgpath=/boot/x86_64/loader/isolinux.cfg
3633
else
3734
return 1;
3835
fi
3936

40-
echo isolinux based $iso: yes
41-
menuentry "$iso (isolinux)" "$dev" "$iso" "$cfg" "$label" {
42-
set dev="$2"
43-
set iso="$3"
44-
set cfg="$4"
45-
set label="$5"
37+
echo isolinux based $isopath: yes
38+
probe -s label -l $realdev
39+
menuentry "${indent}${isopath} (isolinux)" "$realdev" "$isopath" "$cfgpath" {
40+
set device="$2"
41+
set isopath="$3"
42+
set cfgpath="$4"
4643

47-
loopback loop "${dev}${iso}"
44+
probe -s rootuuid -u $device
45+
loopback loop "${device}${isopath}"
4846
set root=(loop)
4947

48+
# this flag requires a hacked grub!!
49+
50+
# language settings
51+
set linux_extra="$langset"
52+
5053
# arch based
51-
set linux_extra="${linux_extra} img_dev="/dev/disk/by-label/$label" img_loop=$iso earlymodules=loop"
54+
set linux_extra="${linux_extra} img_dev=/dev/disk/by-uuid/$rootuuid img_loop=$isopath earlymodules=loop"
55+
56+
# gentoo based
57+
set linux_extra="${linux_extra} isofrom=$isopath"
58+
59+
# ubuntu based, fedora, opensuse, rosa
60+
set linux_extra="${linux_extra} iso-scan/filename=$isopath"
61+
62+
# antiX based
63+
set linux_extra="${linux_extra} from=all fromiso=$isopath"
64+
65+
# Grml Live Linux
66+
set linux_extra="${linux_extra} findiso=$isopath"
67+
68+
# sysrcd
69+
set linux_extra="${linux_extra} isoloop=$isopath"
70+
71+
# MagOS Linux (UIRD)
72+
set linux_extra="${linux_extra} uird.from=${isopath},/MagOS uird.force scantimeout=3"
73+
74+
# TODO: SUSE based
75+
set linux_extra="${linux_extra} isofrom_device=/dev/disk/by-uuid/$rootuuid isofrom_system=$isopath"
76+
77+
# others?
78+
set linux_extra="${linux_extra} isoboot=$isopath"
5279

5380
export linux_extra
54-
syslinux_configfile $cfg
81+
syslinux_configfile $cfgpath
5582
}
5683
return 0
5784
}
5885

59-
# iso_path is used by the loopback target, do not change!
6086
function loopback_iso_entry {
6187
realdev="$1"
6288
isopath="$2"
89+
loopdev="$3"
6390

6491
if test -f /boot/grub/loopback.cfg; then
6592
cfgpath=/boot/grub/loopback.cfg
6693
elif test -f /grub/loopback.cfg; then
6794
cfgpath=/grub/loopback.cfg
6895
else
69-
return 1;
96+
return 1
7097
fi
7198

7299
echo loopback.cfg $isopath: yes
73-
menuentry "${isopath} (loopback)" "$realdev" "$isopath" "$cfgpath" {
100+
probe -s label -l $realdev
101+
menuentry "${indent}${isopath} (loopback)" "$realdev" "$isopath" "$cfgpath" {
74102
set device="$2"
75-
set iso_path="$3"
76-
set cfg="$4"
103+
set isopath="$3"
104+
set cfgpath="$4"
77105

78-
export iso_path
79-
loopback loop "${device}${iso_path}"
106+
loopback loop "${device}${isopath}"
80107
set root=(loop)
81-
configfile $cfg
82-
loopback -d loop
83-
}
84-
return 0
85-
}
86108

87-
function bsdfamily_iso_entry {
88-
realdev="$1"
89-
isopath="$2"
109+
probe -s rootuuid -u $device
110+
set isopath="$isopath $langset"
111+
export isopath
90112

91-
if test -f /FreeNAS-MANIFEST; then kpath=/boot/kernel/kernel; # FreeNAS
92-
elif test -f /boot/zfsloader; then kpath=/boot/kernel/kernel; # FreeBSD
93-
else return 1; fi
94-
95-
echo bsd-family.cfg $isopath: yes
96-
menuentry "${isopath} (BSD family)" "$realdev" "$isopath" {
97-
set device="$2"
98-
set iso="$3"
99-
100-
export iso
101-
loopback loop "${device}${iso}"
102-
set root=(loop)
103-
104-
echo "This may take a while..."
105-
kfreebsd /boot/kernel/kernel
106-
kfreebsd_module "${device}${iso}" type=mfs_root
107-
set kFreeBSD.vfs.root.mountfrom=cd9660:/dev/md0
113+
configfile $cfgpath
114+
loopback -d loop
108115
}
109116
return 0
110117
}
111118

112119
function scan_isos {
113120
isodirs="$1"
114-
label="$2"
115121

122+
echo "scanning ..."
116123
for dev in (*); do
117124
for dir in $isodirs; do
118125
for file in ${dev}${dir}/*.iso ${dev}${dir}/*.ISO; do
119126
if ! test -f "$file"; then continue; fi
120127

121128
pathname $file isopath
122-
if test -z "$dev" -o -z "$isopath"; then continue; fi
123129

124130
if ! loopback loopdev_scan "$file"; then continue; fi
125131
saved_root=$root
126132
set root=(loopdev_scan)
127133

128-
if loopback_iso_entry $dev $isopath; then true;
129-
elif isolinux_iso_entry $dev $isopath "$label"; then true;
130-
elif bsdfamily_iso_entry $dev $isopath; then true;
134+
if false; then true;
135+
elif loopback_iso_entry $dev $isopath (loopdev_scan); then true;
136+
elif isolinux_iso_entry $dev $isopath (loopdev_scan); then true;
131137
else true; fi
132138

133139
set root=$saved_root
@@ -138,12 +144,15 @@ function scan_isos {
138144
return 0
139145
}
140146

141-
# XXX Remove later
142-
insmod serial
143-
serial
144-
terminal_output --append serial
145-
# terminal_input --append serial
147+
insmod part_gpt
148+
insmod part_msdos
149+
insmod regexp
146150

147151
langcode="$lang"
148152

149-
insmod regexp
153+
regexp -s langcode '(^..)' "$lang"
154+
langset="lang=${lang} debian-installer/language=${langcode} keyboard-configuration/layoutcode?=${langcode}"
155+
indent=" " #indent for menu entries
156+
157+
scan_isos "$iso_dirs"
158+
newdir_scan_entry

grub

Submodule grub updated from 3ffd708 to 710cb5d

readme.md

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
![preview with vimix](doc/vimix.png?raw=true "vimix")
99
![preview with starfield](doc/starfield.png?raw=true "starfield")
1010

11-
If your pendrive is already formated to FAT, you only need to change its label
12-
to GIM and then skip step `1`. To use different name changes to the scripts are
13-
required, more on this later (step `3`).
11+
If your pendrive is already formated to FAT skip to `2`
1412

1513
## 1. Installation Guide (clean disk)
1614

15+
```
16+
export LABEL=<label-of-your-choice>
17+
```
18+
1719
### 1.1 Create a partition table:
1820
```
1921
# fdisk /dev/sdX
@@ -29,7 +31,7 @@ w # write
2931

3032
### 1.2 Format to FAT
3133
```
32-
# mkfs.fat -n GIM /dev/sdX1
34+
# mkfs.fat -n $LABEL /dev/sdX1
3335
```
3436

3537
## Or with `gparted`
@@ -40,34 +42,46 @@ gparted /dev/sdX
4042
# Partition -> New -> (configure options) -> Add
4143
Create as: Primary Partition
4244
File System: fat32
43-
Label: GIM
45+
Label: $LABEL
4446
# Apply all operations
4547
# Select partition /dev/sdX1 -> Left click -> Manage Flags -> Enable boot flag
4648
```
4749

4850
## 2. Installation Guide (formated disk)
4951

52+
53+
### 2.1a mount
5054
```
51-
mkdir -p /tmp/GIM
52-
mount /dev/disk/by-label/GIM /tmp/GIM
53-
grub-install --boot-directory=/tmp/GIM/boot /dev/sdX
54-
tar xvf grub-iso-multiboot.tar.gz -C /tmp/GIM
55-
umount /tmp/GIM
55+
mkdir -p /tmp/$LABEL
56+
sudo mount /dev/disk/by-label/$LABEL /tmp/$LABEL
5657
```
5758

58-
## 3. Adjusts
59+
### 2.1b mount (as a regular user)
60+
```
61+
pmount /dev/disk/by-label/$LABEL
62+
# adapt destination to the created folder in /media for the following commands
63+
# mount point will look something like this: /media/disk_by-label_$LABEL
64+
```
5965

60-
### 3.1 I don't want to change the label
66+
### 2.2 install grub & copy release files
67+
```
68+
grub-install --boot-directory=/tmp/$LABEL/boot /dev/sdX
69+
tar xvf grub-iso-multiboot.tar.gz -C /tmp/$LABEL
70+
```
6171

62-
If you didn't change your label to `GIM` you will need to change
63-
`/tmp/GIM/boot/grub/grub.cfg` last line:
72+
### 2.3a unmount
73+
```
74+
umount /tmp/$LABEL
75+
```
6476

65-
```diff
66-
-scan_isos /boot/iso GIM
67-
+scan_isos /boot/iso <label>
77+
### 2.3b unmount
78+
```
79+
pumount /media/disk_by-label_$LABEL
6880
```
6981

70-
### 3.2 I want my GRUB to look like that
82+
## 3. Adjusts
83+
84+
### 3.1 I want my GRUB to look like that
7185

7286
Find a [theme](https://www.gnome-look.org/browse/cat/109/ord/rating/) you would
7387
like to use. The one from the screenshot above is
@@ -76,26 +90,25 @@ like to use. The one from the screenshot above is
7690
Move the theme contents to the `themes` folder of the instalation, like so:
7791

7892
```
79-
mount /dev/disk/by-label/GIM /tmp/GIM
93+
mount /dev/disk/by-label/$LABEL /tmp/$LABEL
8094
tar xvf Vimix-1080p.tar.xz -C /tmp/
81-
mv /tmp/Vimix-1080p/Vimix /tmp/GIM/boot/grub/themes/vimix
95+
mv /tmp/Vimix-1080p/Vimix /tmp/$LABEL/boot/grub/themes/vimix
8296
```
8397

8498
Double check that you have the `theme.txt` file in the correct place
85-
`/tmp/GIM/boot/grub/themes/vimix/theme.txt`.
99+
`/tmp/$LABEL/boot/grub/themes/vimix/theme.txt`.
86100

87-
As the last step, select the theme in `/tmp/GIM/boot/grub/grub.cfg`:
101+
As the last step, select the theme in `/tmp/$LABEL/boot/grub/grub.cfg`:
88102

89103
```diff
90104
- set theme=/boot/grub/themes/starfield/theme.txt
91105
+ set theme=/boot/grub/themes/vimix/theme.txt
92-
scan_isos /boot/iso GIM
93106
```
94107

95108
release the pendrive.
96109

97110
```
98-
umount /tmp/GIM
111+
umount /tmp/$LABEL
99112
```
100113

101114
## 4. Add isos to /boot/iso/
@@ -104,11 +117,16 @@ Menu entries will be populated according to the files present during boot.
104117
To add isos via terminal, just copy them over:
105118

106119
```
107-
mount /dev/disk/by-label/GIM /tmp/GIM
108-
cp <my-iso-file>.iso /tmp/GIM/boot/iso/
109-
umount /tmp/GIM
120+
mount /dev/disk/by-label/$LABEL /tmp/$LABEL
121+
cp <my-iso-file>.iso /tmp/$LABEL/boot/iso/
122+
umount /tmp/$LABEL
110123
```
111124

125+
## 5. Contibute
126+
127+
### 5.1 You can contribute by requesting/testing ISOs, and also by making a
128+
donation.
129+
112130
Consider donating:
113131

114132
```

0 commit comments

Comments
 (0)