Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to mount some smb shares on bootup using fstab on a Kbuntu box. Here are the steps I using to accomplish this:

sudo mkdir /mnt/MyShare

Then I add this line to my fstab file:

//myserver/myshare /mnt/MyShare smbfs username=user1,password=password1 0 0

However after restarting the /mnt/MyShare folder is removed. If i re-create this directory and run sudo mount -a, everything works fine. Can browse the share. But when I reboot, /mnt/MyShare is gone.

Any hints as to what I am doing wrong?

share|improve this question
    
If you don't get a answer here, try the Ubuntu SE, since the more Ubuntu-wise people hang over there... –  Stefan Sep 13 '10 at 17:07
1  
@Stefan does encouraging people to split their resources really help? –  xenoterracide Sep 13 '10 at 17:43
    
@Stefan do you think is could be a *Ubuntu issue? I thought it would be just my misunderstanding of Linux fstab work-flow. If get no answer after awhile, ill try that. –  mxmissile Sep 13 '10 at 17:55
    
@xeno, just trying to be helpfull :) the behaviour of the /mnt/share directory does seem a bit odd... unless HAL is involved.. –  Stefan Sep 13 '10 at 18:41
    
@Stefan HAL might be... KDE still uses it. –  xenoterracide Sep 13 '10 at 20:58

2 Answers 2

up vote 6 down vote accepted

I don't think you should be using /mnt in this way. According to the Filesystem Hierarchy Standard;

This directory is provided so that the system administrator may temporarily mount a filesystem as needed. The content of this directory is a local issue and should not affect the manner in which any program is run.

This directory must not be used by installation programs: a suitable temporary directory not in use by the system must be used instead.

A permanent mount, specified in fstab, should go somewhere else.

Note that current Ubuntu systems use subdirectories in /media for removable disks, and /mnt is always left as an empty directory for manual, one-off mounts. I suspect that Ubuntu is enforcing this, or at least facilitating it, by deleting and recreating it on each startup.

I suggest you create a new root-level directory /network and put your permanent network mounts in there. You may be able to get away with putting them in /media, but it's probably better to leave that for use by the system. Using /network as the prefix nicely labels yours as network drives.

share|improve this answer
    
I would mount it in /home creating a new root directory outside of the FHS is probably wrong. I also suspect there is a way to tell KDE to mount on login. –  xenoterracide Sep 13 '10 at 21:01
    
The FHS constraints distributions, not to administrators. Administrators are warned that distributions may like to have ownership of areas described by the FHS, such as /usr and /var. /mnt is explicitly left to the administrator (/media was created because people couldn't agree on whether to use /mnt as a mount point or as a directory containing mount points). If a distribution doesn't let an administrator create mount points as subdirectories of /mnt, it's broken wrt the FHS. –  Gilles Sep 13 '10 at 23:23
    
@xenoterracide: I just took another quick look at FHS and I don't see anything about not putting additional directories in /. The purpose of the standard is to enable different Unix systems to agree on where to put things, and what to provide, not to constrain the inclusion of additional things. Using /home doesn't feel right to me, since it's primarily for user's home directories. –  Neil Mayhew Sep 13 '10 at 23:36
1  
@Gilles: The FHS says, "This directory is provided so that the system administrator may temporarily mount a filesystem as needed" (emphasis mine). Even if the directory is recreated on every startup, the temporary aspect of the FHS is still being respected. A /mnt directory is provided and you are free to make subdirectories as desired: "The content of this directory is a local issue and should not affect the manner in which any program is run." Using /mnt or a subdirectory of it as a permanent mount point is clearly out of line with the FHS. –  Neil Mayhew Sep 13 '10 at 23:38
1  
Has anyone been able to find where exactly ubuntu is clearing /mnt? I did a quick grep through /etc/init/, /etc/init.d/, and /etc/udev/rules.d/ and didn't find any references to "mnt". –  Steven D Sep 13 '10 at 23:40

Is setting up a permanent SMB mount really the right thing to do? Modern desktop environments like KDE and GNOME allow you to bookmark network shares and accessing them becomes a single click or menu selection. The username and password for the share can then be stored in the user's keychain. This is much better than putting names and passwords into fstab, which can be read by anyone.

share|improve this answer
    
Yes, but we have a console app that needs access to a smb share to retrieve files. Using fstab makes it hands off for our users. It's an internal read-only share with known credentials so I would assume its green in this situation. –  mxmissile Oct 26 '10 at 22:40
    
@mxmissile: There are console programs smbclient and smbget that might be an alternative to using fstab. You can pass username and password on the command line, and disable world-read on the scripts . –  Neil Mayhew Feb 12 '11 at 5:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.