The folder you are looking for is under /Volumes
in your file system. /Volumes
is sometimes called a hidden file in MacOS parlance.
Using Finder with Hidden Files:
There are at least two ways to expose hidden files in Finder:
Use the Finder menu to navigate to arbitrary folders: Go, Go to Folder..., (ALTERNATIVELY: shiftcommandG), and then enter /Volumes
in the text box. Of course this method requires that you know the name of the file/directory you're looking for, but once that's known this will get you there.
If you're running macos Sierra (or later), you can view all hidden files/folders in Finder like so: shiftcommand. (shift-command-period). Repeating this sequence will hide the hidden folders again.
Note: To see /Volumes
using the 2nd method, you must position Finder at the proper place in the file system; i.e. at the Macintosh HD
level (selected from Finder's sidebar if you have it enabled!).
Once Finder has listed the hidden file/folder of interest, use the menu (File, Get Info) or shortcut (commandI) to yield the info window with lots of handy information.
At this point, your questions re. Finder and hidden files have hopefully been answered. Now let's move on to the rest of your question re. how to display usage stats from the command line:
Hidden Files from the Command Line:
Open a terminal window (bash
is the default macos shell). Just like every (?) other *nix system in the universe, the file system root is simply known as /
. So, let's see what's in /
:
$ ls -l /
total 13
drwxrwxr-x+ 80 root admin 2560 Mar 17 18:42 Applications
drwxr-xr-x+ 64 root wheel 2048 Feb 4 01:43 Library
drwxr-xr-x 2 root wheel 64 Feb 4 01:39 Network
drwxr-xr-x@ 5 root wheel 160 Sep 21 05:05 System
drwxr-xr-x 7 root admin 224 Feb 4 01:39 Users
drwxr-xr-x@ 4 root wheel 128 Mar 17 22:48 Volumes
drwxr-xr-x@ 37 root wheel 1184 Feb 8 02:57 bin
drwxrwxr-t 2 root admin 64 Feb 4 01:39 cores
dr-xr-xr-x 3 root wheel 4512 Mar 17 12:17 dev
lrwxr-xr-x@ 1 root wheel 11 Feb 4 01:37 etc -> private/etc
dr-xr-xr-x 2 root wheel 1 Mar 17 22:10 home
-rw-r--r-- 1 root wheel 313 Aug 18 2018 installer.failurerequests
dr-xr-xr-x 2 root wheel 1 Mar 17 22:10 net
drwxr-xr-x 3 root wheel 96 Sep 26 2016 opt
drwxr-xr-x 6 root wheel 192 Feb 4 01:39 private
drwxr-xr-x@ 64 root wheel 2048 Feb 8 02:57 sbin
lrwxr-xr-x@ 1 root wheel 11 Feb 4 01:37 tmp -> private/tmp
drwxr-xr-x@ 10 root wheel 320 Feb 4 01:44 usr
lrwxr-xr-x@ 1 root wheel 11 Feb 4 01:38 var -> private/var
$
Listed here are all of your files and folders, including links, and the hidden files, including /Volumes
. If this makes you wonder about the conventional wisdom (or current practice) re. "ease of use" for Graphical User Interfaces (GUI), then you are on the right track :) But I digress...
Now, take a look to verify that your mounted shares are listed under /Volume
. In your case, assuming your raspberrypi share is the only one mounted, you'll see something similar to this:
$ ls -l /Volumes
total 32
lrwxr-xr-x 1 root wheel 1 Mar 17 12:17 Macintosh HD -> /
d--x--x--x+ 2 macusr wheel 64 Mar 17 12:18 passport2tb
drwx------ 1 macusr staff 16384 Mar 4 23:56 passport2tb-1
$
The first line is a link showing the mapping from the Macintosh HD
to the file system root /
. The second line will show your mounted network drive, but note the permissions - you won't be able to use this one. It's apparently an artifact. I don't know why it's there other than to set the executable
permission bit for the folder; perhaps someone else can offer an explanation? At any rate, while we needn't be overly concerned about why it's there, automating this task will require that we identify the correct share name.
Automating the process via bash
script:
The correct share name can be found as follows:
$ ls -l /Volumes | grep drwx | head -1 | awk '{print $9}'
drwx------ 1 macusr staff 16384 Mar 4 23:56 passport2tb-1
passport2tb-1
$
To recap: grep
will filter the output of ls -l
to get the actual share (instead of the artifact), head -1
will filter duplicates (which may show up as passport2tb-2
, etc) and awk '{print $9}'
will get the 9th field in the string which is the share name. If you have other shares mounted in /Volumes
, simply add another grep
stage to get the one(s) you're interested in.
Knowing the location of your mounted share will allow you to successfully execute the du
command to display the usage statistics of any folder in the mounted share; for example:
$ du -sh /Volumes/passport2tb-1/data_lib
75G /Volumes/passport2tb-1/data_lib
$
In this case, the folder data_lib
folder contains 75GB of data... and this may take a few minutes to tally, even on a fast network.
Some command line gymnastics that might be useful:
- If you don't want/need the path information in
du
, use awk
to strip it:
$ du -sh /Volumes/passport2tb-1/data_lib | awk '{print $1}'
75G
$
- And if you don't want the "G":
$ du -sh /Volumes/passport2tb-1/data_lib | awk '{print $1}' | cut -d "G" -f 1
75
$
To wrap this up in a script:
#!/bin/bash
SHRNM=$(ls -l /Volumes | grep drwx | head -1 | awk '{print $9}')
SIZE=$(du -sh /Volumes/$SHRNM/data_lib | awk '{print $1}' | cut -d "G" -f 1)
echo $SIZE
Finally: Save it, name it, make it executable, and add it to your crontab
to be executed periodically.
This answer has gotten long-winded, so I'll leave this as an exercise for the reader.
df
command useful.