taskman
Posts: 14
Joined: Sun Nov 02, 2014 8:00 am

Pi mount network directory of another Pi

Thu Dec 25, 2014 8:16 am

I have two Raspberry Pi's and I want to mount the directory of the master on the slave on startup

This mounts the directory if I run it manually. I would like to get the mount working everytime I reboot. The master and slave directories both belong to user pi
mount -t cifs //192.168.1.40/scanner -o username=pi,password=raspberry /scanner

on master
drwsrwsrwt 3 pi root 4096 Dec 23 09:43 scanner

on slave
drwsrwsrwt 3 pi root 0 Dec 23 09:43 scanner

I added the mount to /etc/fstab, but it doesn't mount on startup. Here is my fstab file. I tried different things on the line that I defined that I found in this forum and other forums. Can't find the right combination
proc /proc proc defaults 0 0
/dev/mmcblk0p5 /boot vfat defaults 0 2
/dev/mmcblk0p6 / ext4 defaults,noatime 0 1
//192.168.1.40/scanner /scanner cifs username=pi,password=raspberry,rw,file_mode=0777,dir_mode=0777,noperm 0 0


# a swapfile is not a swap partition, so no using swapon|off from here on, use dphys-swapfile swap[on|off] for that

User avatar
emgi
Posts: 357
Joined: Thu Nov 07, 2013 4:08 pm
Location: NL

Re: Pi mount network directory of another Pi

Thu Dec 25, 2014 9:19 am

You will need networking to be up for this to work.
Probably that's part of the problem because fstab is processed earlier in the boot sequence.

Alternatively you can try to put the mount command at the tail of /etc/rc.local.

/emgi

taskman
Posts: 14
Joined: Sun Nov 02, 2014 8:00 am

Re: Pi mount network directory of another Pi

Thu Dec 25, 2014 12:02 pm

That worked. Thank you. Why do all tutorials always say to add it to the fstab?

User avatar
rpdom
Posts: 17174
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Pi mount network directory of another Pi

Thu Dec 25, 2014 12:23 pm

taskman wrote:That worked. Thank you. Why do all tutorials always say to add it to the fstab?
Because that's the right place to put it. The rc.local method is a bit of a bodge. Adding _netdev to the options may help.

Personally I would have used NFS rather than CIFS to connect Linux systems together. It'll be faster and support the proper file permissions. Why use an alien (Windows) method of linking native systems?

taskman
Posts: 14
Joined: Sun Nov 02, 2014 8:00 am

Re: Pi mount network directory of another Pi

Thu Dec 25, 2014 12:25 pm

I will try that also. Thank you. Using Windows because all the tutorial that I found just talks about Linux to Window. Seems few people ever want Linux to Linux

taskman
Posts: 14
Joined: Sun Nov 02, 2014 8:00 am

Re: Pi mount network directory of another Pi

Thu Dec 25, 2014 12:37 pm

I added _netdev and changed to nfs, but not mounting. Did I do it right?

//192.168.1.40/scanner /scanner nfs username=pi,password=raspberry,rw,file_mode=0777,dir_mode=0777,noperm,_netdev 0 0

taskman
Posts: 14
Joined: Sun Nov 02, 2014 8:00 am

Re: Pi mount network directory of another Pi

Thu Dec 25, 2014 12:44 pm

When I add the mount command back into /etc/rc.local and use nfs the error on startup is "mount.nfs: remote share not in 'host:dir' format"

User avatar
rpdom
Posts: 17174
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Pi mount network directory of another Pi

Thu Dec 25, 2014 1:46 pm

First you have to have a NFS server running on the other Pi.

Second, the fstab line is slightly different for NFS.

Perhaps you ought to read up a bit on NFS and how it works. Any Debian or Raspbian specific HOWTO should show how to do it.

On my set up I install nfs-kernal-server on the server Pi (raspi4), then edit /etc/exports to have a line like

Code: Select all

/exported 192.168.1.0/24(rw,sync,no_root_squash,all_squash,no_subtree_check,insecure)
and on the other Pi I have

Code: Select all

raspi4:/exported /home/raspi4 nfs defaults 0 0
That mounts at boot and gives me access to everything I need on raspi4.

However, I do urge you to read up on NFS and the available options. :)

Return to “Beginners”