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

no root cryptdevice error #1

Closed
rokups opened this issue Aug 22, 2017 · 8 comments
Closed

no root cryptdevice error #1

rokups opened this issue Aug 22, 2017 · 8 comments

Comments

@rokups
Copy link

rokups commented Aug 22, 2017

Trying to suspend prints error "no root cryptdevice" and shuts down system instead.

/proc/mounts:

proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sys /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
dev /dev devtmpfs rw,nosuid,relatime,size=16380616k,nr_inodes=4095154,mode=755 0 0
run /run tmpfs rw,nosuid,nodev,relatime,mode=755 0 0
efivarfs /sys/firmware/efi/efivars efivarfs rw,nosuid,nodev,noexec,relatime 0 0
/dev/mapper/system-root / ext4 rw,relatime,discard,data=ordered 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0
cgroup /sys/fs/cgroup/unified cgroup2 rw,nosuid,nodev,noexec,relatime 0 0
cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,name=systemd 0 0
pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0
cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0
cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0
cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0
cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0
cgroup /sys/fs/cgroup/net_cls,net_prio cgroup rw,nosuid,nodev,noexec,relatime,net_cls,net_prio 0 0
cgroup /sys/fs/cgroup/pids cgroup rw,nosuid,nodev,noexec,relatime,pids 0 0
cgroup /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0
cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=24,pgrp=1,timeout=0,minproto=5,maxproto=5,direct 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,relatime 0 0
mqueue /dev/mqueue mqueue rw,relatime 0 0
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
systemd-1 /mnt/storage autofs rw,relatime,fd=36,pgrp=1,timeout=0,minproto=5,maxproto=5,direct 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
configfs /sys/kernel/config configfs rw,relatime 0 0
tmpfs /tmp tmpfs rw,nosuid,nodev,relatime 0 0
/dev/sdd1 /boot vfat rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro,discard 0 0
/dev/mapper/system-home /home ext4 rw,relatime,discard,data=ordered 0 0
/dev/mapper/storage /mnt/storage ext4 rw,noatime,data=ordered 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=3285268k,mode=700,uid=1000,gid=100 0 0
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
gvfsd-fuse /run/user/1000/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=100 0 0

/etc/crypttab

# crypttab: mappings for encrypted partitions
#
# Each mapped device will be created in /dev/mapper, so your /etc/fstab
# should use the /dev/mapper/<name> paths for encrypted devices.
#
# The Arch specific syntax has been deprecated, see crypttab(5) for the
# new supported syntax.
#
# NOTE: Do not list your root (/) partition here, it must be set up
#       beforehand by the initramfs (/etc/mkinitcpio.conf).

# <name>       <device>                                     <password>              <options>
# home         UUID=b8ad5c18-f445-495d-9095-c9ec4f9d2f37    /etc/mypassword1
# data1        /dev/sda3                                    /etc/mypassword2
# data2        /dev/sda5                                    /etc/cryptfs.key
# swap         /dev/sdx4                                    /dev/urandom            swap,cipher=aes-cbc-essiv:sha256,size=256
# vol          /dev/sdb7                                    none

bkp            UUID=092c5ee8-7df2-42f3-a696-eb4e095ceaec    /etc/keys/bkp.key       luks,nofail
storage        UUID=2e13de08-4e66-4825-8553-43f1419b9c4f    /etc/keys/storage.key   luks,nofail
@guns
Copy link
Owner

guns commented Aug 22, 2017

shuts down system instead

Sorry about that! I forgot to mention in the README that the program powers off the machine on errors as a precaution. Debug mode disables this:

# /usr/lib/go-luks-suspend/go-luks-suspend -debug

Trying to suspend prints error "no root cryptdevice"

Looks like I might be making an assumption about sysfs that isn't true on your system.

Could you please tell me what is the output of:

