The officially official Devuan Forum!

You are not logged in.

#1 2020-07-07 13:46:13

john2009w
Member
Registered: 2020-07-07
Posts: 21  

Can't mount LUKS VG LVMs - Failed to activate device: File exists

Recently I installed Devuan 2 ASCII on an LVM inside a LUKS encrypted VG. I couldn't find a way to install Devuan on an existing VG in the installer. So I installed it with debootstrap. Later I upgraded to Devuan 3 Beowulf.

The problem is that Devuan boots just fine, but I can't mount any LVMs inside my VG that Devuan is booting from. I tried:

$ sudo udisksctl unlock -b /dev/sda2
Passphrase: 
Error unlocking /dev/sda2: GDBus.Error:org.freedesktop.UDisks2.Error.Failed: Error unlocking /dev/sda2: Failed to activate device: File exists
$ sudo udisksctl mount -b /dev/mapper/vg1-storage
Error looking up object for device /dev/mapper/vg1-storage
$ sudo vgscan | grep vg1
  Found volume group "vg1" using metadata type lvm2
$ sudo lvscan | grep storage
  ACTIVE            '/dev/vg1/storage' [xxx GiB] inherit

Even Thunar and pcmanfm is failing to do so, while pcmanfm just repeats the message on terminal "Error unlocking /dev/sda2: Failed to activate device: File exists" and Thunar silently fails. Tried so many config changes around the web, but didn't help.

Thinking that this is occuring due to booting and mounting from the same VG, I tried another USB device with a VG, and I think I was right. It works:

$ sudo udisksctl unlock -b /dev/sdb2
Passphrase: 
Unlocked /dev/sdb2 as /dev/dm-8.
$ sudo vgchange -ay vg32
  3 logical volume(s) in volume group "vg32" now active
$ sudo udisksctl mount -b /dev/mapper/vg32-root32
Mounted /dev/dm-10 at /media/root/root32.

I can click and mount the other LVMs from /dev/sdb2 like normal (but not /dev/sda2). So the issue is only with the VG I'm currently running Devuan from.

I am using Openbox and I start it in ~/.xinitrc with exec dbus-launch openbox-session. My user is on users sys adm disk cdrom floppy sudo audio dip www-data video plugdev groups. Other OSs like Trisquel, Void Linux and Parabola just either works out of the box or had to dbus-launch the session, but Devuan is having this issue.

Please help!!

Last edited by john2009w (2020-07-07 13:49:56)

Offline

#2 2020-07-09 10:48:31

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,486  

Re: Can't mount LUKS VG LVMs - Failed to activate device: File exists

john2009w wrote:

The problem is that Devuan boots just fine, but I can't mount any LVMs inside my VG that Devuan is booting from. I tried:

$ sudo udisksctl unlock -b /dev/sda2
Passphrase: 
Error unlocking /dev/sda2: GDBus.Error:org.freedesktop.UDisks2.Error.Failed: Error unlocking /dev/sda2: Failed to activate device: File exists
$ sudo udisksctl mount -b /dev/mapper/vg1-storage
Error looking up object for device /dev/mapper/vg1-storage
$ sudo vgscan | grep vg1
  Found volume group "vg1" using metadata type lvm2
$ sudo lvscan | grep storage
  ACTIVE            '/dev/vg1/storage' [xxx GiB] inherit

Even Thunar and pcmanfm is failing to do so, while pcmanfm just repeats the message on terminal "Error unlocking /dev/sda2: Failed to activate device: File exists" and Thunar silently fails. Tried so many config changes around the web, but didn't help.

If the system is running on a logical volume inside the luks container, then the luks container is already open and the volume group is already active. You should be able to mount whatever /dev/mapper/something that needs to be mounted. Or maybe mount /dev/vg1/storage.

Or maybe I'm missing something because I don't know udiskctl. I always use cryptsetup, vgchange and mount to manually mount encrypted lvm.

Offline

#3 2020-07-09 14:38:28

john2009w
Member
Registered: 2020-07-07
Posts: 21  

Re: Can't mount LUKS VG LVMs - Failed to activate device: File exists

fsmithred wrote:

You should be able to mount whatever /dev/mapper/something that needs to be mounted. Or maybe mount /dev/vg1/storage.

Or maybe I'm missing something because I don't know udiskctl. I always use cryptsetup, vgchange and mount to manually mount encrypted lvm.

