matsojr22
Posts: 4
Joined: Sat Nov 03, 2012 4:59 am

Cannot mount smb/cifs from fstab

Sat Nov 03, 2012 5:38 am

Okay, I have been trying for a few days now and cannot seem to get this to work.

I have a freeNAS box serving out files over cifs/smb and want to automatically mount those shares when the pi boots.

I am able to mount a share using the following command via ssh:

Code: Select all

sudo mount -t cifs //192.168.2.119/0.5TB\ SG\ HDD\ 1 /var/0.5tbsghdd1 -o user=matthew
then entering my password when prompted.

so...
after looking at several hundred recommendations from others...
reading many, many pages of fstab syntax tutorials...
and trying many, many, many... seriously like really a lot... of different fstab configurations...

my best guess for the fstab line should be:

Code: Select all

//192.168.2.119/0.5TB\ SG\ HDD\ 1  /var/0.5tbsghdd1  cifs  user=matthew,pass=pass,uid=1001,_netdev  0  0
saving this to the fstab.

run command

Code: Select all

sudo mount -a
[mntent]: line 4 in /etc/fstab is bad
Okay, I figure there might be some sort of issue with authenticating, or users, or something like that...
So rather than fiddling with credentials and trying to chown everything, I quickly created a user account on my NAS, which matches the default Raspbian user credentials.

Better test it out first to make sure it works manually...

Code: Select all

sudo mount -t cifs //192.168.2.119/0.5TB\ SG\ HDD\ 1  /var/0.5tbsghdd1 -o user=pi
Password: raspberry
so far so good.

Code: Select all

pi@raspberrypi ~ $ df -a
Filesystem                     1K-blocks      Used Available Use% Mounted on
rootfs                           1828696   1465252    270568  85% /
/dev/root                        1828696   1465252    270568  85% /
devtmpfs                           94488         0     94488   0% /dev
tmpfs                              18912       200     18712   2% /run
tmpfs                               5120         0      5120   0% /run/lock
proc                                   0         0         0    - /proc
sysfs                                  0         0         0    - /sys
tmpfs                              37820         0     37820   0% /run/shm
devpts                                 0         0         0    - /dev/pts
/dev/mmcblk0p1                     57288     16896     40392  30% /boot
//192.168.2.119/0.5TB SG HDD 1 480708340 212949452 229302224  49% /var/0.5tbsghdd1
pi@raspberrypi ~ $
alright! The new credentials work fine!

Having done that, I tried a new fstab line using the new credentials...

Code: Select all

//192.168.2.119/0.5TB\ SG\ HDD\ 1  /var/0.5tbsghdd1  cifs  user=pi,pass=raspberry,uid=1006,_netdev  0  0

Code: Select all

sudo mount -a
[mntent]: line 4 in /etc/fstab is bad
So I think to myself why dont I try to mount the share manually by name...

Code: Select all

sudo mount /var/0.5tbsghdd1
mount: can't find /var/0.5tbsghdd1 in /etc/fstab or /etc/mtab
sudo nano /etc/fstab

Code: Select all

proc                                     /proc                   proc    defaults                        0       0
/dev/mmcblk0p1                          /boot                   vfat    defaults                        0       2
/dev/mmcblk0p2                          /                         ext4    defaults,noatime        0       1
//192.168.2.119/0.5TB\ SG\ HDD\ 1  /var/0.5tbsghdd1  cifs  user=pi,pass=raspberry,uid=1006,_netdev  0  0
The mount point is in the fstab... plain as day....
The mount point absolutely exists within /var/...
Dedicated IP for the NAS...
The share mounts 100% correctly when done manually using either set of credentials...

I am completely lost...

Someone please help me... :shock:
ps. if i have broken any forum rules I apologize in advance. Just point out my error and I'll move the post.
pss. I have already read hundreds of search results regarding samba, cifs, fstab, mtab, mount, mount.cifs, and moun -t on this forum alone... google provided me with many thousands of others... I have done lots of homework and am now asking for help. Thankyou.
psss. If this turns out to be some stupidly easy fix I will probably eat my raspberry pi :lol:

itimpi
Posts: 1090
Joined: Sun Sep 25, 2011 11:44 am
Location: Potters Bar, United Kingdom
Contact: Website

