-
Notifications
You must be signed in to change notification settings - Fork 117
/
Copy pathgrub.cfg_internal_template
67 lines (61 loc) · 1.71 KB
/
grub.cfg_internal_template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Automatically created by OE
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
default=boot
insmod ext2
insmod gzio
insmod test
insmod loadenv
insmod regexp
insmod probe
insmod configfile
timeout=@@TIMEOUT@@
load_env --skip-sig bootcount resin_root_part upgrade_available
source ${prefix}/grub_extraenv
if [ ${upgrade_available} = 1 ] ; then
if [ ${bootcount} = 1 ] ; then
set bootcount=2
save_env bootcount
fi
if [ ${bootcount} = 0 ] ; then
set bootcount=1
save_env bootcount
fi
fi
function get_root_uuid {
# Extract drive and partition type from boot drive in grub format
regexp -s 1:bdrive -s 2:pscheme '^(hd.*),(msdos|gpt).*' $root
# Parse boot drive partitions looking for specific label
for part in 1 2 3 4 5 6 7 8 9 10; do
probe --set rlabel --label (${bdrive},${pscheme}${part})
# On label match, extract filesystem UUID and set this partition as new root
if test $rlabel == "$1"; then
probe --set root_uuid --fs-uuid (${bdrive},${pscheme}${part})
search --set root --fs-uuid ${root_uuid}
return
fi
done
}
menuentry 'boot'{
if [ ${bootcount} = 2 ] ; then
if [ ${resin_root_part} = 2 ] ; then
get_root_uuid "resin-rootB"
else
get_root_uuid "resin-rootA"
fi
else
if [ ${resin_root_part} = 2 ] ; then
get_root_uuid "resin-rootA"
else
get_root_uuid "resin-rootB"
fi
fi
linux /boot/@@KERNEL_IMAGETYPE@@ root=UUID=${root_uuid} @@KERNEL_CMDLINE@@ ${extra_os_cmdline}
}
menuentry 'manualfallbackA' {
get_root_uuid "resin-rootA"
linux /boot/@@KERNEL_IMAGETYPE@@ root=UUID=${root_uuid} @@KERNEL_CMDLINE@@ ${extra_os_cmdline}
}
menuentry 'manualfallbackB' {
get_root_uuid "resin-rootB"
linux /boot/@@KERNEL_IMAGETYPE@@ root=UUID=${root_uuid} @@KERNEL_CMDLINE@@ ${extra_os_cmdline}
}