Topic: Disable writing when usb not mounted ?

in usb storage wiki there is this section:

Disable writing when not mounted
You may create an empty file to indicate that the disk is not plugged in so that you don't put files directly onto NAND by doing

touch /mnt/usbstorage/USB_DISK_NOT_PRESENT
chmod 444 /mnt/usbstorage -R

but root can still write to this folder if device is not mounted,right?
and if the folder is shared over nfs while device not plugged in and I write to it my  NAND will explode, right?
so how do you really prevent this from happening? I may plug off the device here and there and if I forget to plug it in before I write to the folder over nfs I may be in problems.
maybe use chattr? which does not exist in openwrt.

Thank you

Re: Disable writing when usb not mounted ?

As a noob, I saw this forum post after looking at the wiki...
I think it is generally a correct idea.
The file USB_DISK_NOT_PRESENT doesn't do anything really except make the lock visible to people trying to use the directory.
The chmod line, on the other hand, does prevent files from being written if the filesystem isn't mounted.
I would likely change it though:
touch /mnt/usbstorage/USB_DISK_NOT_PRESENT
chmod 500 /mnt/usbstorage -R
chmod 400 /mnt/usbstorage/USB_DISK_NOT_PRESENT

This will not prevent root from doing things.. But why would you be putting files on your USB as root?
I think this is mostly for people using FTP, NFS or Samba fileshares.. It is to prevent accidental writing to the system, and will prevent it, provided you aren't working as root (which you shouldn't)

Re: Disable writing when usb not mounted ?

touch /mnt/usbstorage/USB_DISK_NOT_PRESENT
chown root:root /mnt/usbstorage -R
chmod 555 /mnt/usbstorage -R
chmod 444 /mnt/usbstorage/USB_DISK_NOT_PRESENT