[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Edlug Archive Nov 2009 ]

Re: [edlug] Is a USB drive mounted




Jerome Kelleher wrote:

Well /proc/mounts contains the list of mounted file systems, but I'm not sure that this will tell you anything that mount does not, although, mount does not seem to access it:

No, the contents of /proc is maintained by the kernel. Programs such as mount interact with the kernel using the system call api.

A mount does not give certainty to the existence of the underlying
medium.  A filesystem is just an abstraction of the underlying data,
it's not a physical thing.

An error will occur when, but not until, the kernel tries to access
filesystem data on a non-existent device.  The kernel maintains a buffer
for accessing data on a device.  The buffer is not necessarily read from
or written to the device synchronously with accesses to the data by
programs.   Delays of up to 30s writing to the device can be expected.

If you remove a device containing a mounted filesystem then it is not possible for the kernel to unmount it (because to do so it has to update the data and write out to the (non-existent) device). Consequently there is no mechanism in the kernel to unmount a filesystem automatically when the device is removed. You are likely to corrupt the integrity of the data structures on the device and cause unrecoverable errors in the kernel in this situation.

Anyway, are you sure that detecting that these devices are mounted as filesystems is what you want? Sometimes when you have intermittent connectivity, the mounting and unmounting can get into a bit of a mess, because it can take a long time for IOs that are in flight to time out, and the file system will remain mounted until the buffers can be flushed. If you know the device name, it would be much more accurate to test the physical connection in /sys/block.

Dick - ---------------------------------------------------------------------- You can find the EdLUG mailing list FAQ list at: http://www.edlug.org.uk/list_faq.html



This archive is kept by wibble+RM@xxx.xxx.xxx
Morpheux
HomePage