Automount LVM logical volume with a udev rule and udisks2create raid1 from existing lvm local volumeWhy is this udev remove rule not working?confused about udevadm usagePersistent names for physical USB portsPermissions incorrect on symlink to /dev/ttyACM0 created by udev ruleUdev Rule to discern 2 identical webcams on Linuxudev high cpu problemudevadm rule works using “udevadm test” but not with “udevadm trigger”LVM: PV missing after rebootPossible to force udev to create specific device event number, or change device event numbers

Would a virus be able to change eye and hair colour?

Proof of work - lottery approach

Method to test if a number is a perfect power?

Lay out the Carpet

How do I find the solutions of the following equation?

How can I kill an app using Terminal?

Go Pregnant or Go Home

Hostile work environment after whistle-blowing on coworker and our boss. What do I do?

Sequence of Tenses: Translating the subjunctive

How to check is there any negative term in a large list?

How do I rename a Linux host without needing to reboot for the rename to take effect?

Is there a good way to store credentials outside of a password manager?

Is `x >> pure y` equivalent to `liftM (const y) x`

Why escape if the_content isnt?

Did the DC-9 ever use RATO in revenue service?

How can a function with a hole (removable discontinuity) equal a function with no hole?

Where does the Z80 processor start executing from?

What is paid subscription needed for in Mortal Kombat 11?

Did Dumbledore lie to Harry about how long he had James Potter's invisibility cloak when he was examining it? If so, why?

Term for the "extreme-extension" version of a straw man fallacy?

Purchasing a ticket for someone else in another country?

Would this custom Sorcerer variant that can only learn any verbal-component-only spell be unbalanced?

Would a high gravity rocky planet be guaranteed to have an atmosphere?

CREATE opcode: what does it really do?



Automount LVM logical volume with a udev rule and udisks2


create raid1 from existing lvm local volumeWhy is this udev remove rule not working?confused about udevadm usagePersistent names for physical USB portsPermissions incorrect on symlink to /dev/ttyACM0 created by udev ruleUdev Rule to discern 2 identical webcams on Linuxudev high cpu problemudevadm rule works using “udevadm test” but not with “udevadm trigger”LVM: PV missing after rebootPossible to force udev to create specific device event number, or change device event numbers













1















I want to automatically mount an LVM logical volume on an external drive as soon as it is connected to the computer.



The solution I choose here is to use udev to detect plug in events and udisks2 to mount the partition. For other alternatives see a more generic approach of logical volume auto-mounting



I am asking for help to know if my approach of udev and udisks2 is doomed or if it is my achievement that failed. The following is a brief sum-up of all my attempt.



The simplest udev rule that does not work



To my mind udev rules seems to be appropriate to assert drive presence and set UDISKS_AUTO so I created the following rule in its own file /etc/udev/rules.d/61-lvm-automount-lv.rules



SUBSYSTEM=="block"
, ENVID_FS_UUID=="b32cefaa-041e-4ef7-8c82-fe53739aefff"
, ENVUDISKS_AUTO="1"


Then I reload the rules sudo udevadm control --reload (or even better restart my computer), check that the rule is read and UDISKS_AUTO is set to one for the given partition sudo udevadm test /sys/devices/virtual/block/dm-1 and confirm that in the end of the output I can see UDISKS_AUTO=1



However, when I unlplug/plug the external disk the partition is not mounted automatically.



I tried to find the maximum of information about what's going wrong thanks to journactl, udisksctl monitor but the only useful messages was from udevadm monitor --environment --udev showing that:



UDEV [3897.839040] change /devices/virtual/block/dm-1 (block)
.ID_FS_TYPE_NEW=ext4
ACTION=change
DEVLINKS=/dev/mapper/wdhdd0-wd0 /dev/disk/by-uuid/b32cefaa-041e-4ef7-8c82-fe53739aefff /dev/disk/by-label/wd /dev/disk/by-id/dm-name-wdhdd0-wd0 /dev/wdhdd0/wd0 /dev/disk/by-id/dm-uuid-LVM-hwQrCjWSOCCGpJqcdPv3NHaP3OOK6kFQj2Y6j3X51A69FEYNQeHtt8wVnVnlb93N
DEVNAME=/dev/dm-1
DEVPATH=/devices/virtual/block/dm-1
DEVTYPE=disk
DM_ACTIVATION=1
DM_COOKIE=6324838
DM_LV_LAYER=
DM_LV_NAME=wd0
DM_NAME=wdhdd0-wd0
DM_SUSPENDED=0
DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG=1
DM_UDEV_PRIMARY_SOURCE_FLAG=1
DM_UDEV_RULES=1
DM_UDEV_RULES_VSN=2
DM_UUID=LVM-hwQrCjWSOCCGpJqcdPv3NHaP3OOK6kFQj2Y6j3X51A69FEYNQeHtt8wVnVnlb93N
DM_VG_NAME=wdhdd0
ID_FS_LABEL=wd
ID_FS_LABEL_ENC=wd
ID_FS_TYPE=ext4
ID_FS_USAGE=filesystem
ID_FS_UUID=b32cefaa-041e-4ef7-8c82-fe53739aefff
ID_FS_UUID_ENC=b32cefaa-041e-4ef7-8c82-fe53739aefff
ID_FS_VERSION=1.0
MAJOR=253
MINOR=1
SEQNUM=6641
SUBSYSTEM=block
TAGS=:systemd:
UDISKS_AUTO=1
USEC_INITIALIZED=5756122


