You are not logged in.
Pages: 1
Hi,
I just added a udev rule to automount my devices at /media/$DEVICE and everything's going swimmingly. However, when I unmount the device, I'd like /media/$DEVICE to be deleted. This can't be done with udev since the only actions it recognizes are add/remove, right? Is there any way to get HAL or something else to handle it?
Cheers,
SMRT
Offline
I made a similiar question here, At the moment I let udev mount all my stuff. When I want to umount, I do always sudo umount /media/label and the udev rule delete that folder that is created on media folder.
Offline
http://wiki.archlinux.org/index.php/Ude … r_.2Fmedia
# Clean up after removal
ACTION=="remove", RUN+="/bin/rm -f /media/usbhd-%k", RUN+="/bin/umount -l /mnt/usbhd-%k", RUN+="/bin/rmdir /mnt/usbhd-%k"
Offline
I made a similiar question here, At the moment I let udev mount all my stuff. When I want to umount, I do always sudo umount /media/label and the udev rule delete that folder that is created on media folder.
Wait, so you have a udev rule that automatically deletes your folder in /media? May I ask what that rule is?
http://wiki.archlinux.org/index.php/Ude … r_.2Fmedia
# Clean up after removal ACTION=="remove", RUN+="/bin/rm -f /media/usbhd-%k", RUN+="/bin/umount -l /mnt/usbhd-%k", RUN+="/bin/rmdir /mnt/usbhd-%k"
Doesn't that only remove symlinks, unmount, remove the actual folder when the device is PHYSICALLY removed?
Last edited by iamsmrt (2010-08-23 22:20:50)
Offline
yes it deletes. I use this rule on archwiki http://wiki.archlinux.org/index.php/Ude … if_present
Offline
yes it deletes. I use this rule on archwiki http://wiki.archlinux.org/index.php/Ude … if_present
I'm using the same rule but it only deletes when I actually unplug the device rather than just unmounting it.
Offline
Yes willl only delete the folder when you remove it. You must umount first though or you will have corrupt files.
Offline
I couldn't figure out a way to clean when simply just unmounting and I noticed that if you unmounted something and turned off the computer, the folder created in /media would still remain. So I added a cleanup script to /etc/rc.local:
Use your own discretion when using this as it could potentially erase your external media.
for i in $(mount | awk 'match($0,"/media/[^ ]*") {print substr($0,RSTART,RLENGTH)}'); do
for j in $(ls /media | egrep "[^cd|dvd|fl]"); do
if [ "/media/$j" != $i ]; then
rm -r /media/$j
fi
done
done
Offline
Pages: 1