I have an external HDD with one logical volume perfectly working that can be mounted with:
udisksctl mount -b /dev/mapper/wd0hdd-wd0
It will create a new directory under
/media/username/wd which is the expected behavior since
wd is the label of my disk
wd0 the name of my logical volume and
username my username.
However, I would like that this logical volume could be mounted automatically (without typing this command) when I plug the external HDD in, just like udisks2 does usually with standard linux partition (non-lvm). [Problem1]
Besides, I have noticed that
/media/username/wd belongs to root:root with 755 rights which is problematic since I cannot create files/directory at the root of my partition as a normal user. For standard linux partition, the directory created belongs to
username which is expected [Problem2]
Finally, Nautilus does not display the volume in the left pane as usual for standard linux partition instead it is in
Other Locations. However, the gnome-extension
Place Status Indicator list the new
wd correctly below my other drives. [Problem3]
Find a way to tell udisks2 to consider a given logical volume to be auto mounted as a removable media.
Setup an external drive with a single logical partition:
sudo lvmdiskscan # Suppose sdc is the candidate sudo pvcreate /dev/sdc sudo vgcreate wd0hdd /dev/sdc1 sudo lvcreate -l 100%FREE -n wd0 wd0hdd sudo mkfs.ext4 /dev/wd0hdd/wd0
[Facultative] use Gnome-Disk to change the label of the disk to
Reboot Ubuntu and see what happens in nautilus and in
- disk plugged-in during boot
- disk plugged-in after startup has completed
Tell me what could be useful here.
I tried to find something useful in the log to help track the problem, there is nothing relevant displayed by journactl however there might be some hints about what is going wrong thanks to
udisksctl monitor right after I mount the device with
udisksctl mount -b /dev/mapper/wd0hdd/wd0
17:49:54.019: Added /org/freedesktop/UDisks2/jobs/2 org.freedesktop.UDisks2.Job: Bytes: 0 Cancelable: true ExpectedEndTime: 0 Objects: ['/org/freedesktop/UDisks2/block_devices/dm_2d5'] Operation: filesystem-mount Progress: 0.0 ProgressValid: false Rate: 0 StartTime: 1553186994019094 StartedByUID: 0 17:49:54.095: /org/freedesktop/UDisks2/jobs/2: org.freedesktop.UDisks2.Job::Completed (true, '') 17:49:54.095: Removed /org/freedesktop/UDisks2/jobs/2 17:49:54.140: /org/freedesktop/UDisks2/block_devices/dm_2d5: org.freedesktop.UDisks2.Filesystem: Properties Changed MountPoints: /media/mil/wd1 17:49:54.141: /org/freedesktop/UDisks2/block_devices/dm_2d5: org.freedesktop.UDisks2.Block: Properties Changed UserspaceMountOptions: uhelper=udisks2 17:49:54.141: /org/freedesktop/UDisks2/block_devices/sdd: org.freedesktop.UDisks2.PartitionTable: Properties Changed Partitions: ['/org/freedesktop/UDisks2/block_devices/sdd1']
I don't know if this
UserspaceMountOptions: uhelper=udisks2 could help me if I manage to change these mount options.
HintAuto property and
HintAuto is a property that can be overridden thanks to
UDISKS_AUTO in udisks2. I spotted that the physical partition
udisksctl info -b /dev/sdc1 | grep HintAuto ->
HintAuto: true. However,
HintAuto is false for the logical device
udisksctl info -b /dev/mapper/wd0hdd-wd0 | grep HintAuto ->
I managed to override the value of HintAuto for the logical volume thanks to a udev rules as discussed in Automount LVM logical volume with a udev rule and udisks2 however it has not solved my problem since
udisks2 still does not automount the partition.
/etc/fstab either by editing directly or using gnome-disk-utility, it just solves the problem to auto-mount at startup but not if I plug the disk latter. Also, it does not solve Problem 2 nor Problem 3 (I thought x-gvfs-show would solve but no) and as far as I know
/etc/fstab is for static drive and udisks2 is for all kind of removable drives, so I would prefer a udisks2 solution.
Use awesome shell script started by some daemon detecting when the disk is plugged. Huum well maybe if I have no other choice but I did not find any script solving all the three problems mentioned above. Also I still believe the work could be done by udisks2.
Tell udisks2 to auto mount all the logical volume. That would be undesired since some of my logical volume are other linux system. Anyway I did not find any way to do that.
People could ask:
- Why a single LVM partition on the whole disk instead of a single standard partition ? KISS !
- Yes you are right ! However what I try to achieve here is just a simpler scenario of what I want to achieve in the end. I have another disk on which I installed a small ESP partition to multi-boot in EFI mode and another LVM physical volume containing two logical volumes with two different linux and a third huge logical volume for media data storage. Most of the time this disk is just plugged in my personal computer, so I only use the media data storage partition for backup and music however sometimes I go to other places without my computer and only bring my disk, thus I can boot with my own linux, emacs and music player configured as I like and start working in a pleasant environment. In this context, LVM is really useful for this setup to easily resize and manage encryption.