Pages

Saturday, June 27, 2009

Connecting Ubuntu to a Belkin N+ USB drive

After a lot of trouble, I eventually manage to mount a USB drive connected to my Belkin N+ router. This worked no problem on Windows, but failed under linux. From a quick google, it looks like I'm not the only person to have this problem so thought I would write up how to fix it.

Background
This site has a lot of useful information on it about mounting samba CIFS as supported by the Belkin N+: http://opensuse.swerdna.org/susesambacifs.html

The problem

The Belkin is named "BELKIN N+" which includes a space which breaks many of the linux UI/command line tools.

Details you need:
  • YOUR_ROUTER_IP - the IP address you've assigned to your router
  • YOUR_ROUTER_LOCAL_DOMAIN - the domain under LAN > LAN Settings on router
  • YOUR_DRIVE_NAME - the name of your connected drive (in my case FreeAgent)
GUI connection
Install smb4k then you can mount using the relevant details, but you need to manually mount as the spaces prevent the browser working. Add with the following:
  • Share: //BELKIN N+/FreeAgent
  • IP Address: YOUR_ROUTER_IP
  • Workgroup: YOUR_ROUTER_LOCAL_DOMAIN
Ad-hoc Mount
To mount ad-hoc use:
sudo mount -t cifs -o guest,ip=YOUR_ROUTER_IP,domain=YOUR_ROUTER_LOCAL_DOMAIN,_netdev,mand "//BELKIN N+/FreeAgent/" /media/FreeAgent/
  • The quotes are needed due to spaces in the server and if your drive's name has space in it.
  • Remember to create /media/FreeAgent with 777 permissions.
To automount on startup
You need to add this into /etc/fstab (sudo gedit /etc/fstab). As you cannot put quotes around command line instructions you need to replace spaces with "\040" instead:

//BELKIN\040N+/FreeAgent /media/FreeAgent/ cifs guest,ip=YOUR_ROUTER_IP,domain=YOUR_ROUTER_LOCAL_DOMAIN,_netdev,mand
  • _netdev is important as it waits until network is ready before mounting the drive.
  • To unmount cleanly on shut down, you need to run the following
    sudo update-rc.d -f umountnfs.sh remove
    sudo update-rc.d umountnfs.sh stop 15 0 6 .

8 comments:

  1. Newbie Works great with smb4k even under gnome! Not brave enough to stick it in my etc/fstab. Mainly 'cos I'm not sure what the ref to _netdev means! Thanks for any extra info

    Regards

    ReplyDelete
  2. Works like a charm. You could also add the router ip address in /etc/hosts. And let it point for example BELKIN_N+. This resolves the name issue too. Great guide thx.

    ReplyDelete
  3. Thanks! I found it just as easy to install smb4k and place it in my startup applications. I used the GUI once to mount the USB drive and checked the "add this share to bookmarks" box,and now I can mount it anytime by right-clicking on the smb4k icon and choosing Belkin from the bookmarks.

    (Auto-mounting on a notebook that's often on a different network altogether sounds like a PitA waiting to happen anyway.)

    ReplyDelete
  4. Thank you muchly. I was going a little batty; using "guest" in the fstab was an obvious step, but not one I thought of.

    ReplyDelete
  5. I'm getting a mount error(13). Any ideas?

    ReplyDelete
  6. I forgot to turn on email notification so only just spotted these questions!

    Rob

    I'm no longer using the drive on ubuntu but you'd create the directory with:

    sudo mkdir -p -m 777 /media/Aigo


    Dan

    Not very sure about that error, is the mount directory 777 permission and you're not including extra spaces between domain=xxx? Does the UI approach work?

    ReplyDelete
  7. Simon

    You asked about the _netdev flag, from the mount man:

    _netdev
    The filesystem resides on a device that requires network access (used to prevent the system from attempting to mount these filesystems until the network has been enabled on the system).

    ReplyDelete