You are not logged in.

#1 2013-02-05 17:08:21

theta
Member
From: India
Registered: 2010-01-16
Posts: 123

[SOLVED] - Using pmount in udev to mount ntfs partition

I use pmount in my udev rules to mount all my external drives.
My rule file is:

KERNEL!="sd[a-z]*", GOTO="media_by_label_auto_mount_end"
ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="media_by_label_auto_mount_end"

# Get label
PROGRAM=="/sbin/blkid -o value -s LABEL %N", ENV{dir_name}="%c"

# use basename to correctly handle labels such as ../mnt/foo
PROGRAM=="/usr/bin/basename '%E{dir_name}'", ENV{dir_name}="%c"

# Make directory name if label empty
ENV{dir_name}=="", ENV{dir_name}="usb-%k"

#ACTION=="add", ENV{dir_name}!="", RUN+="/bin/su theta -c '/usr/bin/pmount %N   \"%E{dir_name}\"'"
ACTION=="add", ENV{dir_name}!="", RUN+="/bin/su theta -c '/usr/bin/pmount %N    %E{dir_name}'"
ACTION=="add", ENV{dir_name}!="", RUN+="/etc/udev/rules.d/rox_open_media"
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/su theta -c '/usr/bin/pumount / media/%E{dir_name}'"
LABEL="media_by_label_auto_mount_end"
~                                            

I am getting the following problem for mounting an ntfs partition. The other partition on the same drive mounts correctly and this partition also mounts properly if I issue a "pmount /dev/sdb5 /media/NewVolume" manualy.
Does this require ntfs-3g to be loaded somehow?

