Delete mounting directory after umount -l

Yacine Hebbal picture Yacine Hebbal · Jul 11, 2013 · Viewed 8.2k times · Source

I'm working on Linux OpenWrt where I have to mount and umount manually USB disks when they are attached to the router.

I'm using this script: http://wiki.openwrt.org/doc/howto/writable_ntfs#with.a.custom.hotplug.script to mount and unmount automatically USB disks the problem is that it doesn't delete the mounting directory after umount -l /dev/$device. My application on the router needs to check if the USB disk is present or not by checking if /mnt/sda1 exists or not

My question is: is it dangerous to add rm -r sda1 after umount -l /dev/$device, or is there a risk that rm -r sda1 will remove files in sda1 ?

Answer

zekus picture zekus · Jul 11, 2013

It should be safe to delete the directory after the umount if you check for the success of the umount command before but I would suggest to change you script to check if the mountpoint it's listed in the mount table instead with mount | grep sda1