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: create symlink to the disk holding
root
partition
Issue: coreos/fedora-coreos-tracker#759 Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
- Loading branch information
1 parent
c5b299a
commit e1836ca
Showing
4 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
overlay.d/05core/usr/lib/dracut/modules.d/35coreos-ignition/coreos-root-symlink.service
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,23 @@ | ||
[Unit] | ||
Description=Create symlink to boot disk | ||
ConditionPathExists=/etc/initrd-release | ||
DefaultDependencies=no | ||
Wants=systemd-udevd.service | ||
After=systemd-udevd.service | ||
|
||
Requires=dev-disk-by\x2dlabel-root.device | ||
After=dev-disk-by\x2dlabel-root.device | ||
# And since the boot device may be on multipath; optionally wait for it to | ||
# appear via the dynamic target. | ||
After=coreos-multipath-wait.target | ||
After=coreos-gpt-setup.service | ||
Before=ignition-disks.service | ||
|
||
OnFailure=emergency.target | ||
OnFailureJobMode=isolate | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=/usr/sbin/create-root-symlink | ||
|
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
27 changes: 27 additions & 0 deletions
27
overlay.d/05core/usr/lib/dracut/modules.d/35coreos-ignition/create-root-symlink.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,27 @@ | ||
#!/bin/bash | ||
# creates a stable device path for the boot disk when there's exactly one such disk, | ||
# and create no such symlink in other cases (e.g. rootfs RAID) | ||
# Symlink is not propogated to the real root (removed during coreos-teardown-initramfs) | ||
|
||
set -euo pipefail | ||
|
||
# force kernel to update info about disks | ||
for dev in $(lsblk -o NAME --noheadings --nodeps --list --paths); do | ||
partx -u ${dev} | ||
done | ||
|
||
udevadm trigger | ||
udevadm settle | ||
|
||
LINK=/dev/disk/coreos-root-disk | ||
PARTITIONS=() | ||
# skip multipath disks (with same WWN) | ||
mapfile -t PARTITIONS < <(lsblk -o WWN,LABEL,NAME,PKNAME --pairs --paths --noheadings | grep 'LABEL="root"' | sed 's/WWN=\"\" //' | sort -u -k1,2) | ||
|
||
LENGTH=${#PARTITIONS[@]} | ||
if [[ ${LENGTH} -eq 1 ]]; then | ||
eval ${PARTITIONS[0]} | ||
echo "Creating symlink '${LINK}' to '${PKNAME}' (contains 'root' partition '${NAME}')" | ||
mkdir -p /dev/disk/ | ||
ln -s ${PKNAME} ${LINK} | ||
fi |
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