Announcement

Collapse
No announcement yet.

How to: Auto-Mount NAS or Windows share, maybe others as well....

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to: Auto-Mount NAS or Windows share, maybe others as well....


    Ok, for once I'm going to try and put the meat of the post up front, and put the fluff below. 11.10 a couple of days ago seemed to kill my my auto-mount of my NAS on both my computers running it, I started getting an error that said "only root can mount this" when trying to access it in dolphin.

    **Disclaimer: This worked for me, I can't promise it will work for you. Also my share has no security, or login's needed, if yours does this might not work, in fact most likely won't. But you can take what I have here, use smb4k like I did below under "fluff" to get a working mount, look at the mtab file I explain and build from there.**

    Now some background. I have a Dlink NAS that offers up the drive(s) as a single windows share named Volume_1. My dlink router gives it a STATIC IP (I suggest using static ip's if you want to mount a share) and the address is 192.168.0.100. The overall samba/windows share name is DLINKSTORAGE.

    That being said, there are really TWO addresses for this share:

    Code:
    //192.168.0.100/volume_1
    (this is the one linux itself and most non-dolphin or non-samba progams seem to like)

    Code:
    //DLINKSTORAGE/volume_1
    (this is the address that dolphin, samba, smbk4 and other smb share programs seem to use by defalut, but they all will work with the ipaddress also, so I suggest using that mostly)

    Ok, now for setting up the automount:

    You need to create a directory to mount into. I used to use /mnt/dlink for that when I first had it set up. However I used smb4k to mount it for the last few days and it created /home/justin/smb4k/DLINKSTORAGE and mounted it there, so I've been using that now that I've got it working again. Here is my working mount code:
    Code:
    //192.168.0.100/Volume_1 /home/justin/smb4k/DLINKSTORAGE/ cifs guest,_netdev 0 0
    Let's look at that real quick. From above I guess you can figure out the first part is the address, the second part is the directory I'm mounting into, and the last is code gibberish. Ok, well the cifs is the file type I'm mounting, and seems to be the most common for mounting shares. The guest means my share requires no password or username. _netdev tells fstab that it has to wait till you have a network connection before mounting the device. *** This code and section is an edit from the original. After I wrote this post my laptops took an update and my fstab stopped working. After 3 days of work I finally ran across the _netdev command and both laptop have been working fine ever sense. I didn't have to have that for the last 2 years, but I guess something changed. For me it's required to get fstab to automount this share. I've been testing for about 3 days and it's continued to work fine.***

    Now you need to put this little bit of code in the file called fstab (of course customized to YOUR setup, I can show you below a real easy way to get the code premade for you below in the fluff section). To do that in terminal type: (if you don't know what that is your not ready for this yet anyway)
    Code:
    kdesudo kate
    You can use most linux text editors I think, but I like kate and it comes stock in KDE. (EDIT: Thanks Vinny about showing me kdesudo, I had always used gksudo so I updated this section.)

    This will open you a root version of kate, you'll need that to make changes to root files like fstab (and pretty much everything else listed in /root)
    On a side note you can do the same thing with dolphin to delete and mess with stuff in root, just be wary.

    Now in kate click open, and navigate to /root/ect/fstab (it's a file not a directory) and open it.

    Now you paste your
    Code:
    //192.168.0.100/Volume_1 /home/justin/smb4k/DLINKSTORAGE/ cifs guest,_netdev 0 0
    at the bottom of this file, make sure you hit ENTER at the end of the line you just pasted in so that the flashing cursor is on the line BELOW the code, and hit save then your done!!!

    That's all it takes, now with the way it worked BEFORE 3 days ago this would mount the share as a "drive" and if you navigated to /home/justin/smb4k/DLINKSTORAGE/ you would find all the stuff on the share in there like a normal directory.

    ~Fluff to follow~
    So when this first happened I just couldn't get it to mount at all, however the code I was using in fstab then was

    Code:
    //192.168.0.100/volume_1/  /mnt/dlink  cifs  guest,uid=1000,iocharset=utf8,codepage=unicode,unicode 0 0
    to be honest I'm not sure all I tried there at the first, but I did remove this from fstab and download smb4k. After adding the setting for mount as superuser it worked like a charm, and I even had it load on boot, and it worked great, until I realized my laptop wouldn't sleep if it had a share mounted. I spent two day trying to write sleep scripts, I finally got it to kill smb4k when going to sleep, and it would sleep, but I couldn't get it to run it again on wake, so after pulling my hair out with sleep scripts I started trying to get it to umount and mount it again. I happened to notice umount said something about no entry in mtab, so I looked up mtab and after playing for a bit I figured out mtab is a list that is updated in real time of all the drives mounted on the machine. So keeping it open with kate I could watch and see if the system was loading my mount commands or not. And when I loaded smb4k I could see how it used the code in there, so I copied it and started playing with it. Here is what smb4k used in the mtab file.
    Code:
    //DLINKSTORAGE/volume_1/  /home/justin/smb4k/DLINKSTORAGE/volume_1  cifs rw 0 0
    However if I pasted that into fstab and ran a sudo mount it said "Address //DLINKSTORAGE/volume_1/" invalid, or not found, or something. So I changed it to \
    Code:
    //192.168.0.100/volume_1
    Then that was fixed, but it gave me an error that /home/justin/smb4k/DLINKSTORAGE/volume_1 "didn't exist". And it was right, the directory structure didn't have a volume_1 in it, it ended at DLINKSTORAGE. So I deleted volume_1 off it. I don't know why it worked for smb4k, but not for fstab, but that's how it went. After then when I mounted and umounted it corrrecty mounted and unmounted the drive. And since I"m not using smbrk anymore, but letting the system auto-mount it sleeps fine with the share mounted. I liked smb4k, but I like my computer to sleep when the lid is closed more. But it did help me find a "code" for fstab that work.....

    My Homesite<br />My Blog

    #2
    Re: How to: Auto-Mount NAS or Windows share, maybe others as well....

    looks like a wonderful how to......nice work and looks good to me .

    BUT ware you reference
    gksudo kate
    that is the Gnome way.

    in Kubuntu you use
    Code:
    kdesudo kate


    VINNY
    i7 4core HT 8MB L3 2.9GHz
    16GB RAM
    Nvidia GTX 860M 4GB RAM 1152 cuda cores

    Comment


      #3
      Re: How to: Auto-Mount NAS or Windows share, maybe others as well....

      Ahhh... I've always used gksudo.... I'll try kdesudo next time....

      On another note, this DOESN'T work, it was my gksudo, or sudo'ing something that was mounting it, weird but true. What I've figured out is it doens't mount until I do something that asks for a password, and the moment I enter one in, doing ANYTHING that ask's it mounts........ I'm going to dig into that....
      My Homesite<br />My Blog

      Comment


        #4
        Re: How to: Auto-Mount NAS or Windows share, maybe others as well....

        ok, got this updated to what is working for me now. Got rid of the parts that didn't apply anymore, and added kdesudo.
        My Homesite<br />My Blog

        Comment


          #5
          Re: How to: Auto-Mount NAS or Windows share, maybe others as well....

          Very interesting. I'm trying to automount, via fstab, an apple time capsule and the mounts are not completing via fstab. Manually, they do. I have "auto", "_netdev", nobootwait, cifs as parameters. Any thoughts? I have a forum entry with the fstab entries.

          Comment

          Working...
          X