forked from coreos/fedora-coreos-config
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
overlay.d: add udev rule for
stable-root
disk
Issue: coreos/fedora-coreos-tracker#759 Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
- Loading branch information
1 parent
548312e
commit 1ae196e
Showing
6 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
overlay.d/05core/usr/lib/dracut/modules.d/35coreos-ignition/count-fs.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
# Returns amount of filesystems labeled `label` | ||
|
||
label=$1 | ||
uids=() | ||
|
||
for path in /sys/block/*; do | ||
disk=$(basename $path) | ||
for pt in /sys/block/$disk/*; do | ||
name=$(basename $pt) | ||
if [[ "$name" =~ "$disk" ]]; then | ||
eval $(udevadm info --query=property -n /dev/$name | grep -e PARTNAME -e ID_FS_UUID_ENC) | ||
if [[ "$PARTNAME" == "$label" ]]; then | ||
uid=$ID_FS_UUID_ENC | ||
if [[ -z $uid ]]; then | ||
uid=$(/usr/lib/udev/scsi-id -ugd /dev/$name || echo $pt) | ||
fi | ||
uids+=("$uid") | ||
fi | ||
fi | ||
done | ||
done | ||
|
||
uids=($(echo "${uids[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')) | ||
echo ${#uids[@]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
overlay.d/05core/usr/lib/udev/rules.d/99-zz-coreos-stable-root.rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# CoreOS-specific symlink for disk holdind filesystem labeled `root` | ||
|
||
ACTION!="add|change", GOTO="stable_root_end" | ||
SUBSYSTEM!="block", GOTO="stable_root_end" | ||
TEST!="/usr/bin/count-fs", GOTO="stable_root_end" | ||
|
||
# First run on disks and check how many filesystems labeled `root` we have | ||
ENV{DEVTYPE}=="disk" \ | ||
, PROGRAM=="/usr/bin/count-fs root", RESULT=="1" \ | ||
, SYMLINK+="disk/by-id/coreos-root-disk" | ||
|
||
# During processing of disks there are no UUIDs available, so double check | ||
# how many filesystems labeled `root` we have, and if it's not unique - remove | ||
# the symlink | ||
ENV{DEVTYPE}=="partition", ENV(ID_FS_LABEL_ENC)=="root" \ | ||
, PROGRAM=="/usr/bin/count-fs root", RESULT!="1" \ | ||
, RUN{program}+="/bin/rm -f /dev/disk/by-id/coreos-root-disk" | ||
|
||
LABEL="stable_root_end" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
variant: fcos | ||
version: 1.3.0 | ||
storage: | ||
disks: | ||
- device: /dev/disk/by-id/coreos-root-disk | ||
wipe_table: false | ||
partitions: | ||
- number: 5 | ||
size_mib: 1024 | ||
label: toor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
set -xeuo pipefail | ||
|
||
# This test makes sure that ignition is able to use symlink to the disk with `root` fs | ||
|
||
# We don't need to test this on every platform. If it passes in | ||
# one place it will pass everywhere. | ||
# kola: { "platforms": "qemu-unpriv" } | ||
|
||
ok() { | ||
echo "ok" "$@" | ||
} | ||
|
||
fatal() { | ||
echo "$@" >&2 | ||
exit 1 | ||
} | ||
|
||
link="/dev/disk/by-id/coreos-root-disk" | ||
if [[ -h "${link}" ]]; then | ||
fatal "${link} still exists" | ||
fi | ||
|
||
ok "${link} doesn't exist" |