Ubuntu: auto mount samba network shares on boot via smbfs & fstab



Increasingly all of my data is stored on a network server which allows me to access it from multiple devices/platforms and to reduce local storage for each device. Having migrated recently from Windows XP to Ubuntu 11.10 for my main desktop workstation I want to automatically mount my network based data currently hosted as a Windows share on a samba server when my Ubuntu system boots up. Here's how...



fstab (/etc/fstab) is the *nix file systems table, a system configuration file commonly found on *nix systems. The fstab file lists all available disks, disk partitions, network shares and indicates how they are to be initialised or otherwise integrated into the overall system's file system. The fstab file is used by the mount command, which reads the fstab configuration to determine which options should be used when mounting the specified devices.


The disks, partitions and shares defined in fstab are mounted at boot time unless they have been explicitly stated not to be mounted automatically. In order to auto mount the Windows based samba network shares on boot fstab needs to be updated. Since I am using samba shares a further package smbfs is required.


smbfs is a mountable SMB filesystem for Linux, it does not run on any other systems. smbfs has not been maintained in the last few years. Instead, development has been focused on another implementation of the CIFS protocol in the kernel. I should probably be using CIFS but I haven't had the opportunity to look into it yet and smbfs functions adequately. Eventually I wish to move away from samba to NFS as my number of Windows machines diminishes and to reap the performance of NFS.


1. Install smbfs now cifs-utils


sudo apt-get install cifs-utils



2. Create the path that you wish to mounted the network share at


mkdir /your_mount_path


for me I wanted the network shares to be mounted at /server/data so I used..


mkdir /server/data



2. Edit fstab


sudo gedit /etc/fstab


Add:


//path to your windows share/    /your_mount_path cifs username=your_username,password=your_password,workgroup=your_workgroup,users,auto,user_xattr 0 0 


Save and exit.



3. Test it works by either rebooting or using


mount -a


this mounts all the file systems described in fstab. Except those which are marked as ``noauto'', "late'' (unless the -l option was specified), those excluded by the -t
  flag (see below), or if they are already mounted (except the root file system which is always remounted).



To be revised to include NFS at a later date.

5 comments:

  1. Excellent article - my set up from Ubuntu 10 was:

    //xx.xx.xx.xx/path /mount path cifs -o username=xx,password=xx,noperm,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0

    and it was not working - the form you are using worked like a charm

    ReplyDelete
  2. smbfs has been replaced with cifs-utils, use the following at step 1.

    sudo apt-get install cifs-utils

    ReplyDelete
  3. I know of no words which can express my gratitude. I am overwhelmed by your kindness!
    카지노사이트

    ReplyDelete
  4. Much obliged to you for the post with colossal rundown imparted to us. best essay writing service in USA It is useful and exceptionally accommodating. Searching for additional. Much thanks to you

    ReplyDelete

Note: only a member of this blog may post a comment.