So it seems that udisks2 should automatically mount this partition thanks to UDISKS_AUTO=1 but no. However, I can still execute udisksctl mount -b /dev/wdhdd0/wd0 and now the partition is mounted manually.



Other rules that does not work



Changing the value of UDISKS_SYSTEM



SUBSYSTEM=="block", ENVID_FS_UUID=="b32cefaa-041e-4ef7-8c82-fe53739aefff", ENVUDISKS_SYSTEM="0", ENVUDISKS_AUTO="1"


Add a rule to unignore the physical volume containing the logical volume with ENVUDISKS_IGNORE="0". I undestand perfectly why physical volume has to be hidden and not mounted in the filesystem but I though that maybe the logical volume inherit some properties.



Set my simple rule earlier in the order of the udev files to be loaded first. It requires adding IMPORTbuiltin="blkid" in the begining of the rule for those who wants to try. Conversely, I tried to put the simple rule in the end. It only requires to change the number in the name of the file 61-lvm-automount-lv.rules.



Goal



Ultimately, I would like that a given logical volume could be automatically mounted by my system exactly as standard (non-lvm) partitions are usually mounted. I am open to any suggestion on the best way to do that. I oriented this question with udev and udisks2 because it seems to do a perfect job for standard partition under Ubuntu, so I would like to achieve the same thing for LVM.



Edit



my /var/log/syslog right after plugging in the disk:



[12766.403419] usb 1-1: new high-speed USB device number 9 using xhci_hcd
[12766.553014] usb 1-1: New USB device found, idVendor=1058, idProduct=1003
[12766.553020] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[12766.553024] usb 1-1: Product: External HDD
[12766.553029] usb 1-1: Manufacturer: Western Digital
[12766.553032] usb 1-1: SerialNumber: 57442D574D41565531333130343938
[12766.553817] usb-storage 1-1:1.0: USB Mass Storage device detected
[12766.554314] scsi host5: usb-storage 1-1:1.0
mtp-probe: checking bus 1, device 9: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1"
mtp-probe: bus: 1, device: 9 was not an MTP device
upowerd[2160]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0
upowerd[2160]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1
kernel: [12767.564246] scsi 5:0:0:0: Direct-Access WD 15EARS External 1.75 PQ: 0 ANSI: 4
kernel: [12767.565075] sd 5:0:0:0: Attached scsi generic sg1 type 0
kernel: [12767.565196] sd 5:0:0:0: [sdc] 2930277168 512-byte logical blocks: (1.50 TB/1.36 TiB)
kernel: [12767.565482] sd 5:0:0:0: [sdc] Write Protect is off
kernel: [12767.565487] sd 5:0:0:0: [sdc] Mode Sense: 23 00 00 00
kernel: [12767.565740] sd 5:0:0:0: [sdc] No Caching mode page found
kernel: [12767.565749] sd 5:0:0:0: [sdc] Assuming drive cache: write through
kernel: [12767.620230] sdc: sdc1
kernel: [12767.621669] sd 5:0:0:0: [sdc] Attached SCSI disk
systemd[1]: Starting LVM2 PV scan on device 8:33...
lvm[31988]: 1 logical volume(s) in volume group "wdhdd0" now active
systemd[1]: Started LVM2 PV scan on device 8:33.









share|improve this question









New contributor




Émilien is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • This should work automatically. As far as I know, there is nothing special about LVs in this context - they are just another block device. But the place to look for problems/error messages are the system logs in /var/log, specifically message and syslog. What do those say?

    – Faheem Mitha
    yesterday







  • 1





    I'd also recommend checking out udiskie. That's what I use. It's packaged for Debian, and thus for Ubuntu. And it sounds like you are using Ubuntu.

    – Faheem Mitha
    yesterday











  • Yes thanks for your advice I'll edit the main post with the content of syslog right after the disk is plugged in. Also I have seen udiskie while I was browsing the documentation and all the help I could find about udisks and udev, but I hav not tried udiskie yet so I'll try that latter and report my experience.

    – Émilien
    yesterday












  • However I have no /var/log/messages or anything similar maybe it has been removed from Ubuntu 18.04

    – Émilien
    yesterday






  • 1





    Check /var/log/syslog.

    – Faheem Mitha
    yesterday















