

How to mount USB drive as read-only

  • When a USB drive is inserted it will be mounted as writable. How can I configure this to be read-only?
    I had a look at the fstab configuration, there it is possible when the uuid is know. But in my application the user can insert any random drive so this doesn't work.

    Are there other ways to configure USB for read-only access?

  • @ckielstra Since there is no other suggestions I have 2 thing you could look at.

    1. /etc/config/fstab allows you to set up mount points with the various configs. I use one for the sdcard on my devices to set up the mount point and the file system type. The docs refer to an additional "options" option which can be used to set mount options. I expect this includes the ro option but I have not tried it.

    2. The USB hotplug script is executed when you insert a USB device, you could add your own script to remount in read only mode. This is a hack you could use in the absence of a better solution.
