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 1fd59fc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# checks and aborts the boot if system has several partitions with label specified by $1

set -euo pipefail

PARTITIONS=()
mapfile -t PARTITIONS < <(lsblk -o LABEL,NAME --pairs --paths --noheadings | 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 @@ -30,6 +30,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 1fd59fc

Please sign in to comment.