Yes. You're right. I can mount with:

$ sudo mkdir -p /media/user/storage && sudo mount /dev/mapper/vg1-storage /media/user/storage

But I wanted it to be automatic like the other distros.

The LVMs show up on Thunar/pcmanfm's sidebar on other distros after unlocking the VG. It isn't the case on my install.

Other distros (esp. the minimal ones, like Arch, Void) have this kind of problem too. After I install gvfs, add dbus-launch and reboot usually everything works. But not happening here. udiskctl is just to show you the output, I dont use it either.

Offline

#4 2020-07-10 10:28:08

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,486  

Re: Can't mount LUKS VG LVMs - Failed to activate device: File exists

Maybe gvfs-backends is needed. It doesn't get installed with gvfs.

One way to have that volume auto-mount is to add it to /etc/fstab.

Offline

#5 2020-07-11 08:20:23

john2009w
Member
Registered: 2020-07-07
Posts: 21  

Re: Can't mount LUKS VG LVMs - Failed to activate device: File exists

I have gvfs-backends and also gvfs-fuse and udiskie in case it was needed. But not working.

Well, I am not sure if auto-mount with fstab is going to help. I don't actually want it to automount. I want to see the list of the LVMs in Thunar/pcmanfm's sidebar and want to mount it on click.

Another interesting thing I noticed is that I reinstalled with Xfce desktop, and this time stayed with Devuan 2.1. Now if I click on the VG that I have installed Devuan on, the behavior is same as before. It doesn't show LVMs. But when I plug in the USB drive with VG, and unlock it, it shows LVMs from both internal VG and usb VG!! Strange!

As much as I've experimented with config changes, I am suspecting some udisks or polkit config to be missing or wrong. It works, but not on the VGs that are already unlocked and used by system, atleast not before some other device triggers something that makes it work somehow. (probably a bug?)