1















I want to automatically mount an LVM logical volume on an external drive as soon as it is connected to the computer.



The solution I choose here is to use udev to detect plug in events and udisks2 to mount the partition. For other alternatives see a more generic approach of logical volume auto-mounting



I am asking for help to know if my approach of udev and udisks2 is doomed or if it is my achievement that failed. The following is a brief sum-up of all my attempt.



The simplest udev rule that does not work



To my mind udev rules seems to be appropriate to assert drive presence and set UDISKS_AUTO so I created the following rule in its own file /etc/udev/rules.d/61-lvm-automount-lv.rules



SUBSYSTEM=="block"
, ENVID_FS_UUID=="b32cefaa-041e-4ef7-8c82-fe53739aefff"
, ENVUDISKS_AUTO="1"


Then I reload the rules sudo udevadm control --reload (or even better restart my computer), check that the rule is read and UDISKS_AUTO is set to one for the given partition sudo udevadm test /sys/devices/virtual/block/dm-1 and confirm that in the end of the output I can see UDISKS_AUTO=1



However, when I unlplug/plug the external disk the partition is not mounted automatically.



I tried to find the maximum of information about what's going wrong thanks to journactl, udisksctl monitor but the only useful messages was from udevadm monitor --environment --udev showing that:



UDEV [3897.839040] change /devices/virtual/block/dm-1 (block)
.ID_FS_TYPE_NEW=ext4
ACTION=change
DEVLINKS=/dev/mapper/wdhdd0-wd0 /dev/disk/by-uuid/b32cefaa-041e-4ef7-8c82-fe53739aefff /dev/disk/by-label/wd /dev/disk/by-id/dm-name-wdhdd0-wd0 /dev/wdhdd0/wd0 /dev/disk/by-id/dm-uuid-LVM-hwQrCjWSOCCGpJqcdPv3NHaP3OOK6kFQj2Y6j3X51A69FEYNQeHtt8wVnVnlb93N
DEVNAME=/dev/dm-1
DEVPATH=/devices/virtual/block/dm-1
DEVTYPE=disk
DM_ACTIVATION=1
DM_COOKIE=6324838
DM_LV_LAYER=
DM_LV_NAME=wd0
DM_NAME=wdhdd0-wd0
DM_SUSPENDED=0
DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG=1
DM_UDEV_PRIMARY_SOURCE_FLAG=1
DM_UDEV_RULES=1
DM_UDEV_RULES_VSN=2
DM_UUID=LVM-hwQrCjWSOCCGpJqcdPv3NHaP3OOK6kFQj2Y6j3X51A69FEYNQeHtt8wVnVnlb93N
DM_VG_NAME=wdhdd0
ID_FS_LABEL=wd
ID_FS_LABEL_ENC=wd
ID_FS_TYPE=ext4
ID_FS_USAGE=filesystem
ID_FS_UUID=b32cefaa-041e-4ef7-8c82-fe53739aefff
ID_FS_UUID_ENC=b32cefaa-041e-4ef7-8c82-fe53739aefff
ID_FS_VERSION=1.0
MAJOR=253
MINOR=1
SEQNUM=6641
SUBSYSTEM=block
TAGS=:systemd:
UDISKS_AUTO=1
USEC_INITIALIZED=5756122


So it seems that udisks2 should automatically mount this partition thanks to UDISKS_AUTO=1 but no. However, I can still execute udisksctl mount -b /dev/wdhdd0/wd0 and now the partition is mounted manually.



Other rules that does not work



Changing the value of UDISKS_SYSTEM



SUBSYSTEM=="block", ENVID_FS_UUID=="b32cefaa-041e-4ef7-8c82-fe53739aefff", ENVUDISKS_SYSTEM="0", ENVUDISKS_AUTO="1"


Add a rule to unignore the physical volume containing the logical volume with ENVUDISKS_IGNORE="0". I undestand perfectly why physical volume has to be hidden and not mounted in the filesystem but I though that maybe the logical volume inherit some properties.



Set my simple rule earlier in the order of the udev files to be loaded first. It requires adding IMPORTbuiltin="blkid" in the begining of the rule for those who wants to try. Conversely, I tried to put the simple rule in the end. It only requires to change the number in the name of the file 61-lvm-automount-lv.rules.



Goal