Re: Cannot mount smb/cifs from fstab

Sat Nov 03, 2012 9:47 am

Have you tried using a share name without spaces in it so that they do not need escaping? I am not sure if escaping works in fstab (I have never used it).

User avatar
jojopi
Posts: 3270
Joined: Tue Oct 11, 2011 8:38 pm

Re: Cannot mount smb/cifs from fstab

Sat Nov 03, 2012 10:25 am

"man fstab" says you should use "\040" to include a space. Although even it does not expect you to need to do so in the device/remote field.

matsojr22
Posts: 4
Joined: Sat Nov 03, 2012 4:59 am

Re: Cannot mount smb/cifs from fstab

Sun Nov 04, 2012 1:13 am

Thank you for your replys!

I tried adding the \040 to each space, but it still gave me the bad line error.

Having lost the will to live I decided to try renaming all of my cifs/smb shares without spaces.
That works perfectly with the fstab!

The only bummer is that none of my terminals know where anything is at on the network now, so it will take a few days to rebuild database files for xbmc and sickbeard.

Conclusion:
My issue is SOLVED by removing the spaces from mount names in freeNAS. Once this was done, I could add the shares to fstab without any problems using the previously mentioned format.

Thanks again for your help!

User avatar
jojopi
Posts: 3270
Joined: Tue Oct 11, 2011 8:38 pm

Re: Cannot mount smb/cifs from fstab

Sun Nov 04, 2012 7:45 am

matsojr22 wrote:I tried adding the \040 to each space, but it still gave me the bad line error.
You should use \040 (meaning ASCII character octal 40) instead of a literal space, that is: "//192.168.2.119/0.5TB\040SG\040HDD\0401". This eliminates the bad line error, because it allows the line to be space separated into the correct number of fields.

matsojr22
Posts: 4
Joined: Sat Nov 03, 2012 4:59 am

Re: Cannot mount smb/cifs from fstab

Sun Nov 04, 2012 9:29 am

jojopi wrote:
matsojr22 wrote:I tried adding the \040 to each space, but it still gave me the bad line error.
You should use \040 (meaning ASCII character octal 40) instead of a literal space, that is: "//192.168.2.119/0.5TB\040SG\040HDD\0401". This eliminates the bad line error, because it allows the line to be space separated into the correct number of fields.
Yup, that's what I tried.
"//192.168.2.119/0.5TB\040SG\040HDD\0401"

I had tried this before posting here as well.
All of the documentation that I was able to find suggested that this method of dealing with spaces should have worked... sadly it did not. Thanks though jojopi, I appreciate you help very much :)

I would love to have found a workaround which did not include renaming my smb shares, but the damage is done and so, therefore, am I.

I apologize to anyone in the future reading this thread looking for a better solution to the same problem I had!
Renaming the shares was the path of least resistance for me, good luck :)

Jingles
Posts: 2
Joined: Thu Apr 18, 2013 8:39 pm

Re: Cannot mount smb/cifs from fstab

Thu Apr 18, 2013 8:44 pm