$ ls -ld /sys/block/*/dm; ls -l /dev/disk/by-id/dm-*

Thanks!

@rokups
Copy link
Author

rokups commented Aug 22, 2017

~ % ls -ld /sys/block/*/dm; ls -l /dev/disk/by-id/dm-*
drwxr-xr-x - root 22 Rgp 20:27 /sys/block/dm-0/dm
drwxr-xr-x - root 22 Rgp 20:27 /sys/block/dm-2/dm
drwxr-xr-x - root 22 Rgp 20:27 /sys/block/dm-1/dm
drwxr-xr-x - root 22 Rgp 20:27 /sys/block/dm-4/dm
drwxr-xr-x - root 22 Rgp 20:27 /sys/block/dm-3/dm
drwxr-xr-x - root 22 Rgp 20:27 /sys/block/dm-5/dm
lrwxrwxrwx 10 root 22 Rgp 10:44 /dev/disk/by-id/dm-name-bkp -> ../../dm-5
lrwxrwxrwx 10 root 22 Rgp 10:44 /dev/disk/by-id/dm-name-cryptolvm -> ../../dm-0
lrwxrwxrwx 10 root 22 Rgp 10:44 /dev/disk/by-id/dm-name-storage -> ../../dm-4
lrwxrwxrwx 10 root 22 Rgp 10:44 /dev/disk/by-id/dm-name-system-home -> ../../dm-1
lrwxrwxrwx 10 root 22 Rgp 10:44 /dev/disk/by-id/dm-name-system-root -> ../../dm-2
lrwxrwxrwx 10 root 22 Rgp 10:44 /dev/disk/by-id/dm-name-system-swap -> ../../dm-3
lrwxrwxrwx 10 root 22 Rgp 10:44 /dev/disk/by-id/dm-uuid-CRYPT-LUKS1-092c5ee87df242f3a696eb4e095ceaec-bkp -> ../../dm-5
lrwxrwxrwx 10 root 22 Rgp 10:44 /dev/disk/by-id/dm-uuid-CRYPT-LUKS1-2e13de084e664825855343f1419b9c4f-storage -> ../../dm-4
lrwxrwxrwx 10 root 22 Rgp 10:44 /dev/disk/by-id/dm-uuid-CRYPT-LUKS1-ae490dc87b40443d9241607802c39b53-cryptolvm -> ../../dm-0
lrwxrwxrwx 10 root 22 Rgp 10:44 /dev/disk/by-id/dm-uuid-LVM-L4Pb5ccD1tpIGOIs03BWiUUw8PWqrWpc0xePtdIgVDOI6ZsVjHCjOCBRIYcXnIfu -> ../../dm-2
lrwxrwxrwx 10 root 22 Rgp 10:44 /dev/disk/by-id/dm-uuid-LVM-L4Pb5ccD1tpIGOIs03BWiUUw8PWqrWpcHUyOCqyXsuFhLs6IecJbNaqcSdV34IOC -> ../../dm-3
lrwxrwxrwx 10 root 22 Rgp 10:44 /dev/disk/by-id/dm-uuid-LVM-L4Pb5ccD1tpIGOIs03BWiUUw8PWqrWpcpy1Wulo5HVCKkLg41GuZa9T5dVr2jqy7 -> ../../dm-1

@guns
Copy link
Owner

guns commented Aug 22, 2017

Thanks. I'm pretty sure it's related to vianney#8 then. I don't have a system with LVM, but I'll do my best!

guns added a commit that referenced this issue Aug 22, 2017
cf. #1

In an LVM on LUKS setup the root cryptdevice does not hold the
filesystem that is mounted on /. We can get this information from
/proc/cmdline instead.

Credit to afn:

vianney#8
@guns
Copy link
Owner

guns commented Aug 22, 2017

Okay, I'm pretty sure this will handle an LVM on LUKS setup. You should run the binary in debug mode from a root shell to test:

# /usr/lib/go-luks-suspend/go-luks-suspend -debug

The binary in the initramfs is unchanged, so there is no need to reboot; just makepkg and update.

@rokups
Copy link
Author

rokups commented Aug 23, 2017

Seems like problem is still present.

~ % /usr/lib/go-luks-suspend/go-luks-suspend -debug
2017/08/23 10:56:19 checking for suspend program in initramfs
2017/08/23 10:56:19 gathering cryptdevices
2017/08/23 10:56:19 preparing initramfs chroot
2017/08/23 10:56:19 running pre-suspend scripts
2017/08/23 10:56:19 stopping selected systemd services
2017/08/23 10:56:19 flushing pending writes
2017/08/23 10:56:19 disabling write barriers on filesystems to avoid IO hangs
2017/08/23 10:56:19 dumping list of cryptdevice names to initramfs
2017/08/23 10:56:19 no root cryptdevice
2017/08/23 10:56:19 POWEROFF