Ultimately, I would like that a given logical volume could be automatically mounted by my system exactly as standard (non-lvm) partitions are usually mounted. I am open to any suggestion on the best way to do that. I oriented this question with udev and udisks2 because it seems to do a perfect job for standard partition under Ubuntu, so I would like to achieve the same thing for LVM.



Edit



my /var/log/syslog right after plugging in the disk:



[12766.403419] usb 1-1: new high-speed USB device number 9 using xhci_hcd
[12766.553014] usb 1-1: New USB device found, idVendor=1058, idProduct=1003
[12766.553020] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[12766.553024] usb 1-1: Product: External HDD
[12766.553029] usb 1-1: Manufacturer: Western Digital
[12766.553032] usb 1-1: SerialNumber: 57442D574D41565531333130343938
[12766.553817] usb-storage 1-1:1.0: USB Mass Storage device detected
[12766.554314] scsi host5: usb-storage 1-1:1.0
mtp-probe: checking bus 1, device 9: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1"
mtp-probe: bus: 1, device: 9 was not an MTP device
upowerd[2160]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0
upowerd[2160]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1
kernel: [12767.564246] scsi 5:0:0:0: Direct-Access WD 15EARS External 1.75 PQ: 0 ANSI: 4
kernel: [12767.565075] sd 5:0:0:0: Attached scsi generic sg1 type 0
kernel: [12767.565196] sd 5:0:0:0: [sdc] 2930277168 512-byte logical blocks: (1.50 TB/1.36 TiB)
kernel: [12767.565482] sd 5:0:0:0: [sdc] Write Protect is off
kernel: [12767.565487] sd 5:0:0:0: [sdc] Mode Sense: 23 00 00 00
kernel: [12767.565740] sd 5:0:0:0: [sdc] No Caching mode page found
kernel: [12767.565749] sd 5:0:0:0: [sdc] Assuming drive cache: write through
kernel: [12767.620230] sdc: sdc1
kernel: [12767.621669] sd 5:0:0:0: [sdc] Attached SCSI disk
systemd[1]: Starting LVM2 PV scan on device 8:33...
lvm[31988]: 1 logical volume(s) in volume group "wdhdd0" now active
systemd[1]: Started LVM2 PV scan on device 8:33.









share|improve this question









New contributor




Émilien is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • This should work automatically. As far as I know, there is nothing special about LVs in this context - they are just another block device. But the place to look for problems/error messages are the system logs in /var/log, specifically message and syslog. What do those say?

    – Faheem Mitha
    yesterday







  • 1





    I'd also recommend checking out udiskie. That's what I use. It's packaged for Debian, and thus for Ubuntu. And it sounds like you are using Ubuntu.

    – Faheem Mitha
    yesterday











  • Yes thanks for your advice I'll edit the main post with the content of syslog right after the disk is plugged in. Also I have seen udiskie while I was browsing the documentation and all the help I could find about udisks and udev, but I hav not tried udiskie yet so I'll try that latter and report my experience.

    – Émilien
    yesterday












  • However I have no /var/log/messages or anything similar maybe it has been removed from Ubuntu 18.04

    – Émilien
    yesterday






  • 1





    Check /var/log/syslog.

    – Faheem Mitha
    yesterday













1












1








1








I want to automatically mount an LVM logical volume on an external drive as soon as it is connected to the computer.



The solution I choose here is to use udev to detect plug in events and udisks2 to mount the partition. For other alternatives see a more generic approach of logical volume auto-mounting



I am asking for help to know if my approach of udev and udisks2 is doomed or if it is my achievement that failed. The following is a brief sum-up of all my attempt.



The simplest udev rule that does not work



To my mind udev rules seems to be appropriate to assert drive presence and set UDISKS_AUTO so I created the following rule in its own file /etc/udev/rules.d/61-lvm-automount-lv.rules



SUBSYSTEM=="block"
, ENVID_FS_UUID=="b32cefaa-041e-4ef7-8c82-fe53739aefff"
, ENVUDISKS_AUTO="1"


Then I reload the rules sudo udevadm control --reload (or even better restart my computer), check that the rule is read and UDISKS_AUTO is set to one for the given partition sudo udevadm test /sys/devices/virtual/block/dm-1 and confirm that in the end of the output I can see UDISKS_AUTO=1



However, when I unlplug/plug the external disk the partition is not mounted automatically.



I tried to find the maximum of information about what's going wrong thanks to journactl, udisksctl monitor but the only useful messages was from udevadm monitor --environment --udev showing that:



