-
Notifications
You must be signed in to change notification settings - Fork 0
/
fix-reboot.sh
executable file
·42 lines (30 loc) · 968 Bytes
/
fix-reboot.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
#!/bin/bash
# Because the X1 Carbon (4th Gen) has a broken UEFI, some serious
# hacks are required to be able to dual boot back into this Linux
# instance. Here we attempt to make this possible by using the
# BootNext flag with efibootmgr as changing BootOrder doesn't work.
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NEXT=`efibootmgr | grep BootNext | cut -c11-14`
DEB=`efibootmgr | grep debian | cut -c5-8`
ORDER=`efibootmgr | grep BootOrder | cut -c12-`
# Check to see if the last time we set BootOrder stuck:
echo $ORDER | grep -q $DEB
TEST=`echo $?`
if [ "$TEST" = "0" ];
then
exit
else
# If we got here, the efibootmgr is broken still, so we'll set
# the "BootNext" variable which does survive a reboot.
# Check if BootNext is set and bail, or set it
if [ "$NEXT" != "$DEB" ];
then
efibootmgr -n $DEB
else
exit
fi
# Here we'll try to reset the boot order as well. It might work
# one of these days.
efibootmgr -O
efibootmgr -o $DEB,$ORDER
fi