I will try to set up IDE and debug it.

@rokups
Copy link
Author

rokups commented Aug 23, 2017

Ok i managed to debug it, whats supposed to be a root device in program happens to be this:

 = {goLuksSuspend.CryptDevice} 
 Name = "cryptolvm"
 DMDir = "/sys/block/dm-0/dm"
 DMDevice = "/dev/mapper/cryptolvm"
 Mountpoint = ""
 Keyfile = ""
 NeedsRemount = false
 IsRootDevice = false

This is not right. IsRootDevice should be true.

~ % ls -lah /dev/mapper 
Permissions   Size User Date Modified Name
lrwxrwxrwx       7 root 23 Rgp 11:38  bkp -> ../dm-5
crw-------  10,236 root 23 Rgp 11:38  control
lrwxrwxrwx       7 root 23 Rgp 11:38  cryptolvm -> ../dm-0
lrwxrwxrwx       7 root 23 Rgp 11:38  storage -> ../dm-4
lrwxrwxrwx       7 root 23 Rgp 11:38  system-home -> ../dm-1
lrwxrwxrwx       7 root 23 Rgp 11:38  system-root -> ../dm-2
lrwxrwxrwx       7 root 23 Rgp 11:38  system-swap -> ../dm-3
~ % cat /proc/cmdline 
initrd=\intel-ucode.img initrd=\initramfs-linux.img cryptdevice=UUID=ae490dc8-7b40-443d-9241-607802c39b53:cryptolvm:allow-discards root=/dev/mapper/system-root resume=/dev/mapper/system-swap rw intel_iommu=on quiet splash intremap=no_x2apic_optout nohz_full=2-5,8-11 rcu_nocbs=2-5,8-11 fastboot user_namespace.enable=1
~ % ls -lah /dev/disk/by-uuid 
Permissions Size User Date Modified Name
lrwxrwxrwx    10 root 23 Rgp 11:38  0c6687e3-43bd-4860-95ca-6f70fa00825f -> ../../dm-4
lrwxrwxrwx    10 root 23 Rgp 11:38  005F-E41D -> ../../sdc2
lrwxrwxrwx    10 root 23 Rgp 11:38  03f578b1-88fb-4427-a2cd-c55aab11e2fa -> ../../dm-3
lrwxrwxrwx    10 root 23 Rgp 11:38  09E6-5AE4 -> ../../sdd1
lrwxrwxrwx     9 root 23 Rgp 11:38  092c5ee8-7df2-42f3-a696-eb4e095ceaec -> ../../sda
lrwxrwxrwx     9 root 23 Rgp 11:38  2e13de08-4e66-4825-8553-43f1419b9c4f -> ../../sdb
lrwxrwxrwx    10 root 23 Rgp 11:38  73b49731-bd14-448c-8185-68dcd079606d -> ../../dm-1
lrwxrwxrwx    10 root 23 Rgp 11:38  29933a9f-ffa3-40cb-b9cb-55d522976e39 -> ../../dm-2
lrwxrwxrwx    10 root 23 Rgp 11:38  94505FA9505F90BA -> ../../sdc1
lrwxrwxrwx    10 root 23 Rgp 11:38  ae490dc8-7b40-443d-9241-607802c39b53 -> ../../sdd2
lrwxrwxrwx    10 root 23 Rgp 11:38  bf268fc0-5515-422e-aaf8-95b0f942022d -> ../../dm-5

@guns
Copy link
Owner

guns commented Aug 24, 2017

Thank you for the detailed feedback! I was grabbing the root=… kernel param when what we needed was the cryptdevice=… param. This is fixed, and I bet your system will now suspend properly.

Looking into this issue made me realize that I am making the false assumption that all LUKS volumes contain filesystems. I'll fix this shortly and post here when I'm done.

Thanks for your help!

@guns
Copy link
Owner

guns commented Sep 8, 2017

Thanks for reporting this issue. This is definitely fixed now (v1.3.1), and in addition, I've changed the default poweroff-on-error setting to false.

@guns guns closed this as completed Sep 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants