4

Most popular desktop Linux distributions automatically mount USB storage devices when the devices are connected or at least provide an easy way to mount them from the GUI. Does mounting a USB storage device the "default" way (from the GUI) write anything to the device? It's simple enough to mount the device as read-only, but if I don't explicitly write to the device (with cp, touch, mkdir, etc.) will the operating system write anything in the background?

I have a hardware RAID controller for two USB hard drives configured in RAID 1. At some point I may want to remove the drives and examine them individually to make sure that content is being written to both and to check on the drives' health. I'm concerned that if I forget to mount the drives as read-only the operating system (in my case Manjaro Linux) might update something that I'm unaware of (perhaps "last time mounted" or "last time data was accessed") and break the RAID 1 setup.

Thank you for your time!

  • Some filesystems like ext2 to 4 have mount counts and last mount times that are updated on the disk if it is not mounted readonly. See man tune2fs for example. You could use iosnoop to trace all i/o to your device. – meuh Apr 27 '18 at 18:00
4

The answer depends on the file system. Those typically used on removable devices (FAT32 or ExFAT) shouldn’t be modified on mount, but many file systems store their last mount time and update that every time they’re mounted. Even when mounted read-only, some file systems such as Ext3 or Ext4 are liable to replay their journal (if the file system is dirty) and thus be modified.

There are ways to force a really read-only mount. One approach works with any file system: you can set the underlying block device itself to be read-only, using blockdev --setro. Others are file system-specific; for the Ext family, you can use the ro,noload mount options. To do this on a system with auto-mounting enabled, you’d have to add a udev rule to protect the device before it’s mounted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.