UDEV [3897.839040] change /devices/virtual/block/dm-1 (block)
.ID_FS_TYPE_NEW=ext4
ACTION=change
DEVLINKS=/dev/mapper/wdhdd0-wd0 /dev/disk/by-uuid/b32cefaa-041e-4ef7-8c82-fe53739aefff /dev/disk/by-label/wd /dev/disk/by-id/dm-name-wdhdd0-wd0 /dev/wdhdd0/wd0 /dev/disk/by-id/dm-uuid-LVM-hwQrCjWSOCCGpJqcdPv3NHaP3OOK6kFQj2Y6j3X51A69FEYNQeHtt8wVnVnlb93N
DEVNAME=/dev/dm-1
DEVPATH=/devices/virtual/block/dm-1
DEVTYPE=disk
DM_ACTIVATION=1
DM_COOKIE=6324838
DM_LV_LAYER=
DM_LV_NAME=wd0
DM_NAME=wdhdd0-wd0
DM_SUSPENDED=0
DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG=1
DM_UDEV_PRIMARY_SOURCE_FLAG=1
DM_UDEV_RULES=1
DM_UDEV_RULES_VSN=2
DM_UUID=LVM-hwQrCjWSOCCGpJqcdPv3NHaP3OOK6kFQj2Y6j3X51A69FEYNQeHtt8wVnVnlb93N
DM_VG_NAME=wdhdd0
ID_FS_LABEL=wd
ID_FS_LABEL_ENC=wd
ID_FS_TYPE=ext4
ID_FS_USAGE=filesystem
ID_FS_UUID=b32cefaa-041e-4ef7-8c82-fe53739aefff
ID_FS_UUID_ENC=b32cefaa-041e-4ef7-8c82-fe53739aefff
ID_FS_VERSION=1.0
MAJOR=253
MINOR=1
SEQNUM=6641
SUBSYSTEM=block
TAGS=:systemd:
UDISKS_AUTO=1
USEC_INITIALIZED=5756122


So it seems that udisks2 should automatically mount this partition thanks to UDISKS_AUTO=1 but no. However, I can still execute udisksctl mount -b /dev/wdhdd0/wd0 and now the partition is mounted manually.



Other rules that does not work



Changing the value of UDISKS_SYSTEM



SUBSYSTEM=="block", ENVID_FS_UUID=="b32cefaa-041e-4ef7-8c82-fe53739aefff", ENVUDISKS_SYSTEM="0", ENVUDISKS_AUTO="1"


Add a rule to unignore the physical volume containing the logical volume with ENVUDISKS_IGNORE="0". I undestand perfectly why physical volume has to be hidden and not mounted in the filesystem but I though that maybe the logical volume inherit some properties.



Set my simple rule earlier in the order of the udev files to be loaded first. It requires adding IMPORTbuiltin="blkid" in the begining of the rule for those who wants to try. Conversely, I tried to put the simple rule in the end. It only requires to change the number in the name of the file 61-lvm-automount-lv.rules.



Goal



Ultimately, I would like that a given logical volume could be automatically mounted by my system exactly as standard (non-lvm) partitions are usually mounted. I am open to any suggestion on the best way to do that. I oriented this question with udev and udisks2 because it seems to do a perfect job for standard partition under Ubuntu, so I would like to achieve the same thing for LVM.



Edit



my /var/log/syslog right after plugging in the disk:



[12766.403419] usb 1-1: new high-speed USB device number 9 using xhci_hcd
[12766.553014] usb 1-1: New USB device found, idVendor=1058, idProduct=1003
[12766.553020] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[12766.553024] usb 1-1: Product: External HDD
[12766.553029] usb 1-1: Manufacturer: Western Digital
[12766.553032] usb 1-1: SerialNumber: 57442D574D41565531333130343938
[12766.553817] usb-storage 1-1:1.0: USB Mass Storage device detected
[12766.554314] scsi host5: usb-storage 1-1:1.0
mtp-probe: checking bus 1, device 9: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1"
mtp-probe: bus: 1, device: 9 was not an MTP device
upowerd[2160]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0
upowerd[2160]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1
kernel: [12767.564246] scsi 5:0:0:0: Direct-Access WD 15EARS External 1.75 PQ: 0 ANSI: 4
kernel: [12767.565075] sd 5:0:0:0: Attached scsi generic sg1 type 0
kernel: [12767.565196] sd 5:0:0:0: [sdc] 2930277168 512-byte logical blocks: (1.50 TB/1.36 TiB)
kernel: [12767.565482] sd 5:0:0:0: [sdc] Write Protect is off
kernel: [12767.565487] sd 5:0:0:0: [sdc] Mode Sense: 23 00 00 00
kernel: [12767.565740] sd 5:0:0:0: [sdc] No Caching mode page found
kernel: [12767.565749] sd 5:0:0:0: [sdc] Assuming drive cache: write through
kernel: [12767.620230] sdc: sdc1
kernel: [12767.621669] sd 5:0:0:0: [sdc] Attached SCSI disk
systemd[1]: Starting LVM2 PV scan on device 8:33...
lvm[31988]: 1 logical volume(s) in volume group "wdhdd0" now active
systemd[1]: Started LVM2 PV scan on device 8:33.









