You are not logged in.

#1 2012-07-28 05:22:25

12qu
Member
Registered: 2012-07-28
Posts: 7

[Solved] Udev symlinks disappear after umount

Hi,
I have a 1TB external hardrive with an NTFS filesystem. I have in place a udev rule which creates a symlink to the device when I plug it in.

Everything works fine when I mount the device as read-only -- that is, I can mount it and umount it and the symlink stays in place. But whenever I mount it with read-write permissions, the symlink is deleted as soon as I umount it.

I'm not sure whether this is a bug or a feature of something, or possibly of the hardware itself, but I would like this behaviour to stop. Any help would be appreciated.

Thanks!

Last edited by 12qu (2012-09-02 10:38:48)

Offline

#2 2012-07-28 06:01:15

Zancarius
Member
From: NM, USA
Registered: 2012-05-06
Posts: 207

Re: [Solved] Udev symlinks disappear after umount

It might be worth posting your custom udev rule.


He who has no .plan has small finger.
~Confucius on UNIX.

Offline

#3 2012-07-28 06:28:33

12qu
Member
Registered: 2012-07-28
Posts: 7

Re: [Solved] Udev symlinks disappear after umount

Sure:

ACTION=="add", KERNEL=="sd[a-z][1-9]", ATTRS{idVendor}=="0bc2", ATTRS{idProduct}=="3300", SYMLINK+="seagate_1tb_hdd"

Offline

#4 2012-07-29 04:31:54

12qu
Member
Registered: 2012-07-28
Posts: 7

Re: [Solved] Udev symlinks disappear after umount

The problem is still with me, but I might have made some progress. It appears that when I umount my drive, I trigger a "remove" event with udev. This does not happend when I umount a usb (symlinks to which don't get deleted on umount). The following should better explain things:

[user@arch-machine ~]$ sudo udevadm monitor &
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
[user@arch-machine ~]$ sudo mount -t ntfs /dev/seagate_1tb_hdd /media
KERNEL[5217.807175] add      /devices/virtual/bdi/8:17-fuseblk (bdi)
UDEV  [5217.809634] add      /devices/virtual/bdi/8:17-fuseblk (bdi)
[user@arch-machine ~]$ sudo umount /media
KERNEL[5224.983833] change   /devices/pci0000:00/0000:00:10.4/usb5/5-1/5-1:1.0/host14/target14:0:0/14:0:0:0/block/sdb/sdb1 (block)
KERNEL[5224.987900] remove   /devices/virtual/bdi/8:17-fuseblk (bdi)
UDEV  [5224.990578] remove   /devices/virtual/bdi/8:17-fuseblk (bdi)
UDEV  [5225.035267] change   /devices/pci0000:00/0000:00:10.4/usb5/5-1/5-1:1.0/host14/target14:0:0/14:0:0:0/block/sdb/sdb1 (block)

Compare with my USB drive (on sdb1):

[user@arch-machine ~]$ sudo udevadm monitor &
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
[user@arch-machine ~]$ sudo mount -t auto /dev/sdb1 /media
[user@arch-machine ~]$ sudo umount /media

Any ideas?

I should also make clear that the /dev/sd? and /dev/sd?[1-9] nodes stay in place throughout the whole time, even after this remove event and when the symlink has disappeared. Thus, I am still able to remount the drive without having to physically reconnect it, but really I want some way of naming it persistently so I can set up autofs to work with it.

I am also wondering if there is possibly some way of using the remove event to redetect the drive and rerun the original udev event, or otherwise recreate the symlink. Cheers!

Offline

#5 2012-09-02 10:37:01

12qu
Member
Registered: 2012-07-28
Posts: 7

Re: [Solved] Udev symlinks disappear after umount

At last, I seem to have found a solution. I have no idea how or why this works, but after removing the

ACTION=="add"

part, everything works fine. That is, my final and working udev rule is as follows:

KERNEL=="sd?1", ATTRS{idVendor}=="0bc2", ATTRS{idProduct}=="3300", SYMLINK+="seagate_1tb_hdd"

Anyone have any ideas on what the ACTION part might have been doing to cause that? Will I lose any functionality or cause any unexpected behaviour by removing it?

Offline

#6 2013-11-24 10:05:50

lostgdi
Member
Registered: 2013-11-24
Posts: 1

Re: [Solved] Udev symlinks disappear after umount

thank you "12qu" , your code worked to mine.

Last edited by lostgdi (2013-11-24 10:06:23)

Offline

#7 2013-11-24 15:24:02

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: [Solved] Udev symlinks disappear after umount

Welcome to these boards lostgdi. Please be mindful of our forum rules, Forum Etiquette: Old Threads / Necro-Bumping. Thanks.

Closing.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

Board footer

Powered by FluxBB