Skip to content

Auto mount folders with CIFS at startup

Setup shared folders with CIFS and mount automatically at startup. This worked for me within Ubuntu. For example, the shared folder can be on a NAS or a file server.

  1. Run the following command:

    # Open your terminal application
    sudo apt-get update
    sudo apt-get install cifs-utils
  2. Create the folder to which you want to point the mount
    Section titled “Create the folder to which you want to point the mount”

    This can be a shared folder from your NAS of fileserver. Run the following commands:

    # Open your terminal application
    cd /mnt
    sudo mkdir -p fileserver/archive
    cd /home # Go to home where in step 4 .smbcred will be saved
    # IMPORTANT: Please read the instructions below
    Instructions:
    • Required Replace fileserver/archive with your own folder
  3. /etc/fstab
    # To edit use your text editor application, for example Nano
    //fileserver/archive /mnt/fileserver/archive/ cifs vers=3.0,credentials=/home/.smbcred,file_mode=0777,dir_mode=0777,iocharset=utf8,nofail 0 0
    # IMPORTANT: Please read the instructions below
    Instructions:
    • Required Replace //fileserver/archive with your shared folder, for example the folder on your NAS or fileserver
    • Required Replace /mnt/fileserver/archive/ with the local folder you created earlier to point the mount to
  4. Save the credentials to a separate .smbcred file
    Section titled “Save the credentials to a separate .smbcred file”
    /home/.smbcred
    # To create this script use your text editor application, for example Nano
    username=<username>
    password=<password>
    # IMPORTANT: Please read the instructions below
    Instructions:
    • Required Replace <username> with your username of the shared folder (on the file server or NAS)
    • Required Replace <password> with your password of the shared folder (on the file server or NAS)
  5. Run the following command:

    # Open your terminal application
    sudo mount -a

    No comments found for this note.

    Join the discussion for this note on Github. Comments appear on this page instantly.

     Copyright 2021-2026 Fiction Becomes Fact