share|improve this question









New contributor




Émilien is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I want to automatically mount an LVM logical volume on an external drive as soon as it is connected to the computer.



The solution I choose here is to use udev to detect plug in events and udisks2 to mount the partition. For other alternatives see a more generic approach of logical volume auto-mounting



I am asking for help to know if my approach of udev and udisks2 is doomed or if it is my achievement that failed. The following is a brief sum-up of all my attempt.



The simplest udev rule that does not work



To my mind udev rules seems to be appropriate to assert drive presence and set UDISKS_AUTO so I created the following rule in its own file /etc/udev/rules.d/61-lvm-automount-lv.rules



SUBSYSTEM=="block"
, ENVID_FS_UUID=="b32cefaa-041e-4ef7-8c82-fe53739aefff"
, ENVUDISKS_AUTO="1"


Then I reload the rules sudo udevadm control --reload (or even better restart my computer), check that the rule is read and UDISKS_AUTO is set to one for the given partition sudo udevadm test /sys/devices/virtual/block/dm-1 and confirm that in the end of the output I can see UDISKS_AUTO=1



However, when I unlplug/plug the external disk the partition is not mounted automatically.



I tried to find the maximum of information about what's going wrong thanks to journactl, udisksctl monitor but the only useful messages was from udevadm monitor --environment --udev showing that:



UDEV [3897.839040] change /devices/virtual/block/dm-1 (block)
.ID_FS_TYPE_NEW=ext4
ACTION=change
DEVLINKS=/dev/mapper/wdhdd0-wd0 /dev/disk/by-uuid/b32cefaa-041e-4ef7-8c82-fe53739aefff /dev/disk/by-label/wd /dev/disk/by-id/dm-name-wdhdd0-wd0 /dev/wdhdd0/wd0 /dev/disk/by-id/dm-uuid-LVM-hwQrCjWSOCCGpJqcdPv3NHaP3OOK6kFQj2Y6j3X51A69FEYNQeHtt8wVnVnlb93N
DEVNAME=/dev/dm-1
DEVPATH=/devices/virtual/block/dm-1
DEVTYPE=disk
DM_ACTIVATION=1
DM_COOKIE=6324838
DM_LV_LAYER=
DM_LV_NAME=wd0
DM_NAME=wdhdd0-wd0
DM_SUSPENDED=0
DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG=1
DM_UDEV_PRIMARY_SOURCE_FLAG=1
DM_UDEV_RULES=1
DM_UDEV_RULES_VSN=2
DM_UUID=LVM-hwQrCjWSOCCGpJqcdPv3NHaP3OOK6kFQj2Y6j3X51A69FEYNQeHtt8wVnVnlb93N
DM_VG_NAME=wdhdd0
ID_FS_LABEL=wd
ID_FS_LABEL_ENC=wd
ID_FS_TYPE=ext4
ID_FS_USAGE=filesystem
ID_FS_UUID=b32cefaa-041e-4ef7-8c82-fe53739aefff
ID_FS_UUID_ENC=b32cefaa-041e-4ef7-8c82-fe53739aefff
ID_FS_VERSION=1.0
MAJOR=253
MINOR=1
SEQNUM=6641
SUBSYSTEM=block
TAGS=:systemd:
UDISKS_AUTO=1
USEC_INITIALIZED=5756122


So it seems that udisks2 should automatically mount this partition thanks to UDISKS_AUTO=1 but no. However, I can still execute udisksctl mount -b /dev/wdhdd0/wd0 and now the partition is mounted manually.



Other rules that does not work



Changing the value of UDISKS_SYSTEM



SUBSYSTEM=="block", ENVID_FS_UUID=="b32cefaa-041e-4ef7-8c82-fe53739aefff", ENVUDISKS_SYSTEM="0", ENVUDISKS_AUTO="1"


Add a rule to unignore the physical volume containing the logical volume with ENVUDISKS_IGNORE="0". I undestand perfectly why physical volume has to be hidden and not mounted in the filesystem but I though that maybe the logical volume inherit some properties.



Set my simple rule earlier in the order of the udev files to be loaded first. It requires adding IMPORTbuiltin="blkid" in the begining of the rule for those who wants to try. Conversely, I tried to put the simple rule in the end. It only requires to change the number in the name of the file 61-lvm-automount-lv.rules.



Goal



