-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path08_bootmgr.sh
104 lines (84 loc) · 3.11 KB
/
08_bootmgr.sh
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
source config.sh
UUIDROOT=$(blkid -s UUID -o value /dev/sda2)
if [ ! -f /root/installer/logs/linux.preset.bak ]; then
# backup the linux.preset for mkinitcpio
cp /etc/mkinitcpio.d/linux.preset /root/installer/logs/linux.preset.bak
fi
# ----------------------------------------------- BOOTLDRX (systemd-boot based)
if [ x"${BOOTMNGR}" == x"xbootldr" ]; then
# for xbootldr to work:
# loader.conf MUST be on the ESP (the same where the systemd.efi lives)
# loader/entries/*.conf MUST live on the XBOOTLDR partition
mkdir -p /boot/loader/entries /efi/loader
cat > /efi/loader/loader.conf << EOUBOOTLOAD
default arch
timeout 8
console-mode max
editor no
EOUBOOTLOAD
cat > /boot/loader/entries/arch.conf << EOARCHCONF
title Arch Linux
linux /vmlinuz-linux
initrd /intel-ucode.img
initrd /initramfs-linux.img
options root=UUID=${UUIDROOT} ro
EOARCHCONF
cat > /boot/loader/entries/arch-fallback.conf << EOARCHFBCONF
title Arch Linux (fallback initramfs)
linux /vmlinuz-linux
initrd /intel-ucode.img
initrd /initramfs-linux-fallback.img
options root=UUID=${UUIDROOT} single ro
EOARCHFBCONF
fi
#----------------------------------------------------------------
# --------------------------------------------------------------- systemd-boot
if [ x"${BOOTMNGR}" == x"systemd" ]; then
mkdir -p /boot/loader/entries
cat > /boot/loader/loader.conf << EOUBOOTLOAD
default arch
timeout 6
console-mode max
editor no
EOUBOOTLOAD
cat > /boot/loader/entries/arch.conf << EOARCHCONF
title Arch Linux
linux /vmlinuz-linux
initrd /intel-ucode.img
initrd /initramfs-linux.img
options root=UUID=${UUIDROOT} ro
EOARCHCONF
cat > /boot/loader/entries/arch-fallback.conf << EOARCHFBCONF
title Arch Linux (fallback initramfs)
linux /vmlinuz-linux
initrd /intel-ucode.img
initrd /initramfs-linux-fallback.img
options root=UUID=${UUIDROOT} single ro
EOARCHFBCONF
fi
# --------------------------------------------------------------- grub
if [ x"${BOOTMNGR}" == x"grub" ]; then
pacman -S --needed --noconfirm grub
fi
# --------------------------------------------------------------- refind
if [ x"${BOOTMNGR}" == x"refind" ]; then
pacman -S --needed --noconfirm refind
fi
# --------------------------------------------------------------- efistub
if [ x"${BOOTMNGR}" == x"efistub" ]; then
ESP_PATH=/boot/EFI/Linux
mkdir -p ${ESP_PATH}
echo -e "ro root=UUID=${UUIDROOT}" > /etc/kernel/cmdline
echo -e "ro root=UUID=${UUIDROOT} single" > /etc/kernel/fallback_cmdline
sed \
-e "s:.*\(default_image=.*\):#\1:" \
-e "s:.*\(default_uki\).*:\1=\"${ESP_PATH}/arch-linux.efi\":" \
-e "s:.*\(default_options\).*:\1=\"--cmdline /etc/kernel/cmdline\":" \
-e "s:.*\(fallback_image=.*\):#\1:" \
-e "s:.*\(fallback_uki\).*:\1=\"${ESP_PATH}/arch-linux-fallback.efi\":" \
-e "s:.*\(fallback_options\).*:\1=\"-S autodetect --cmdline /etc/kernel/fallback_cmdline\":" \
-i /etc/mkinitcpio.d/linux.preset
# UGLY-HACK remove and re-install linux kernel to have it pickup the vmlinuz location
pacman -Rdd --noconfirm linux
pacman -S --noconfirm linux
fi