[18916.348063] UDF-fs: warning (device sdb5): udf_load_vrs: No anchor found
[18916.348067] UDF-fs: warning (device sdb5): udf_fill_super: No partition found (1)
[18916.403569] ISOFS: Unable to identify CD-ROM format.
[18916.427471] FAT-fs (sdb5): bogus number of reserved sectors
[18916.427477] FAT-fs (sdb5): Can't find a valid FAT filesystem
[18916.429066] UDF-fs: warning (device sdb1): udf_load_vrs: No anchor found
[18916.429070] UDF-fs: warning (device sdb1): udf_fill_super: No partition found (1)
[18916.432555] hfs: unable to find HFS+ superblock
[18916.478445] ISOFS: Unable to identify CD-ROM format.
[18916.480808] hfs: can't find a HFS filesystem on dev sdb5.
[18916.502095] EXT4-fs (sdb5): VFS: Can't find ext4 filesystem
[18916.515836] EXT4-fs (sdb5): VFS: Can't find ext4 filesystem
[18916.518035] EXT4-fs (sdb5): VFS: Can't find ext4 filesystem
[18916.523693] REISERFS warning (device sdb5): sh-2021 reiserfs_fill_super: can not find reiserfs on sdb5
[18916.543484] XFS (sdb5): bad magic number
[18916.543488] XFS (sdb5): SB validate failed
[18916.560207] omfs: Invalid superblock (58665866)
[18920.008682] systemd-udevd[144]: seq 1980 forked new worker [11524]
[18920.009218] systemd-udevd[11524]: seq 1980 running
[18920.009413] systemd-udevd[11524]: device 0x67c8a0 filled with db file data
[18920.009424] systemd-udevd[11524]: removing watch on '/dev/sdb5'
[18920.009494] systemd-udevd[144]: device 0x67c8a0 has devpath '/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1:1.0/host8/target8:0:0/8:0:0:0/block/sdb/sdb5'
[18920.009544] systemd-udevd[144]: inotify event: 8000 for /dev/sdb5
[18920.009631] systemd-udevd[144]: device 0x67c8a0 filled with db file data
[18920.009638] systemd-udevd[144]: removing watch on '/dev/sdb5'
[18920.009711] systemd-udevd[11524]: PROGRAM '/sbin/blkid -o value -s LABEL /dev/sdb5' /etc/udev/rules.d/11-media-by-label-with-pmount.rules:5
[18920.010134] systemd-udevd[11525]: starting '/sbin/blkid -o value -s LABEL /dev/sdb5'
[18920.214668] systemd-udevd[11524]: 'udisks-part-id /dev/sdb5'(err) 'new part entry'
[18920.214679] systemd-udevd[11524]: 'udisks-part-id /dev/sdb5'(err) 'Exiting MS-DOS parser'
[18920.214686] systemd-udevd[11524]: 'udisks-part-id /dev/sdb5'(err) 'MSDOS partition table detected'
[18920.214704] systemd-udevd[11524]: 'udisks-part-id /dev/sdb5'(out) 'UDISKS_PARTITION=1'
[18920.214711] systemd-udevd[11524]: 'udisks-part-id /dev/sdb5'(out) 'UDISKS_PARTITION_SCHEME=mbr'
[18920.214727] systemd-udevd[11524]: 'udisks-part-id /dev/sdb5'(out) 'UDISKS_PARTITION_NUMBER=5'
[18920.214735] systemd-udevd[11524]: 'udisks-part-id /dev/sdb5'(out) 'UDISKS_PARTITION_TYPE=0x07'
[18920.214742] systemd-udevd[11524]: 'udisks-part-id /dev/sdb5'(out) 'UDISKS_PARTITION_SIZE=218603234304'
[18920.214748] systemd-udevd[11524]: 'udisks-part-id /dev/sdb5'(out) 'UDISKS_PARTITION_LABEL='
[18920.214755] systemd-udevd[11524]: 'udisks-part-id /dev/sdb5'(out) 'UDISKS_PARTITION_UUID='
[18920.214762] systemd-udevd[11524]: 'udisks-part-id /dev/sdb5'(out) 'UDISKS_PARTITION_FLAGS='
[18920.214793] systemd-udevd[11524]: 'udisks-part-id /dev/sdb5'(out) 'UDISKS_PARTITION_SLAVE=/sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1:1.0/host8/target8:0:0/8:0:0:0/block/sdb'
[18920.214801] systemd-udevd[11524]: 'udisks-part-id /dev/sdb5'(out) 'UDISKS_PARTITION_OFFSET=31453502976'
[18920.214808] systemd-udevd[11524]: 'udisks-part-id /dev/sdb5'(out) 'UDISKS_PARTITION_ALIGNMENT_OFFSET=0'
[18920.215071] systemd-udevd[11524]: 'udisks-part-id /dev/sdb5' [11527] exit with return code 0
[18920.215447] systemd-udevd[11524]: found 'b8:21' claiming '/run/udev/links/\x2fdisk\x2fby-id\x2fwwn-0x5000c500100cc1f5-part5'
[18920.215458] systemd-udevd[11524]: creating link '/dev/disk/by-id/wwn-0x5000c500100cc1f5-part5' to '/dev/sdb5'
[18920.215471] systemd-udevd[11524]: preserve already existing symlink '/dev/disk/by-id/wwn-0x5000c500100cc1f5-part5' to '../../sdb5'
[18920.215502] systemd-udevd[11524]: creating link '/dev/disk/by-label/NewVolume' to '/dev/sdb5'
[18920.215515] systemd-udevd[11524]: preserve already existing symlink '/dev/disk/by-label/NewVolume' to '../../sdb5'
[18920.215539] systemd-udevd[11524]: found 'b8:21' claiming '/run/udev/links/\x2fdisk\x2fby-path\x2fpci-0000:00:1d.7-usb-0:1:1.0-scsi-0:0:0:0-part5'
[18920.215550] systemd-udevd[11524]: creating link '/dev/disk/by-path/pci-0000:00:1d.7-usb-0:1:1.0-scsi-0:0:0:0-part5' to '/dev/sdb5'
[18920.215583] systemd-udevd[11524]: found 'b8:21' claiming '/run/udev/links/\x2fdisk\x2fby-uuid\x2f7264F3C564F389DD'
[18920.215593] systemd-udevd[11524]: creating link '/dev/disk/by-uuid/7264F3C564F389DD' to '/dev/sdb5'
[18920.215606] systemd-udevd[11524]: preserve already existing symlink '/dev/disk/by-uuid/7264F3C564F389DD' to '../../sdb5'
[18921.904941] ROX-Filer[10688]: segfault at 30 ip 000000000042ddac sp 00007fff8ad5d290 error 4 in ROX-Filer[400000+8c000]

Last edited by theta (2013-02-07 14:56:34)

Offline

#2 2013-02-05 19:28:49

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: [SOLVED] - Using pmount in udev to mount ntfs partition

theta wrote:

I use pmount in my udev rules to mount all my external drives.

