Is there an easy way to determine if a mounted filesystem is mounted as Read-Only or Read-Write? I was thinking just to pipe mount but I thought there might be an easier way.
|
feedback
|
|
If the file system is mounted, I'd cd to a temporary directory and attempt to create a file. The return code will tell you if the file system is Read-Only or Read-Write. | |||||||
feedback
|
|
This little one-liner will pop-out something if a ro file system exists.
Assuming you don't usually have a ro file system like a CD in the drive, it is sufficient for some basic monitoring type stuff and doesn't require changing the file system to find the current state. It also doesn't assume your file system type. Pipe it into grep -v iso9660 if you want to keep your CDs out of the record. | ||||
|
feedback
|
|
For example, to check if the root partition is in Read-Only mode:
| |||
feedback
|