Spoke to soon! I have managed to mount my shares successfully and can now access them through the mount-place in xbmc (I'm using xbian). However, when trying to set things up with sickbeard/nzbGet they can't create any files on the directory, so I'm guessing I have not set the read/write access properly.

The user profile (xbian) has read/write privileges on the share and when edited the fstab i made sure i put rw in the options.

Code: Select all

//192.168.1.70/xbian /mnt/xbian cifs user=xbian,pass=raspberry,rw 0 0
Can anyone see what I'm doing wrong?

Hi matsojr22

I cannot say how happy I am to have found this thread. As a complete LInux noob I have being hunting hi and low on how to get my SMB share to mount at boot at this has finally solved the mystery!

However I do have one question, what do the last two options (uid=1001,_netdev) in you fstab entry do/mean? I have managed to mount my share without them, but do I need them?

matsojr22
Posts: 4
Joined: Sat Nov 03, 2012 4:59 am

Re: Cannot mount smb/cifs from fstab

Fri Apr 19, 2013 3:30 am

Jingles wrote:Spoke to soon! I have managed to mount my shares successfully and can now access them through the mount-place in xbmc (I'm using xbian). However, when trying to set things up with sickbeard/nzbGet they can't create any files on the directory, so I'm guessing I have not set the read/write access properly.

The user profile (xbian) has read/write privileges on the share and when edited the fstab i made sure i put rw in the options.

Code: Select all

//192.168.1.70/xbian /mnt/xbian cifs user=xbian,pass=raspberry,rw 0 0
Can anyone see what I'm doing wrong?

Hi matsojr22

I cannot say how happy I am to have found this thread. As a complete LInux noob I have being hunting hi and low on how to get my SMB share to mount at boot at this has finally solved the mystery!

However I do have one question, what do the last two options (uid=1001,_netdev) in you fstab entry do/mean? I have managed to mount my share without them, but do I need them?

Hey Jingles,
I had similar issues with permission, the last two option i was using were in an attempt to get things running smoothly. uid=1001 was the user identification number for my permissions. user matthew = uid #1001. I don't know if you need this or not, but at the time I was trying everything on earth to make things work. The later option, _netdev is pretty important. That option tells the fstab to wait for network connectivity before trying to mount the share. That way you dont get a failed mount just because raspbian (or whatever) tries to process the fstab before your network connection is complete.

In the end I abandoned SMB/CIFS and switched to NFS shares. You have no idea how much less of a hassle NFS is. I spent weeks trying to get this to work correctly and failed. I continued to have permissions errors no matter what I tried in sabnzbd+. The NFS shares took less than an hour to create in freeNAS/nas4free and the fstab worked first time using the format:

Code: Select all

192.168.2.119:/mnt/0.4tbsshdd1   /mnt/0.4tbsshdd1      nfs     defaults,_netdev     0    0
To save yourself the grief and frustration, I would suggest changing to NFS. It only took me a few hours to convert all of the devices on my network (2 desktops, 2 laptops, 2 ras pi's, and one huge NAS). Listed below is the lines I add to my fstab on all new devices:

Code: Select all

192.168.2.119:/mnt/0.4tbsshdd1   /mnt/0.4tbsshdd1      nfs     defaults,_netdev     0    0
192.168.2.119:/mnt/0.5tbwdhdd1   /mnt/0.5tbwdhdd1      nfs     defaults,_netdev     0    0
192.168.2.119:/mnt/1.5tbsghdd2   /mnt/1.5tbsghdd2      nfs     defaults,_netdev     0    0
192.168.2.119:/mnt/1.0tbsghdd1   /mnt/1.0tbsghdd1      nfs     defaults,_netdev     0    0
192.168.2.119:/mnt/2.0tbsghdd1   /mnt/2.0tbsghdd1      nfs     defaults,_netdev     0    0
192.168.2.119:/mnt/2.0tbsshdd1   /mnt/2.0tbsshdd1      nfs     defaults,_netdev     0    0
192.168.2.119:/mnt/2.0tbsshdd2   /mnt/2.0tbsshdd2      nfs     defaults,_netdev     0    0
192.168.2.119:/mnt/2.0tbwdhdd1   /mnt/2.0tbwdhdd1      nfs     defaults,_netdev     0    0
192.168.2.119:/mnt/3.0tbsghdd1   /mnt/3.0tbsghdd1      nfs     defaults,_netdev     0    0
It may not be the best way to do things... There might be some people who would scoff at my methods... but it has worked perfectly for me.

The two raspberry pi's run my usenet stuff. I have one model B rev.2 running sabnzbd+, and a model B rev.1 running sickbeard and headphones. They work pretty darn well for their purpose.
The only issue I have found so far is that sabnzbd needs to: run only one job at a time, pause downloads for job processing, and not preallocate folders. Besides that I only achieve about a 1-1.5Mb/s download speed, while my desktop can hit 3Mb/s.

I hope that some of that info helped.
You can check out some of the other hurdles I overcame on my site http://www.hobo-geek.com

(mods, if I am not allowed to post my site's web address just let me know so I can edit it out rather than delete the entire comment. Thank you!)

Jingles
Posts: 2
Joined: Thu Apr 18, 2013 8:39 pm

Re: Cannot mount smb/cifs from fstab

Fri Apr 19, 2013 11:47 am

Hey matsojr22,

Thanks for your reply. Unfortunately I am using an Apple AirPort Extreme to share my HD across my network and that doesn't support NFS :cry:

My goal is to get a proper NAS to store all my media on but I do not have the money to do this right now, but I will keep this post to hand for when that day comes. I guess in the mean time I'll just have to carry on plugging away trying to get my existing share working.

Cheers

jeffk
Posts: 3
Joined: Sat Apr 20, 2013 4:50 pm

Re: Cannot mount smb/cifs from fstab

Sat Apr 20, 2013 5:01 pm

I am having similar problem. I can mount using mount command
pi@raspberrypi ~ $ sudo mount //192.168.0.xx/media /mnt/video -t cifs -o username=user,password=pw

but can't seem to mount using edited fstab. any suggestions?
I am brand new with raspi and pretty new with linux

jeffk

DirkS
Posts: 10363
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Cannot mount smb/cifs from fstab

Sat Apr 20, 2013 6:50 pm

but can't seem to mount using edited fstab. any suggestions?
Can you show us exactly *what* you put in fstab?

Gr.
Dirk.

jeffk
Posts: 3
Joined: Sat Apr 20, 2013 4:50 pm

Re: Cannot mount smb/cifs from fstab

Sun Apr 21, 2013 3:12 am

yes. Here's what I put in. Tried a lot of different things
//192.168.0.xx/volume2/media /mnt/video username=username,password=password

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

Re: Cannot mount smb/cifs from fstab

Sun Apr 21, 2013 3:39 am

jeffk wrote:yes. Here's what I put in. Tried a lot of different things
//192.168.0.xx/volume2/media /mnt/video username=username,password=password
That's different to what you said you put in the manual mount command:

pi@raspberrypi ~ $ sudo mount //192.168.0.xx/media /mnt/video -t cifs -o username=user,password=pw

There's no "volume2" in the pathname there. Is that a typo, or did you copy/paste those two lines?

Also, on the fstab line, you don't seem to have the full entry. It should be something like this:

Code: Select all

//192.168.0.xx/volume2/media /mnt/video cifs username=username,password=password 0 2
There needs to be six fields for each entry, separated by spaces or tabs.

geejeej
Posts: 1
Joined: Thu May 09, 2013 2:48 pm

Re: Cannot mount smb/cifs from fstab

Thu May 09, 2013 2:54 pm

After a long search, I found that the insecure setting ",noperm" fixed my issues with NZBget in combination with a CIFS share for saving my downloads to.

My current setting inside /etc/fstab is:

Code: Select all

//192.168.x.x/SHARE /media/SHARE cifs directio,guest,rw,iocharset=utf8,noperm 0 0
As it turns out, there is something weird going on with permissions, even if you set everything to 0777, which I had before, you'll end up with NZBget not being able to access the files and create the appropriate directories.
I found this thread through google when searching for a solution, so I thought I would also post what worked in my case.

EDIT: somehow it still, or again, does not work... Anyone have any suggestions for CIFS on rpi?

Hi-Jack
Posts: 2
Joined: Thu Jun 07, 2018 11:50 am

Re: Cannot mount smb/cifs from fstab

Thu Jun 07, 2018 3:09 pm

Update notes, seeing that this came up on Google. I suffered the same series of frustrations mounting my Airport Time Capsule. I am running Raspberry Pi 3B+ on Rasbian Stretch released 14 March 2018 with standard GUI over a wi-fi connection.

Here is my fstab code line:

Code: Select all

//100.10.10.1/Data /mnt/timecapsule cifs username=********,password=******,vers=1.0,rw,uid=1000,iocharset=utf8,sec=ntlm 0 0
A few changes appears to have happened over time:
  • You need to add "vers=1.0" statement (it currently defaults to a later version 3.0, which appears tobe casuing problems)
  • _netdev does nothing on CFIS file system, only works on NFS file system, so it does not create the required delay for thenetwork to activate
  • "user=" and "pass=" should now be "username=" and "password=" respectively (Updates to kernel)
  • Lastly, there is now a "Wait for network" box that that can be ticked in the Raspberry Pi Configuration Utility, that solved my mount at boot problem.

After 2 days of struggles, mine is now finally mounted and does so at boot !

Return to “Troubleshooting”