in reply to Check that a ramdisk is mounted
To test whether a ramdisk has been mounted I have created a file in the mount point directory. I then test whether that file exists and if not I presume a ramdisk has been mounted there. Is there a more elegant method without needing a test file?
That test just check if anything was mounted on the moint point directory. Of course, it will be false negative once the mounted filesystem contains a file with the same name as the test file. jcb's stat test Re: Check that a ramdisk is mounted does that better, without false negative results.
None of the tests checks for a ramdisk, both just check for any filesystem mounted. Detecting a ramdisk is highly specific for the operating system. The device number of the file system (the first value in stat's return value) may be a clue. With knowledge about how device numbers are allocated, you may at least be able to identify disk- or flash-backed block devices. Linux has a file named "Documentation/devices.txt", "Documentation/admin-guide/devices.txt" in newer versions, that contains major and minor device numbers. Some major device numbers are used for RAM disks, floppies, various hard disk interfaces, cdrom drives, and so on, they are quite obvious. Other block devices are in-between: Loop devices create a block device from a file that may or may not exist on a ramdisk. Network block devices import other computer's block devices that may or may not be ramdisks. Then there are experimental, local and dynamically allocated block devices, the latter for virtual filesystems like tmpfs that need just a dummy block device number, but no real block device. And ramdisks implemented as real, physical peripherals plugged into some system bus, or simply appearing as a SCSI disk. And that's just Linux. Feel free to explore OSX and the *BSDs ...
Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Check that a ramdisk is mounted
by jcb (Parson) on May 18, 2021 at 01:19 UTC |