there is your problem. udev rules are not meant to be used to mount devices. What you are doing there is an ugly hack that just happens to work in some cases. Get rid of this udev rule and do what every other sane person does - use udisks/udisks2 (with an automount wrapper like udevil if necessary, see wiki).

Offline

#3 2013-02-06 15:23:19

theta
Member
From: India
Registered: 2010-01-16
Posts: 123

Re: [SOLVED] - Using pmount in udev to mount ntfs partition

I took your advice and installed udevil. The wiki isn't very clear whether we need to install devmon explicitily.
So I modified my udev rule to use udevil:

KERNEL!="sd[b-z]*", GOTO="media_by_label_auto_mount_end"
ACTION=="add", RUN+="/bin/su theta -c '/usr/bin/udevil mount %N'"
ACTION=="add", RUN+="/etc/udev/rules.d/rox_open_media"
LABEL="media_by_label_auto_mount_end"

The problem persists. The ntfs partition mounts for a second, and then when I try opening the concerned directory rox says "File doesn't exist, or I can't access it".

Edit:
Doing a ls in the directory gives:

[theta@pc media]$ ls
ls: cannot access NewVolume: Transport endpoint is not connected
NewVolume  sdb1-ata-ST9250827AS_5RG4 x

Then I have to do a

sudo umount /dev/sdb5

to unmount the ntfs partition. And remount using udevil from command line to make it work

Last edited by theta (2013-02-06 15:30:12)

Offline

#4 2013-02-06 15:36:20

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: [SOLVED] - Using pmount in udev to mount ntfs partition

theta wrote:

I took your advice and installed udevil. The wiki isn't very clear whether we need to install devmon explicitily.
So I modified my udev rule to use udevil:

KERNEL!="sd[b-z]*", GOTO="media_by_label_auto_mount_end"
ACTION=="add", RUN+="/bin/su theta -c '/usr/bin/udevil mount %N'"
ACTION=="add", RUN+="/etc/udev/rules.d/rox_open_media"
LABEL="media_by_label_auto_mount_end"

The problem persists. The ntfs partition mounts for a second, and then when I try opening the concerned directory rox says "File doesn't exist, or I can't access it".
Then I have to do a

sudo umount /dev/sdb5

to unmount the ntfs partition. And remount using udevil from command line to make it work

no, get rid of the rule completely. From my understanding devmon is part of udevil and you will have to run it in the background (via a systemd service I guess).

If you use a filemanager like thunar or nautilus you don't need any of this as they take care of automounting for you (as long as you have udisks/udisks2 installed and actually enabled to automount devices in the file managers settings).

Offline

#5 2013-02-06 16:32:08

theta
Member
From: India
Registered: 2010-01-16
Posts: 123

Re: [SOLVED] - Using pmount in udev to mount ntfs partition

I couldn't get systemd to activate the devmon service. It shows it with an @ sign.
I wonder what it means.
I finally added devmon to start in my  .config/openbox/autostart.sh, that has done the magic.

But I would really like to know what that "Transport endpoint is not connected" means, in case you have any idea.

Adding a seperate service increases system load, so I would have preffered using just udev alone.

Offline

#6 2013-02-06 18:05:37

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,058

Re: [SOLVED] - Using pmount in udev to mount ntfs partition

The @ sign is so you run the service as your user like:

systemctl enable devmon@theta.service

As for that message, you did remove the udev rule and reboot right? Also if your drive has NTFS partitions, make sure you have ntfs-3g installed.

Offline

#7 2013-02-06 18:13:05

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: [SOLVED] - Using pmount in udev to mount ntfs partition

theta wrote:

But I would really like to know what that "Transport endpoint is not connected" means, in case you have any idea.

This probably happens because, in case of ntfs partitions, the mount process has to keep running while the device is mounted. udev will however kill any long running processes that are started via udev rules.

Last edited by 65kid (2013-02-06 18:13:25)

Offline

#8 2013-02-07 14:54:12

theta
Member
From: India
Registered: 2010-01-16
Posts: 123

Re: [SOLVED] - Using pmount in udev to mount ntfs partition

anonymous_user wrote:

The @ sign is so you run the service as your user like:

systemctl enable devmon@theta.service

As for that message, you did remove the udev rule and reboot right? Also if your drive has NTFS partitions, make sure you have ntfs-3g installed.

Thanks that solved the service problem. I suppose using udev directly wasn't such a good idea.

Offline

Board footer

Powered by FluxBB