Skip to content

Commit

Permalink
overlay.d: abort booting if system has more than 1 'boot' partition
Browse files Browse the repository at this point in the history
Inspired by: coreos/fedora-coreos-tracker#976

Signed-off-by: Nikita Dubrovskii <[email protected]>
  • Loading branch information
nikita-dubrovskii committed Sep 30, 2021
1 parent 904141f commit 1087eeb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# checks and aborts the boot if system has several partitions with label specified by $1

set -euo pipefail

# ensure all disks are discovered
udevadm trigger
udevadm settle

# read WWN to skip multipath disks
PARTITIONS=()
mapfile -t PARTITIONS < <(lsblk -o LABEL,WWN,NAME --pairs --paths --noheadings | sort -u -k1,2 | grep "LABEL=\""$1"\"")

LENGTH=${#PARTITIONS[@]}
if [[ ${LENGTH} -gt 1 ]]; then
echo "System has "${LENGTH}" partitions with '"$1"' label:"
for PT in "${PARTITIONS[@]}"; do
echo "${PT}"
done
echo "Please 'wipefs' other partitions/disks and reboot. Aborting..."
exit 1
fi
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ OnFailureJobMode=isolate
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/usr/sbin/coreos-ensure-single-partition boot
ExecStart=/usr/sbin/coreos-gpt-setup /dev/disk/by-label/boot
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ install() {
diff \
lsblk \
sed \
sort \
grep \
sgdisk

inst_simple "$moddir/coreos-diskful-generator" \
Expand All @@ -30,6 +32,9 @@ install() {
inst_script "$moddir/coreos-gpt-setup.sh" \
"/usr/sbin/coreos-gpt-setup"

inst_script "$moddir/coreos-ensure-single-partition.sh" \
"/usr/sbin/coreos-ensure-single-partition"

inst_script "$moddir/coreos-ignition-setup-user.sh" \
"/usr/sbin/coreos-ignition-setup-user"

Expand Down

0 comments on commit 1087eeb

Please sign in to comment.