-
Notifications
You must be signed in to change notification settings - Fork 148
fix(crypt): set need_shutdown for LUKS under systemd-cryptsetup #2406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
nadzyah
wants to merge
1
commit into
dracut-ng:main
Choose a base branch
from
nadzyah:shutdown-failed
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| #!/bin/sh | ||
|
|
||
| command -v getarg > /dev/null || . /lib/dracut-lib.sh | ||
|
|
||
| # The legacy crypt path calls need_shutdown from cryptroot-ask.sh, but | ||
| # systemd-cryptsetup does not, so ensure the flag is set here whenever a LUKS | ||
| # mapping is active. Otherwise dracut-initramfs-restore exits early and | ||
| # dm-shutdown.sh never runs, leaving LUKS stacks busy at shutdown | ||
| for _dev in /sys/block/dm-*; do | ||
| [ -e "${_dev}/dm/uuid" ] || continue | ||
| case $(cat "${_dev}/dm/uuid") in | ||
| CRYPT-LUKS*) | ||
| need_shutdown | ||
| break | ||
| ;; | ||
| esac | ||
| done | ||
| unset _dev |
This file contains hidden or 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
This file contains hidden or 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,11 @@ | ||
| #!/bin/sh | ||
|
|
||
| # required binaries: test | ||
|
|
||
| # Verify that dracut flagged .need_shutdown during boot. Without the flag, | ||
| # dracut-initramfs-restore exits early on shutdown, the initramfs is not | ||
| # pivoted to, and dm-shutdown.sh never runs leaving LUKS stacks | ||
| # (e.g. LVM-on-LUKS) busy and blocking poweroff | ||
| if [ ! -e /run/initramfs/.need_shutdown ]; then | ||
| echo "/run/initramfs/.need_shutdown was not created during boot" >> /run/failed | ||
| fi |
This file contains hidden or 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,32 @@ | ||
| #!/bin/sh | ||
|
|
||
| # Creates a single-disk LVM-on-LUKS root filesystem for the shutdown test | ||
|
|
||
| trap 'poweroff -f' EXIT | ||
| set -ex | ||
|
|
||
| printf verySecurePassword > keyfile | ||
| cryptsetup --pbkdf pbkdf2 -q luksFormat /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_disk1 /keyfile | ||
| cryptsetup luksOpen /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_disk1 vault < /keyfile | ||
|
|
||
| lvm pvcreate -ff -y /dev/mapper/vault | ||
| lvm vgcreate dracut /dev/mapper/vault | ||
| lvm lvcreate --yes -l 100%FREE -n root dracut | ||
| lvm vgchange -ay | ||
|
|
||
| mkfs.ext4 -q /dev/dracut/root | ||
| mkdir -p /sysroot | ||
| mount -t ext4 /dev/dracut/root /sysroot | ||
| cp -a -t /sysroot /source/* | ||
| umount /sysroot | ||
|
|
||
| lvm lvchange -a n /dev/dracut/root | ||
| lvm vgchange -an | ||
| cryptsetup luksClose vault | ||
|
|
||
| { | ||
| echo "dracut-root-block-created" | ||
| udevadm info --query=property --name=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_disk1 \ | ||
| | grep 'ID_FS_UUID=' | ||
| } | dd oflag=direct of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker status=none | ||
| sync |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.