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 a2ec398
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
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,25 @@ | ||
[Unit] | ||
Description=Create symlink to boot disk | ||
ConditionPathExists=/etc/initrd-release | ||
DefaultDependencies=no | ||
Before=local-fs-pre.target systemd-fsck-root.service | ||
Before=ignition-diskful.target | ||
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=coreos-ignition-setup-user.service 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
23 changes: 23 additions & 0 deletions
23
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,23 @@ | ||
#!/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 | ||
|
||
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 for disk '${PKNAME}' holding 'root' partiton '${NAME}'" | ||
mkdir -p /dev/disk/by-label | ||
ln -s ${PKNAME} /dev/disk/by-label/coreos-root-disk | ||
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