Browse code

grub.cfg: Do not use hardcoded root partition path.

YustasSwamp authored on 2015/08/14 09:12:04
Showing 1 changed files
... ...
@@ -77,9 +77,18 @@ cp boot/terminal_*.tga ${BUILDROOT}/boot/grub2/themes/photon/
77 77
 cp boot/theme.txt ${BUILDROOT}/boot/grub2/themes/photon/
78 78
 cat > $BUILDROOT/boot/grub2/grub.cfg << EOF
79 79
 # Begin /boot/grub2/grub.cfg
80
+
81
+function set_rootpartition {
82
+    regexp -s dev '.{2}(.)' \$root
83
+    regexp -s part '.*(.)' \$root
84
+    regexp -s char '.{'\$dev'}(.)' abcdefghij
85
+    set rootpartition=/dev/sd\$char\$part
86
+}
87
+
80 88
 set default=0
81 89
 set timeout=5
82 90
 search -n -u $UUID -s
91
+set_rootpartition
83 92
 loadfont /boot/grub2/unifont.pf2
84 93
 
85 94
 insmod gfxterm
... ...
@@ -97,7 +106,7 @@ set theme=/boot/grub2/themes/photon/theme.txt
97 97
 load_env -f /boot/photon.cfg
98 98
 
99 99
 menuentry "Photon" {
100
-    linux \$photon_linux root=$PARTITION \$photon_cmdline
100
+    linux \$photon_linux root=\$rootpartition \$photon_cmdline
101 101
     if [ "\$photon_initrd" ]; then
102 102
         initrd \$photon_initrd
103 103
     fi