1

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 ?

Yacine Hebbal
  • 364
  • 2
  • 16
  • 1
    you could change your script to check 'mount | grep sda1' instead of checking if the directory exists. – zekus Jul 11 '13 at 11:23

1 Answers1

2

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

zekus
  • 848
  • 8
  • 16
  • Your answer contradicts your comment (about checking the mountpoint). Also could you please provide reasoning as to why one way is better than the other? – styrofoam fly Jul 10 '18 at 19:36