Ultimately, I would like that a given logical volume could be automatically mounted by my system exactly as standard (non-lvm) partitions are usually mounted. I am open to any suggestion on the best way to do that. I oriented this question with udev and udisks2 because it seems to do a perfect job for standard partition under Ubuntu, so I would like to achieve the same thing for LVM.



Edit



my /var/log/syslog right after plugging in the disk:



[12766.403419] usb 1-1: new high-speed USB device number 9 using xhci_hcd
[12766.553014] usb 1-1: New USB device found, idVendor=1058, idProduct=1003
[12766.553020] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[12766.553024] usb 1-1: Product: External HDD
[12766.553029] usb 1-1: Manufacturer: Western Digital
[12766.553032] usb 1-1: SerialNumber: 57442D574D41565531333130343938
[12766.553817] usb-storage 1-1:1.0: USB Mass Storage device detected
[12766.554314] scsi host5: usb-storage 1-1:1.0
mtp-probe: checking bus 1, device 9: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1"
mtp-probe: bus: 1, device: 9 was not an MTP device
upowerd[2160]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0
upowerd[2160]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1
kernel: [12767.564246] scsi 5:0:0:0: Direct-Access WD 15EARS External 1.75 PQ: 0 ANSI: 4
kernel: [12767.565075] sd 5:0:0:0: Attached scsi generic sg1 type 0
kernel: [12767.565196] sd 5:0:0:0: [sdc] 2930277168 512-byte logical blocks: (1.50 TB/1.36 TiB)
kernel: [12767.565482] sd 5:0:0:0: [sdc] Write Protect is off
kernel: [12767.565487] sd 5:0:0:0: [sdc] Mode Sense: 23 00 00 00
kernel: [12767.565740] sd 5:0:0:0: [sdc] No Caching mode page found
kernel: [12767.565749] sd 5:0:0:0: [sdc] Assuming drive cache: write through
kernel: [12767.620230] sdc: sdc1
kernel: [12767.621669] sd 5:0:0:0: [sdc] Attached SCSI disk
systemd[1]: Starting LVM2 PV scan on device 8:33...
lvm[31988]: 1 logical volume(s) in volume group "wdhdd0" now active
systemd[1]: Started LVM2 PV scan on device 8:33.






lvm udev automounting external-hdd udisks






share|improve this question









New contributor




Émilien is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Émilien is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 19 hours ago







Émilien













New contributor




Émilien is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









ÉmilienÉmilien

64




64




New contributor




Émilien is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Émilien is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Émilien is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • This should work automatically. As far as I know, there is nothing special about LVs in this context - they are just another block device. But the place to look for problems/error messages are the system logs in /var/log, specifically message and syslog. What do those say?

    – Faheem Mitha
    yesterday







  • 1





    I'd also recommend checking out udiskie. That's what I use. It's packaged for Debian, and thus for Ubuntu. And it sounds like you are using Ubuntu.

    – Faheem Mitha
    yesterday











  • Yes thanks for your advice I'll edit the main post with the content of syslog right after the disk is plugged in. Also I have seen udiskie while I was browsing the documentation and all the help I could find about udisks and udev, but I hav not tried udiskie yet so I'll try that latter and report my experience.

    – Émilien
    yesterday












  • However I have no /var/log/messages or anything similar maybe it has been removed from Ubuntu 18.04

    – Émilien
    yesterday






  • 1





    Check /var/log/syslog.

    – Faheem Mitha
    yesterday

















  • This should work automatically. As far as I know, there is nothing special about LVs in this context - they are just another block device. But the place to look for problems/error messages are the system logs in /var/log, specifically message and syslog. What do those say?

    – Faheem Mitha
    yesterday







  • 1





    I'd also recommend checking out udiskie. That's what I use. It's packaged for Debian, and thus for Ubuntu. And it sounds like you are using Ubuntu.

    – Faheem Mitha
    yesterday











  • Yes thanks for your advice I'll edit the main post with the content of syslog right after the disk is plugged in. Also I have seen udiskie while I was browsing the documentation and all the help I could find about udisks and udev, but I hav not tried udiskie yet so I'll try that latter and report my experience.

    – Émilien
    yesterday












  • However I have no /var/log/messages or anything similar maybe it has been removed from Ubuntu 18.04

    – Émilien
    yesterday






  • 1





    Check /var/log/syslog.

    – Faheem Mitha
    yesterday
















This should work automatically. As far as I know, there is nothing special about LVs in this context - they are just another block device. But the place to look for problems/error messages are the system logs in /var/log, specifically message and syslog. What do those say?

– Faheem Mitha
yesterday






This should work automatically. As far as I know, there is nothing special about LVs in this context - they are just another block device. But the place to look for problems/error messages are the system logs in /var/log, specifically message and syslog. What do those say?

