Verify that a USB Flash Drive is Actually Mounted
by Steve R. from LinuxQuestions.org on (#5QSWG)
I have a USB flash drive that is attached to my router. It's physical location is "//rt-ac3100-84e8/sda1" it is mounted on "/media/My_Passport"
The USB flash drive is always "mounted" since it is on a router and is used to store my backup files. For an unknown reason, the USB flash drive became unmounted one day. I was able to remount it. Nevertheless, I am revising my backup program to send an error message should the USB flash drive becomes unmounted.
The issue that I am having is the various utilities for listing what is mounted apparently show mount points irrespective of whether or not the USB flash drive is actually mounted or not. Is there a time delay before a computer system recognizes that a mount point is actually empty?
I have tried "findmnt", "mount", "dmesg", "lsblk". None of the commands provided real-time output that would confirm whether the USB flash drive was actually mounted or not.
The less elegant, Plan "B" solution is to issue the following two commands in the terminal to test for the existence of the top directory in the USB flash drive. In the bash program it will be revised to an "if" statement.
Is there a way to test, real-time, whether a USB flash drive attached to a router is mounted or not on the local computer?
The USB flash drive is always "mounted" since it is on a router and is used to store my backup files. For an unknown reason, the USB flash drive became unmounted one day. I was able to remount it. Nevertheless, I am revising my backup program to send an error message should the USB flash drive becomes unmounted.
The issue that I am having is the various utilities for listing what is mounted apparently show mount points irrespective of whether or not the USB flash drive is actually mounted or not. Is there a time delay before a computer system recognizes that a mount point is actually empty?
I have tried "findmnt", "mount", "dmesg", "lsblk". None of the commands provided real-time output that would confirm whether the USB flash drive was actually mounted or not.
The less elegant, Plan "B" solution is to issue the following two commands in the terminal to test for the existence of the top directory in the USB flash drive. In the bash program it will be revised to an "if" statement.
Code:test -e /media/My_Passport/AlcorThat works as expected, but it would not be the best approach for identifying if a device is mounted since it actually only tests for the existence of a directory.
echo $?
Is there a way to test, real-time, whether a USB flash drive attached to a router is mounted or not on the local computer?