-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dracut/ignition-ostree: Regenerate UUIDs for /boot and /
This is a general best practice; the intention of filesystem UUIDs is that they're unique. It helps backup systems and the like if we change this. But in the future, we may also switch to using these UUIDs for subsequent boots; see: coreos/fedora-coreos-tracker#465
- Loading branch information
Showing
5 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/ignition-ostree-firstboot-uuid
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,26 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
# https://github.com/coreos/fedora-coreos-tracker/issues/465 | ||
# coreos-assembler generates disk images which are installed bit-for-bit | ||
# or booted directly in the cloud. | ||
# Generate new UUID on firstboot; this is general best practice, but in the future | ||
# we may use this for mounting by e.g. adding a boot=<uuid> and root=<uuid> kernel args. | ||
# Note this code should be changed when we land https://github.com/coreos/fedora-coreos-tracker/issues/94 | ||
# so that we only generate a new UUID if we're using the default one. | ||
|
||
regenerate_uuid() { | ||
local path=$1 | ||
shift | ||
if ! [ -b "${path}" ]; then | ||
echo "$0: Failed to find block device ${path}" 1>&2 | ||
exit 1 | ||
fi | ||
eval $(blkid -o export ${path}) | ||
case "${TYPE}" in | ||
ext4) tune2fs -U random "${path}" ;; | ||
xfs) xfs_admin -U generate "${path}" ;; | ||
*) echo "warning: Don't know how to generate uuid for filesystem ${TYPE} at ${path}" 1>&2 ;; | ||
esac | ||
} | ||
|
||
regenerate_uuid /dev/disk/by-label/$1 |
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
...lay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/ignition-ostree-uuid-boot.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,19 @@ | ||
[Unit] | ||
Description=Ignition OSTree: Regenerate filesystem UUID (boot) | ||
DefaultDependencies=false | ||
ConditionPathExists=/usr/lib/initrd-release | ||
ConditionKernelCommandLine=ostree | ||
ConditionPathExists=!/run/ostree-live | ||
# We run pretty early | ||
Before=coreos-copy-firstboot-network.service | ||
Before=ignition-fetch.service | ||
Before=ignition-setup-base.service | ||
Before=ignition-setup-user.service | ||
|
||
Requires=dev-disk-by\x2dlabel-boot.device | ||
After=dev-disk-by\x2dlabel-boot.device | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=/usr/sbin/ignition-ostree-firstboot-uuid boot |
18 changes: 18 additions & 0 deletions
18
...lay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/ignition-ostree-uuid-root.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,18 @@ | ||
[Unit] | ||
Description=Ignition OSTree: Regenerate filesystem UUID (root) | ||
# These conditions match mount-firstboot-sysroot.service | ||
DefaultDependencies=false | ||
ConditionKernelCommandLine=!root | ||
ConditionKernelCommandLine=ostree | ||
ConditionPathExists=!/run/ostree-live | ||
Before=initrd-root-fs.target | ||
After=ignition-disks.service | ||
# Note we don't have a Requires: /dev/disk/by-label/root here like | ||
# the -subsequent service does because ignition-disks may have | ||
# regenerated it. | ||
Before=ignition-ostree-mount-firstboot-sysroot.service | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=/usr/sbin/ignition-ostree-firstboot-uuid root |
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