Jan 18

How-to: Mount a Network drive in Ubuntu

Tag: linux,ubuntuScott Wegner @ 3:16 am


Recently, one of my roommates bought an external network drive, so everyone in the house can upload their music and movies. It’s hooked right into the network through the router so it’s easy for anyone to access– pretty cool stuff. It was pretty simple to setup in Windows, but it took a little bit of research for Ubuntu. Specifically, we have Maxtor “Shared Storage II” hard-drive, and I wanted it to auto-mount each time I reboot my computer. I figured it out using the tutorial here, but the basics are below.

  1. First you will need to install the “smbfs” package. This is what we will use to mount the drive.

    sudo aptitude install smbfs

  2. We will also need a folder to mount the drive in. I used /media/public.

    sudo mkdir /media/public

  3. Then, we need to edit /etc/fstab. This is where we add all the information needed to find and mount the drive. Open /etc/fstab using the command:

    gksudo gedit /etc/fstab

    At the end of the file add the following lines:

    # Mount our network drive
    //SERVER/SHARE /MOUNT-POINT smbfs guest 0 0

    Where “SERVER” is the name of your drive on the network. This can be either a name or IP address. For example, mine was “MAXTOR”. Replace “SHARE” with the folder in the drive you’d like to mount– mine was “Public”. “MOUNT-POINT” is the directory we created earlier, such as “/media/public”. The rest of the parameters have to do with permissions, and also where you can add advanced options. For more information on the advanced preferences, see

    man mount.smbfs

  4. The final step is to tell the system to reload /etc/fstab and mount our drive. Do this with the command:

    sudo mount -a

    Then, you’re done! At this point you should be able to see the files in your drive with the command

    ls /MOUNT-POINT

Share:
  • Digg
  • Facebook
  • Reddit
  • StumbleUpon
  • email
  • Twitter

15 Responses to “How-to: Mount a Network drive in Ubuntu”

  1. 6regmcc says:

    Thanks the guide relay helped it was very easy to follow thanks, But to mount a drive with permissions on you will need to create a text file with just the following in it

    username=yourusername
    password=yourpassword

    save it with a-name.smbcredentials and at the end of the line you add to etc/fstap on the line is
    credentials=/home/greg/passw.smbcredentials
    //SERVER/SHARE /MOUNT-POINT smbfs credentials=/path/to/a-name.smbcredentials or in my case
    //192.168.1.3/Share /home/greg/Harddrive smbfs credentials=/home/greg/passw.smbcredentials

  2. Jim says:

    Thanks for helping me on my way to getting my NAS mounted in Ubuntu.

    Sadly you didn’t have quite enough information for users of older NAS hardware like myself.

    Some older hardware it seems returns the error message “mount error 5 = Input/output error” which for me was frustratingly difficult to track down a solution for. I eventually stumbled across http://public.ok2life.com/welcome/index/75 and found my answer.

    So to make the command

    # Mount our network drive
    //SERVER/SHARE /MOUNT-POINT smbfs guest 0 0

    work for older hardware it should look like

    # Mount our network drive
    //SERVER/SHARE /MOUNT-POINT smbfs guest, nounix 0 0

    Hope this helps some more folk as it took me literally days to find the solution.

  3. eric says:

    I get to the “gksudo gedit /etc/fstab” but, it does nothing, so i try opening it maunally and putting in the lines but it says, “Can’t open file to write”.

  4. richard says:

    Thanks – looking for ages for this!

  5. BJ Turnner says:

    How I get the IP or the Name of my Network Drive on the net. when I run sudo mount -a , I get error message
    mount error: could not resolve address for SERVER: No address associated with hostname
    No ip address specified and hostname not found

    Please any help is appreciated !

  6. Maverick Steel says:

    I’ve got the same problem as BJ Turner. The path I’m using I get from nautilus. In the folder, it appears as smb://mybookworld/public, so I added
    //mybookworld/public /media/networkshare smbfs guest 0 0

    I get the error:
    Warning: mapping ‘guest’ to ‘guest,sec=none’
    mount error: could not resolve address for mybookworld: No address associated with hostname
    No ip address specified and hostname not found

    So I replaced ‘guest’ with my username, and that got rid of the first part. The “mount error:” / “no ip address specified” errors remained.

    I also tried putting in various combinations of capital letters into the address, since the folder reads as MYBOOKWORLD/PUBLIC when browsing with nautilus (though not in the address, strangely). Also tried using \\mybookworld\public, in case it was formatted for windows or something. I’m not sure if I should be able to do this, but I can’t cd to the directory either using that address.

  7. Stacey says:

    Just add the name and IP address of your NAS to /etc/hosts unless you use DHCP of course.

  8. Linux commands – for Daily usage | Синеочко says:

    [...] Mount a Network Drive in Ubuntu [...]

  9. the dsc says:

    BJ Turnner, changing the hostname for an IP may work. But of course it will not be good if the IP keeps changing. I’m not being able to make it work as it was supposed to. Funnily enough, I can access the machine via smb:/hostname on konqueror, but I can’t make a fstab mont.

  10. Danish says:

    very very helpful

    thanks all

  11. Ubuntu « awayfromwindows says:

    [...] Samba einrichten [...]

  12. JonathanSFL says:

    Using Ubuntu 10.04LTS
    Why must I use the IP address to mount a (Win2K3 Svr) network drive using CIFS or SMBFS?
    I have the Windows server in my /etc/hosts file as: my_hostname_which_pings_fine 192.168.1.40
    pinging hostname: my_hostname_which_pings_fine returns a solid ping
    WORKS:
    [CODE]
    sudo mount -t cifs //192.168.1.40/Photos /media/mnt_club_id_images -o username=replication,password=mypassword
    sudo mount -t smbfs //192.168.1.40/Photos /media/mnt_club_id_images -o username=replication,password=mypasswordsudo mount -t
    [/CODE/
    FAILS:
    [CODE]
    sudo mount -t cifs //my_hostname_which_pings_fine/Photos /media/mnt_club_id_images -o username=replication,password=mypassword
    sudo mount -t smbfs //my_hostname_which_pings_fine/Photos /media/mnt_club_id_images -o username=replication,password=mypasswordsudo mount -t
    [/CODE]

    when i run the failing commands at command prompt I get error:
    [ERROR]
    mount.cifs kernel mount options: unc=//bst_webserver\Photos,ver=1,rw,username=replication,nounix,ip=192.168.1.40,pass=********
    mount error(5): Input/output error
    Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

    Why does the hostname use fail but the IP Address use succeeds??

  13. ron hyatt says:

    This is the kind of thing that turns people off linux. This should be a checkbox or right click menu item “logon to this drive every boot” when you mount it.

  14. How-to: Mount a Network drive in Ubuntu | automaticable | muistiinpanot says:

    [...] How-to: Mount a Network drive in Ubuntu | automaticable. This entry was posted in Uncategorized. Bookmark the permalink. ← How to install firefox 5 on ubuntu | Ubuntu Geek [...]

  15. [Ubuntu] Mount a share says:

    [...] so, I'm guessing you need to install smb/Samba on your Ubuntu machine. This might shed some light How-to: Mount a Network drive in Ubuntu | automaticable Reply With Quote   [...]

Leave a Reply