– Faheem Mitha
yesterday





1




1





I'd also recommend checking out udiskie. That's what I use. It's packaged for Debian, and thus for Ubuntu. And it sounds like you are using Ubuntu.

– Faheem Mitha
yesterday





I'd also recommend checking out udiskie. That's what I use. It's packaged for Debian, and thus for Ubuntu. And it sounds like you are using Ubuntu.

– Faheem Mitha
yesterday













Yes thanks for your advice I'll edit the main post with the content of syslog right after the disk is plugged in. Also I have seen udiskie while I was browsing the documentation and all the help I could find about udisks and udev, but I hav not tried udiskie yet so I'll try that latter and report my experience.

– Émilien
yesterday






Yes thanks for your advice I'll edit the main post with the content of syslog right after the disk is plugged in. Also I have seen udiskie while I was browsing the documentation and all the help I could find about udisks and udev, but I hav not tried udiskie yet so I'll try that latter and report my experience.

– Émilien
yesterday














However I have no /var/log/messages or anything similar maybe it has been removed from Ubuntu 18.04

– Émilien
yesterday





However I have no /var/log/messages or anything similar maybe it has been removed from Ubuntu 18.04

– Émilien
yesterday




1




1





Check /var/log/syslog.

– Faheem Mitha
yesterday





Check /var/log/syslog.

– Faheem Mitha
yesterday










0






active

oldest

votes











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Émilien is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f508790%2fautomount-lvm-logical-volume-with-a-udev-rule-and-udisks2%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








Émilien is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















Émilien is a new contributor. Be nice, and check out our Code of Conduct.












Émilien is a new contributor. Be nice, and check out our Code of Conduct.











Émilien is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f508790%2fautomount-lvm-logical-volume-with-a-udev-rule-and-udisks2%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







-automounting, external-hdd, lvm, udev, udisks

Popular posts from this blog

Mobil Contents History Mobil brands Former Mobil brands Lukoil transaction Mobil UK Mobil Australia Mobil New Zealand Mobil Greece Mobil in Japan Mobil in Canada Mobil Egypt See also References External links Navigation menuwww.mobil.com"Mobil Corporation"the original"Our Houston campus""Business & Finance: Socony-Vacuum Corp.""Popular Mechanics""Lubrite Technologies""Exxon Mobil campus 'clearly happening'""Toledo Blade - Google News Archive Search""The Lion and the Moose - How 2 Executives Pulled off the Biggest Merger Ever""ExxonMobil Press Release""Lubricants""Archived copy"the original"Mobil 1™ and Mobil Super™ motor oil and synthetic motor oil - Mobil™ Motor Oils""Mobil Delvac""Mobil Industrial website""The State of Competition in Gasoline Marketing: The Effects of Refiner Operations at Retail""Mobil Travel Guide to become Forbes Travel Guide""Hotel Rankings: Forbes Merges with Mobil"the original"Jamieson oil industry history""Mobil news""Caltex pumps for control""Watchdog blocks Caltex bid""Exxon Mobil sells service station network""Mobil Oil New Zealand Limited is New Zealand's oldest oil company, with predecessor companies having first established a presence in the country in 1896""ExxonMobil subsidiaries have a business history in New Zealand stretching back more than 120 years. We are involved in petroleum refining and distribution and the marketing of fuels, lubricants and chemical products""Archived copy"the original"Exxon Mobil to Sell Its Japanese Arm for $3.9 Billion""Gas station merger will end Esso and Mobil's long run in Japan""Esso moves to affiliate itself with PC Optimum, no longer Aeroplan, in loyalty point switch""Mobil brand of gas stations to launch in Canada after deal for 213 Loblaws-owned locations""Mobil Nears Completion of Rebranding 200 Loblaw Gas Stations""Learn about ExxonMobil's operations in Egypt""Petrol and Diesel Service Stations in Egypt - Mobil"Official websiteExxon Mobil corporate websiteMobil Industrial official websiteeeeeeeeDA04275022275790-40000 0001 0860 5061n82045453134887257134887257

Frič See also Navigation menuinternal link

Identify plant with long narrow paired leaves and reddish stems Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?What is this plant with long sharp leaves? Is it a weed?What is this 3ft high, stalky plant, with mid sized narrow leaves?What is this young shrub with opposite ovate, crenate leaves and reddish stems?What is this plant with large broad serrated leaves?Identify this upright branching weed with long leaves and reddish stemsPlease help me identify this bulbous plant with long, broad leaves and white flowersWhat is this small annual with narrow gray/green leaves and rust colored daisy-type flowers?What is this chilli plant?Does anyone know what type of chilli plant this is?Help identify this plant