cifs mount from fstab

Hi,

I have two cifs shares that I would like to mount on every boot. My /etc/fstyab entries look like this:


//192.168.0.2/media  /mnt/media           cifs       _netdev,users,auto,uid=reg,gid=users    0 0
//192.168.0.2/data   /mnt/data            cifs       _netdev,users,auto,uid=reg,gid=users    0 0

The shares don’t get mounted but once I have logged on, I can mount them with “mount -a” without any problem… what’s going on here?
Thanks!
Ron

Only thing I can think of is that your network is not up until very late in the process. I see you have ‘_netdev’ included, but not always sufficient. You may need to add a cron job to take care of ‘mount -a’ automagically. Workaround as dicussed (see FAQ: Tricks for a Slow Network) here:

Samba: HowTo Mount a CIFS Network Share [AKA Map Network Drive] in openSUSE 10 & 11 plus FAQs

Thanks to Swerdna.

Yup, this makes sense, I knew that… but still, I was looking for a “clean” solution that apparently doesn’t exist… anyways, it says to add @reboot sleep 10;mount -a to the crontab - why “@reboot” and
why are we adding it to crontab at all? wouldn’t it be nicer to make an own init script and start it at the end of init 5&3?

On SUSE if you want to write an init script it should conform to the template in /etc/init.d/skeleton. It’s a little bit more complicated than on other systems. The crontab method is a quick-and-dirty solution. The hardwired 10 in sleep 10 should alert you to that fact. @reboot is a special “time” recognised by cron, as um, at boot time, see man 5 crontab.

Well alright, i added it to my crontab now even tho i don’t like it too much… and why don’t i actually need to define root as user? don’t get that either, why is it not
@reboot root sleep 10;mount -a?

Because there are two kinds of crontab. The first kind are the ones edited by crontab -e where the user is known. Then there is the system crontab /etc/crontab and the extensions in /etc/cron.d where the user can be specified per job. These have the extra 6th field. This fact is buried in man 5 crontab:

Each line has five time and date fields, followed by a user name if this is the system crontab file.

Okay, yups, thanks but anyways, on reboot my smb mounts still weren’t mounted, I had to manually run a mount -a again… :frowning: Any other clues?

I assume you’ve already tried increasing the sleep time?

Nope not yet as I can’t reboot my pc that often… i’m working now and i need it, i’ll try that for sure, thanks :slight_smile:


Okay, my /etc/crontab now looks like:
reg@desktop-reg:~> cat /etc/crontab
SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root
#
# check scripts in cron.hourly, cron.daily, cron.weekly, and cron.monthly
#
-*/15 * * * *   root  test -x /usr/lib/cron/run-crons && /usr/lib/cron/run-crons >/dev/null 2>&1
@reboot sleep 30;mount -a
reg@desktop-reg:~>

And guess what, I still need to manually make a mount -a after the boot in order to get my shares mounted, what’s going on here?

Thanks,
Ron

You weren’t paying attention. As I explained, /etc/crontab is one of those crontabs that requires the user in the 6th field, well after the time in this case, which is @reboot. So it should be:

@reboot root sleep 30;mount -a

If you look in /var/log/cron you will probably see errors saying no such user ‘sleep’.

It may not fix the problem, but it’s a start.

Hoops, yup, sorry :shame:
I don’t have such a log file: /var/log/cron … i’ll be reporting after the next reboot which probably won’t happen tonite anymore.
Thanks anyways dude! :slight_smile:

Simplest solution in my opinion to have samba shares mounted during boot is to not use “Network Manager” to manage network connections only “Traditional Method with ifup”. To set it, go to YaST, then to Network Settings, change Network Setup Method to “Traditional Method with ifup” then go to next tab “Overview” select interface and press Edit then in tab “Addresses” either leave DHCP or set static and set your connection accordingly. On first tab General there is information that interface is up on boot time and that is before fstab is executed. You can change it however default settings here is exactly what one need to mount samba shares on boot time. It works for me very well.

You just resurrected a FIVE YEAR OLD THREAD.

Miuku, this has been happening a lot lately. Three days in a row of very old threads.
Very disconcerting, and now I add a few more moments (to check the dates of the posts) before continuing reading the post.