Pi-top | Automounting a network drive

So this one can be a little frustrating to get working and gives you some nice additional remote space, certainly handy when, it can be common to reinstall pi-topOS to wipe edits :stuck_out_tongue:

Automounting a Network Drive

The following steps is all done though the Terminal

Setting the credentials file

To start, first set a file that will have the username and password for accessing the network share.

  • Open terminal Ctrl+Alt+T
  • run the command nano ~/.smbcredentials
  • All you need in this file is the following
    • username=YOUR_NETORK_SHARE_USERNAME
      password=YOUR_NETORK_SHARE_PASSWORD
      

chanfing YOUR_NETORK_SHARE_USERNAME and YOUR_NETORK_SHARE_PASSWORD to the username and password for your network share

  • Save this file and close.
  • I the Terminal enter sudo chmod 600 ~/.smbcredentials to set the correct permissions to the file

Create Share Location
In the Terminal type mkdir /media/networkshare you can change networkshare to anything you like. This location will be needed for the next step

fstab entry

Now we need to edit fstab.

  • In the Terminal enter sudo nano /etc/fstab
  • At the end you can add the following line
    • //SERVERNAME/SHAREFOLDER /media/networkshare cifs credentials=/home/pi/.smbcredentials,uid=1000,gid=1000 0 0
      Replace the following
      SERVERNAME = with the network computer that you are accessing A eg. //sever.local/SHAREFOLDER
      SHAREFOLDER = the share folder that you want to mount | eg //sever.local/Dev
      networkshare = the folder you made in the previous step, must be full path | eg. /home/pi/ShareDrive , does not have to be in /media

an example of the whole line
//orilla.local/dev /home/pi/DevDrive credentials=/home/pi/.smbcredentials,uid=1000,gid=1000 0 0

Note: Just so you know, an error will occur if you have a space between the comma and uid and gid

Validating it works

To test that the mount is working properly, in the Terminal, enter sudo mount -a you should see a folder on your desktop with the folder name you made for the share location. If everything is working correctly, after a reboot, the network drive should automount

2 Likes

I think I’ll make a quick write up for mounting a Google drive tomorrow too. Its 2 am and I had to go pick my kid up 250miles away… Crazy stuffs