[I'll probably upgrade to 3 to see if that behavior stays the same and edit this] EDIT: It got worse on 3

Last edited by john2009w (2020-07-11 12:17:55)

Offline

#6 2020-07-11 11:12:12

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,486  

Re: Can't mount LUKS VG LVMs - Failed to activate device: File exists

In xfce, there's a setting to allow removable drives to show up on the desktop. It used to be that the setting affected only removable drives, but it no longer does that. I think the change occurred with xfce 4.12, but I'm not certain.

Internal drives will now show up along with the removable drives, unless they are listed in fstab. (I listed a few of mine and gave them 'none' for a mount point just to get them off the desktop.) It's the same in beowulf (3.0).

Offline

#7 2020-07-11 12:16:05

john2009w
Member
Registered: 2020-07-07
Posts: 21  

Re: Can't mount LUKS VG LVMs - Failed to activate device: File exists

I tried some mounting options from Thunar - Preferences - Advanced tab - Volume Management - Configure, checked 3 checkboxes under Removable Storage. But it didn't solve the problem.

I have "defaults" set for my / and swap on my fstab. Can you suggest any options that I can try?

About trying the upgrade... upgrading to Devuan 3 didn't help. It worsened. Now unlocking the usb VG shows LVMs from neither of the VGs.

I think if I reinstall, I should stick with 2. I like Devuan, but there are more issues than I expected in a stable release. I had network-manager and openvpn installed. They are uninstalled by themselves after the upgrade. When I try to install network-manager it complains "network-manager : Depends: libpam-systemd". Xfce's focus started following the mouse cursor. I had to change it to click manually.

Offline

#8 2020-07-11 13:06:46

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,486  

Re: Can't mount LUKS VG LVMs - Failed to activate device: File exists

If you want user to be able to mount a logical volume that's part of an active volume group, you should be able to add a line to fstab for that lv. Something like:

/dev/mapper/vg0-mylv  /some/mountpoint  ext4  defaults,noauto,user   0   0

Then the user can either mount it in terminal, or you could put the mount and unmount commands into panel buttons or a menu item.

Offline

#9 2020-07-11 13:36:08

john2009w
Member
Registered: 2020-07-07
Posts: 21  

Re: Can't mount LUKS VG LVMs - Failed to activate device: File exists

Thanks, I'll test that.

But even if it works, it would still mean that I'd have to update them when I add/remove/change my lvms. Plus, it wouldn't solve not showing up VG in the USB drive (on beowulf). I think listing all the possible LVMs in fstab won't be practical for me in the long run, as I have lots of other drives with VGs and lots of LVMs in them. Finding out names, mounting them one by one is not very user friendly as well.

First I thought it was a non-systemd issue. But Void Linux (runit init) can list LVMs just fine. So I guess it can be done on Devuan as well. My best guess is that there are some config that is not letting it work. Esp. seeing that it works partially on Devuan 2 makes me think I'm right.

Offline

#10 2020-07-11 15:42:32

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,486  

Re: Can't mount LUKS VG LVMs - Failed to activate device: File exists

Depends: libpam-systemd". Xfce's focus started following the mouse cursor. I had to change it to click manually.

Forgot to comment on this. Install libpam-elogind to satisfy the dependency on libpam-systemd. network-manager works in beowulf.

I was never able to list and mount lvm with gui in debian. Plain encrypted partitions, yes, but not lvm. Find out how those others do it, and maybe it can be replicated. Maybe something is missing.

Offline

#11 2020-07-14 19:00:43

john2009w
Member
Registered: 2020-07-07
Posts: 21  

Re: Can't mount LUKS VG LVMs - Failed to activate device: File exists

Install libpam-elogind to satisfy the dependency on libpam-systemd. network-manager works in beowulf.

Thanks, it worked. Also installed `network-manager-gnome` for nm-applet. Working as expected.

OK, so I reached a temporary workaround. I reinstalled Chimaera/testing this time and did not install Xfce to test everything from ground up. I have installed thunar, thunar-volman, gvfs, ran `update-initramfs -u -k all` just in case. I use `exec dbus-launch openbox-session` as before.

Typically, when unlocking an encrypted VG, it asks for LUKS password, then user password. I was looking for a config to skip the user password. I had many failed attempts but luckily found this answer. It said that if the output of pkaction --version is less than `0.106`, then policykit's .rules files won't work. Devuan is still at `0.105`, so .pkla file should be used. I created /etc/polkit-1/localauthority/50-local.d/60-udisks.pkla with:

[udisks]
Identity=unix-group:plugdev
Action=org.freedesktop.udisks.*;org.freedesktop.udisks2.*
ResultAny=yes
ResultInactive=yes
ResultActive=yes

For this to work I had to make sure I was in `plugdev` group: sudo usermod -aG plugdev $USER and then reboot for it to take effect.
Now we should be able to mount things without entering our user password. I could probably setup a polkit agent, but this is easier for me now to test around.

I used `lvscan` and found that my VG+LVMs were active already, but they weren't showing up on sidebar, even the external ones (like I reported before, external VGs are affected in Devuan v3 and above but not v2, and VGs booted from are affected in v2-4). Surprizingly when I ran vgchange -ay <vg name>, they came up on sidebar!

But activating the VG I'm currently running Devuan from caused an error telling me that 2 of the lvms are mounted. So I figured I would have to activate LVMs individually with `lvchange`: sudo lvchange -an /dev/<vg name>/<lvm name> && sudo lvchange -ay /dev/<vg name>/<lvm name> for all of them. I don't know why it needs `-an` first, but it works. I wrote a script for running this command for all the VG-LVMs automatically:

#!/bin/bash

# reactivate-lvms.sh
# Loops through LVMs and re-activate them in order for them to appear
# in file explorer sidebars on some versions of Devuan
if [ -z $(command -v lvscan) ];then echo "Run as root. e.g. sudo $0"; exit 1; fi
lvscan | while read lv_line ; do
	LV=`echo $lv_line | awk '{print $2}'`
	# Remove quotes
	LV="${LV%\'}"
	LV="${LV#\'}"
	echo "-- Re-activating $LV..."
	lvchange -an $LV
	lvchange -ay $LV
done

Plus, this should take care for VGs/LVMs both in internal and external media. Theoretically it should work for LVMs even without VGs.

I was never able to list and mount lvm with gui in debian. Plain encrypted partitions, yes, but not lvm. Find out how those others do it, and maybe it can be replicated. Maybe something is missing.

I'm not sure where the issue is... udev, udisks or somewhere else. I'm not that familiar with how these things work. I am looking into udev rules first. I have already tried to use udev rules from Trisquel, but failed. Using rules from v2 raises dmsetup initramfs error. I'm not even a noob when it comes to udev. So an experienced hand would be helpful. Please let me know if I can contact someone.

Offline

Board footer