Skip to content

Commit

Permalink
arch-luks-suspend assumes that the root device is /dev/mapper/{crypt-…
Browse files Browse the repository at this point in the history
…name}

Fixes vianney#8
  • Loading branch information
afn committed Dec 30, 2016
1 parent 15420df commit 31a1e8d
Showing 1 changed file with 3 additions and 2 deletions.
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

0 comments on commit 31a1e8d

Please sign in to comment.