storaged-project / udisks

The UDisks project provides a daemon, tools and libraries to access and manipulate disks, storage devices and technologies.
https://storaged.org/doc/udisks2-api/latest/
Other
349 stars 142 forks source link

Unable to mount LUKS partition: "Error looking up object for device..." #925

Closed gagara closed 2 years ago

gagara commented 3 years ago

I have LUKS encrypted partition in a file. It is exposed to the system through e.g. /dev/loop1 device I can decrypt it using udisks

$ udisksctl unlock -b /dev/loop1
Passphrase: 
Unlocked /dev/loop1 as /dev/dm-0.

$ ls -l /dev/dm-0
brw-rw---- 1 root disk 253, 0 Oct  4 12:25 /dev/dm-0
$ ls -l /dev/mapper/
total 0
crw------- 1 root root  10, 236 Oct  3 18:16 control
brw------- 1 root root 253,   0 Oct  4 12:25 luks-04e7f218-94ae-481e-b448-d61065e112c7

# blkid -o udev -p /dev/mapper/luks-04e7f218-94ae-481e-b448-d61065e112c7 
ID_FS_UUID=31765941-1c02-4e02-bebb-527e6f41b5c1
ID_FS_UUID_ENC=31765941-1c02-4e02-bebb-527e6f41b5c1
ID_FS_VERSION=1.0
ID_FS_BLOCK_SIZE=1024
ID_FS_TYPE=ext4
ID_FS_USAGE=filesystem

I can mount it using usual mount /dev/mapper/luks-04e7f218-94ae-481e-b448-d61065e112c7 /some/where with no problem. But when I try to mount it using udisksctl I got:

$ udisksctl mount -b /dev/dm-0
Object /org/freedesktop/UDisks2/block_devices/dm_2d0 is not a mountable filesystem.
$ udisksctl mount -b /dev/mapper/luks-04e7f218-94ae-481e-b448-d61065e112c7
Error looking up object for device /dev/mapper/luks-04e7f218-94ae-481e-b448-d61065e112c7

Same problem if I unlock it with cryptsetup udisks version 2.9.3

vojtechtrefny commented 3 years ago

What does udisksctl info -b /dev/dm-0 shows about the device?

gagara commented 3 years ago
$ udisksctl info -b /dev/dm-0
/org/freedesktop/UDisks2/block_devices/dm_2d0:
  org.freedesktop.UDisks2.Block:
    Configuration:              []
    CryptoBackingDevice:        '/org/freedesktop/UDisks2/block_devices/loop1'
    Device:                     /dev/dm-0
    DeviceNumber:               64768
    Drive:                      '/'
    HintAuto:                   false
    HintIconName:               
    HintIgnore:                 false
    HintName:                   
    HintPartitionable:          false
    HintSymbolicIconName:       
    HintSystem:                 true
    Id:                         
    IdLabel:                    
    IdType:                     
    IdUUID:                     
    IdUsage:                    
    IdVersion:                  
    MDRaid:                     '/'
    MDRaidMember:               '/'
    PreferredDevice:            /dev/dm-0
    ReadOnly:                   false
    Size:                       35651584
    Symlinks:                   
    UserspaceMountOptions:      
tbzatek commented 3 years ago

Could you also post output of udevadm info /dev/dm-0 please? Does an explicit udevadm trigger make any difference?

gagara commented 3 years ago
# udevadm info /dev/dm-0
P: /devices/virtual/block/dm-0
N: dm-0
E: DEVNAME=/dev/dm-0
E: DEVPATH=/devices/virtual/block/dm-0
E: DEVTYPE=disk
E: MAJOR=253
E: MINOR=0
E: SUBSYSTEM=block

udevadm trigger doesn't help either. Here are udev events captured when partition is unlocked:

# udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[92939.200972] add      /devices/virtual/bdi/253:0 (bdi)
KERNEL[92939.201001] add      /devices/virtual/block/dm-0 (block)
KERNEL[92939.201267] change   /devices/virtual/block/dm-0 (block)
KERNEL[92939.212501] change   /devices/virtual/block/loop1 (block)
UDEV  [92939.213067] add      /devices/virtual/bdi/253:0 (bdi)
UDEV  [92939.213319] add      /devices/virtual/block/dm-0 (block)
UDEV  [92939.213701] change   /devices/virtual/block/dm-0 (block)
UDEV  [92939.383897] change   /devices/virtual/block/loop1 (block)
gagara commented 3 years ago

Can it be connected with kernel version? I had it working well some time ago. Now if I even downgrade udisks to e.g. 2.9.0 it still doesn't work. My current kernel version is 5.14.9

gagara commented 2 years ago

It appears that there was a problem with cryptsetup. This issue can be closed. Thanks for support.

tbzatek commented 2 years ago

OK, thanks for your feedback. Feel free to reopen should the issue reappear.