Skip to content
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

arch-luks-suspend assumes that the root device is /dev/mapper/{crypt-name} #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions arch-luks-suspend
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ BIND_PATHS="/sys /proc /dev /run"
REMOUNT=0
# Retrieve cryptdevice name from boot cmdline
CRYPTNAME="$(sed -n 's/.*cryptdevice=[^: ]*:\([^: ]*\).*$/\1/p' /proc/cmdline)"
ROOTDEV=$(sed -n 's/.*root=\([^ ]*\).*/\1/p' /proc/cmdline)

# run_dir DIR ARGS...
# Run all executable scripts in directory DIR with arguments ARGS
Expand All @@ -30,7 +31,7 @@ umount_initramfs() {
}

ext4_cryptdevice_mount_options() {
local mt="$(grep "^/dev/mapper/${1} " /proc/mounts | cut -d ' ' -f 3,4)"
local mt="$(grep "^${1} " /proc/mounts | cut -d ' ' -f 3,4)"
if [[ "${mt:0:5}" == "ext4 " ]]; then
echo "${mt:5}"
fi
Expand Down Expand Up @@ -60,7 +61,7 @@ systemctl stop systemd-udevd.service
# Journalled ext4 filesystems in kernel versions 3.11+ will block suspend
# if mounted with `barrier=1`, which is the default. Temporarily remount with
# `barrier=0` if this is true of the crypt fs.
MOUNT_OPTS="$(ext4_cryptdevice_mount_options "$CRYPTNAME")"
MOUNT_OPTS="$(ext4_cryptdevice_mount_options "$ROOTDEV")"
if [[ "$MOUNT_OPTS" ]] && ! [[ "$MOUNT_OPTS" == *nobarrier* || "$MOUNT_OPTS" == *barrier=0* ]]; then
REMOUNT=1
mount -o remount,"$MOUNT_OPTS",barrier=0 /
Expand Down