-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathefi_sync
More file actions
executable file
·46 lines (34 loc) · 1.45 KB
/
Copy pathefi_sync
File metadata and controls
executable file
·46 lines (34 loc) · 1.45 KB
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
#!/bin/bash
# The overall idea is that, if we sync the EFI information to the
# second drive, it has all the information it needs to boot as a
# degraded array. Switch out the first drive, mirror the partition
# scheme, add the device to the RAID array, let it rebuild, and
# everything will be fine.
HOSTNAME=`hostname`
if [ $HOSTNAME == "bluebox" ]; then
# This machine is a little odd. The install was originally on BIOS
# machines which was converted over to an EFI machine, so it ended
# with the EFI System Partition (ESP) as the last partition on the
# disks, rather than the first.
DRIVE="/dev/nvme1n1p4"
elif [ $HOSTNAME == "hiro" ]; then
# This machine is similar to bluebox, except that it has 3 NVMe
# drives (2 the same and 1 different) AND the system firmware
# likes to reorder them every boot. Thus, we can't reliably mount
# them by device name, and we need to use UUID instead.
DRIVE="UUID=\"42CE-83D3\""
elif [ $HOSTNAME == "cameras" ]; then
# This machine is more conventional. It was built as an EFI
# machine, so the ESP is first on the drives.
DRIVE="/dev/sdb1"
else
echo "Unknown machine. Not doing anything to protect against damage."
exit -1
fi
# This mountpoint is the same for all machines.
EFI_DIR="/boot/efi"
TMP_DIR=`mktemp -d /tmp/efi_mount.XXXX`
mount ${DRIVE} ${TMP_DIR} && \
rsync -a --delete ${EFI_DIR}/ ${TMP_DIR} && \
umount ${TMP_DIR} && \
rmdir ${TMP_DIR}