1

I am building hardware solutions for video debriefing purposes, where users will connect and remove cameras and/or SD cards to computers all the time. I am working with Raspberry pi's (Raspbian) for media playback. A fast media server for video related calculations and media conversion (Ubuntu) and a fast NAS for storage. I like to overcome the need for the user to ejecting media before removing the hardware, because I know from experience nobody will take the effort anyway. I have no need for my system to write data onto the users devices. So I was wondering if there is a way to mount all external devices always read-only in order to prevent any data corruption on unsafe removal.

I am fairly new to Linux and programming. The software I am writing is mainly Python, but I am looking for a more system wide approach for this problem so the user will not experience any

0

1 Answer 1

1

It's always recommended to umount properly any media , a file can still be opened for example

You can force media to mount read only with mount command options dedicated to options

mount -o ro /dev/media /example/path

you can use udev rules to force this option to any external media ... see this post to know how to How can I create a udev rule to mount a USB drive read only?

4
  • Thanks for your quick response! Do you know if mounting read only really means the data on the mounted drive is not touched in any way? or can a file still become corrupt if its opened while a the drive is removed? Feb 17, 2018 at 14:50
  • risk is nearly zero ...
    – francois P
    Feb 17, 2018 at 14:57
  • 1
    Data on the external media should stay untouched. But the running system can become unstable after that, especially if you're disconnecting a (spinning) disk. Feb 17, 2018 at 15:01
  • @SatōKatsura No it can’t. Never happens. And besides rpi up to revision 2 can’t source enough current to drive a magnetic disk. GNU/Linux is famous for ignoring conditions that would make a sane operating system panic (...and so is Linus Torvalds, but that’s off-topic)
    – user2497
    Feb 17, 2018 at 21:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .