Ubuntu: Mount Lehigh LAN file storage from the command line with gio

Ubuntu: Mount Lehigh LAN file storage from the command line with gio

Current versions of Ubuntu Linux (including 20.04) contain a highly-developed version of the Gnome desktop manager.  Part of that system is the included gio command, which provides control of the gnome virtual file system (gvfs), which allows non-administrative users to connect and access network file systems.   Following this procedure does require a bit of familiarity with linux commands like 'cd', 'ls', and 'ln'.

The procedure below describes how to use that command to connect to Lehigh’s LAN file storage spaces.

1.  From the Ubuntu desktop:

  • Click the 'Activity' button, and
  • In the search box, type "Terminal"
  • Click on the icon for the 'Terminal' program.

2.  At the terminal prompt, enter the command as shown, specifying your own username.  For example, if your Lehigh username was dab406, you would enter:

$ gio mount smb://homefs.cc.lehigh.edu/home

Note :  The 'share' parameter is generally simply the top-level share directory name -- subdirectories appended to the share name will be ignored.

3.  At the authentication prompts, type:

  • your Lehigh username (e.g dab406)
  • "ad" for the domain
  • and your Lehigh password

and then hit enter.

4. Gio connects network file systems to the /run/user directory under another directory named with your 'user ID'.  To find your user ID on your current system, type 'echo $UID'.  It should return a number, likely one greater than 1000. 

$ echo $UID


5.  Next, check that the connection to the file system was made (this is a 'gvfs mount'). 

a.  To do this, navigate to the directory gio created by typing  'cd /run/user/<your UID from step 4>/gvfs', and give the 'ls' command. 

$ cd /run/user/1001/gvfs

You should see an entry for the 'mount' you made with a long string indicating the parameters of the connection in the name of the directory.  It will look like:

'smb-share:server=homefs.cc.lehigh.edu,share=home'

Note that to cd into that directory, Ubuntu's auto-complete feature makes it easier -- type 'cd s' and then hit 'tab'.  Ubuntu will complete the directory name for you.

$ cd smb-share\:server\=homefs.cc.lehigh.edu\,share\=home/

b.  Now, in the case of the H-drive, the 'home' share contains the H-drives of everyone in the university.  It can take a while to populate and display that whole list.  Spare yourself the wait, and immediately cd again to your own directory, named with your username. For example:

cd dab406

c.  Then type 'ls' to see the contents, and verify that it's your H-drive.

$ cd dab406
$ ls

Note Also:  This connection is temporary -- it will need to be re-made each time you log into the computer you're making it from. Yes, you can add the command to your .bashrc file, but remember that it's unwise to store the password in plain text.


6.  Every time you give the gio command with that server and share name, gio creates a folder in that directory with that same name.  Knowing that, you can create an easier-to-find and easier-to-type shortcut for those LAN spaces right in your home directory.  Before you do that though, it's good to make a directory there just for those kinds of shortcuts.

For example, if connecting your H-drive, first give the following command:

$ mkdir ~/lts-shares

7.  Then, in that new directory, create a symbolic link to your gvfs mount using the following command:

$ ln -s /run/user/<uid>/gvfs/smb-share\:server\=<servername>\,share\=<sharename><\/desired subdirectory> ~/<mountpoint>/<linkname>

Where:

  • <uid> is the value received in step 4,
  • <servername> is the network name of the server the share is on,
  • <sharename> is the name of the directory that the server shares,
  • <\/desired subdirectory> is an optional addition to go direct to a particular subdirectory within the share (like your H-drive) and
  • <mountpoint> is the directory created in step 6, and
  • <link-name> is a short, descriptive name for the link that makes sense to you.

For example:

$ ln -s /run/user/1000/gvfs/smb-share\:server\=home.cc.lehigh.edu\,share\=home\/dab406 ~/lts-shares/hdrive

Note:  The syntax of this command is tedious and fussy because autocomplete won't work within the ln command.  You'll see several backslash characters here '\' -- these are used to 'escape' the colons, equal signs and commas, and they must stay.  Finally, in the case of your H-drive, make sure to append the '\/<username>' string to the end of the reference (so you only make a shortcut to _your_ H-drive, and not _everyone's_ H-drive).


8.  Additional Lehigh LAN storage locations can be connected, and links created by altering the <servername>, <sharename>, and <linkname> fields appropriately, for example:

Departmental Storage (I-drive):

$ gio mount smb://common.cc.lehigh.edu/common
$ ln -s /run/user/1000/gvfs/smb-share\:server\=common.cc.lehigh.edu\,share\=common ~/lts-shares/idrive

Faculty Storage (R-drive):

$ gio mount smb://rdrive.cc.lehigh.edu/dab406
$ ln -s /run/user/1000/gvfs/smb-share\:server\=rdrive.cc.lehigh.edu\,share\=dab406 ~/lts-shares/rdrive

Note:  The symbolic links are persistent files.  They don't need to be re-created for subsequent logons.  Only the mount command in steps 2 and 3 needs to be repeated, and can be added to the .bashrc file to be run at login.



For immediate help, contact the LTS Help Desk (Hours)
EWFM Library | Call: 610-758-4357 (8-HELP) | Text: 610-616-5910 | Chat | helpdesk@lehigh.edu
Submit a help request (login required)