You are not logged in.
Pages: 1
Topic closed
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
It might be worth posting your custom udev rule.
He who has no .plan has small finger.
~Confucius on UNIX.
Offline
Sure:
ACTION=="add", KERNEL=="sd[a-z][1-9]", ATTRS{idVendor}=="0bc2", ATTRS{idProduct}=="3300", SYMLINK+="seagate_1tb_hdd"
Offline
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
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
thank you "12qu" , your code worked to mine.
Last edited by lostgdi (2013-11-24 10:06:23)
Offline
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
Pages: 1
Topic closed