Here’s a very simple PHP script I whipped up to get the names, sizes, and mount state of a disk or partition in GNU/Linux or similar OS. It’s meant to be used on the shell in other scripts, so the output is easy to parse.
Use is as follows:
diskinfo [options] DISKNAME
DISKNAME is the name of the disk or partition, with or without the /dev/ portion. The script accepts several options, the --version option shows version and license information, the --help shows the version message and a help/usage message. The -s option makes the size of the disk or partition be printed in bytes, with -b in blocks, or with -h as a more appropriate unit (KB, MB, GB, etc.). The -m option displays whether the disk or partition is mounted or not, 1 if it is or 0 if it’s not. Have a look at the code, it’s fairly easy to see what’s going on and/or modify the behavior.
Download the script file, make it executable, and put it in a location in your $PATH environment variable (ex. /usr/bin) or call it otherwise.
