Page 1 of 1

[SOLVED] Mount share with cifs on boot

Posted: 29 June 2013, 0:40
by viking
I have those lines in fstab:

Code: Select all

//white/video /mnt/white/video cifs guest,_netdev,sec=ntlm,iocharset=utf8 0 0
//white/audio /mnt/white/audio cifs guest,_netdev,sec=ntlm,iocharset=utf8 0 0
When I reboot machine, nothing happen. Folders /mnt/white/video and /mnt/white/audio are empty.

Those works without any problem:

Code: Select all

mount.cifs //white/video /mnt/white/video cifs -o guest,_netdev,sec=ntlm,iocharset=utf8 0 0
mount.cifs //white/audio /mnt/white/audio cifs -o guest,_netdev,sec=ntlm,iocharset=utf8 0 0
What I am doing wrong? :cry:

EDIT: I forgot to add this info Rosa 2012.1 R1 x86_64 with 3.9.8-nrjQL-desktop-69rosa kernel

Re: Mount share with cifs on boot?

Posted: 29 June 2013, 11:23
by GvMariani
I had the same problem when I switched from Mdv 2010.2 to Rosa 2012.1...
I suspect that the culprit is the use of the autofs service: it is involved in the FS mounting business and
while I did not have it on the old setup, now is used by default.

But after some unsuccessful tries to find clear docs or how-to about how to configure autofs to mount cifs shares, I gave up and added the line

Code: Select all

mount /mountpoint
to the rc.local script file...

Now it WFM.

GvM

Re: Mount share with cifs on boot?

Posted: 29 June 2013, 20:36
by viking
GvMariani wrote:I had the same problem when I switched from Mdv 2010.2 to Rosa 2012.1...
I suspect that the culprit is the use of the autofs service: it is involved in the FS mounting business and
while I did not have it on the old setup, now is used by default.

But after some unsuccessful tries to find clear docs or how-to about how to configure autofs to mount cifs shares, I gave up and added the line

Code: Select all

mount /mountpoint
to the rc.local script file...

Now it WFM.

GvM
You can forget about autofs and you can also remove that line from rc.local.

I found a proper solution!!! :D

For impatient people, who just want to see solution as soon as possible, here it is:

Code: Select all

[viking@gemstone ~]$ sudo systemctl enable remote-fs.target
I use sudo all the time, since I am lazy to type "su -" and to type root password every time i need root access. :)

Please notice that for kernels starting with 3.8, you need to have something like sec=ntlm or sec=ntlmv2 or you will not be able to mount drive with cifs.

If you omit sec= parameter, you will get error like this:

Code: Select all

mount error(38): Function not implemented
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
You will also need to add _netdev in order to make system wait for network, before trying to mount shares.

---

And here is full story for people who are interested in how I came to this solution. :)

This laptop is used by my wife and son, and was Windows machine until 2 days ago. It is used like desktop replacement, so I wanted to provide them access to shares without a need to mount anything manually.

First I tried to manually mount the share in order to figure out what to add in fstab.

When I tried to mount share I got error

Code: Select all

[viking@gemstone ~]$ sudo mount.cifs //white/audio /mnt/white/audio cifs -o guest,iocharset=utf8 0 0
mount error(38): Function not implemented
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
I did some digging and fount out that problem exists only on latest kernels (past 3.8) and that fix is very easy, just add sec= parameter.

After I successfully mounted shares I tried to add those lines in fstab.

I also added _netdev to be sure that network is on before system try to mount share.

I hoped that this is the end, but that was just a beginning.

I tried to add every param that I could imagine in fstab but haven't found anything useful.

Then I found some old articles that points that problem might be in inactive netfs service.

So I did a check.

Code: Select all

[viking@gemstone ~]$ sudo chkconfig --list netfs
netfs           0:off   1:off   2:off   3:on    4:on    5:on    6:off   7:off
Since it looks like it is starting on inits 3 and 5, this was signal that something might be wrong with netfs service itself.

I tried to start it manually.

Code: Select all

[viking@gemstone ~]$ sudo service netfs start
Starting netfs (via systemctl):  Failed to issue method call: Unit netfs.service is masked.
                                                                [FAILED]
OOOOOOOOOOPS!!!

Looks like it can not be started, so I tried to find out what this masked thing is.

When I searched for "service is masked" on web I found this very useful info:

systemd – boot faster and cleaner with openSUSE 12.1

I decided to check if we also have systemd on ROSA.

I tried what I learned from that article:

Code: Select all

[viking@gemstone ~]$ sudo systemctl status netfs.service
netfs.service
          Loaded: masked (/dev/null)
          Active: inactive (dead)
This confirms that we have systemd on ROSA now.

Then I checked man page of systemctl to find out more about masked feature:
mask [NAME...]
Mask one or more unit files, as specified on the command line. This
will link these units to /dev/null, making it impossible to start
them. This is a stronger version of disable, since it prohibits all
kinds of activation of the unit, including manual activation. Use
this option with care.
So that's it. Someone doesn't want us to use netfs anymore, so there must be another way to do this.

Another search "systemd netfs", and another useful info.
You should not need nefts at all, this is dealt with by systemd internally (there is remote-fs.target, if you want to order anything after it).
So I cheked remote-fs.target status:

Code: Select all

[viking@gemstone ~]$ sudo systemctl status remote-fs.target
remote-fs.target - Remote File Systems
          Loaded: loaded (/lib/systemd/system/remote-fs.target; disabled)
          Active: inactive (dead)
            Docs: man:systemd.special(7)       
This looked like good sign.

I tried to start it with:

Code: Select all

[viking@gemstone ~]$ sudo systemctl start remote-fs.target
Shares was mounted!

I just needed a way to do it permanently, so I tried:

Code: Select all

[viking@gemstone ~]$ sudo systemctl enable remote-fs.target
ln -s '/lib/systemd/system/remote-fs.target' '/etc/systemd/system/multi-user.target.wants/remote-fs.target'
and rebooted!

IT WORKS!!!

Thank you for your patience.

Re: [SOLVED] Mount share with cifs on boot

Posted: 29 June 2013, 23:09
by azioga
Thank you for this mini-howto

Ciao, Luca.

Re: [SOLVED] Mount share with cifs on boot

Posted: 29 June 2013, 23:31
by viking
azioga wrote:Thank you for this mini-howto

Ciao, Luca.
You are welcome.

btw. When I write something like this, I can always remind myself if I forget how or why something should be done. :D

Re: Mount share with cifs on boot?

Posted: 30 June 2013, 15:51
by GvMariani
viking wrote: You can forget about autofs and you can also remove that line from rc.local.
I found a proper solution!!! :D
IT WORKS!!!
Thank you for your patience.
Thank you for the good suggestion...
it works indeed.

GvM