Q: How to add a (Windows Server) network drive.

Discussion in 'Linux' started by Aviel, Aug 1, 2008.

  1. Aviel

    Aviel

    Joined:
    Aug 1, 2008
    Messages:
    17
    Likes Received:
    0
    Hello people.
    Yesterday I became the proud owner of a Acer Aspire one, i was satisfied.
    My only dissapointement was that Pesky OS it was deliverd with, Linpus.

    And now, to my question;
    On my network i have a storage/file server, to acces it in windows i normaly typed in internet explorer the ip, (\\192.168.0.111\) and it would promt me for a username and password. and gave me acces. i tried to do the same thing on my new Aspire One but all for not.

    Can someone please help me?

    Thanks in advance.

    Aviel O. :arrow:
     
    Aviel, Aug 1, 2008
    #1
    1. Advertisements

  2. Aviel

    hkalnes

    Joined:
    Aug 1, 2008
    Messages:
    15
    Likes Received:
    0
    Hi,
    I also wondered about this, since it's so easy to do on for instance Ubuntu.
    However, I came across a solution using the built-in tool mount.cifs (see http://linux.die.net/man/8/mount.cifs).
    This is a shell command that you may put into a shell script file.

    1) You need to create one dummy folder for each network share you want to use. For instance, in your home directory, create the folder NAS. You can do this with the file manager thunar (that opens with My Files in the main menu).

    2) Then, in your home folder, right click and select Open Terminal Here.

    3) Type the command su and then your password. This gives you the necessary rights.

    4) Now you can mount your share and map it to the folder you created earlier. Say you have the following parameters:
    Machine IP: 192.168.1.2
    Share name: files
    Local folder: NAS
    Username: MyName
    Password: MyPass

    Then the mount command will be the following:

    Code:
    mount.cifs \\\\192.168.1.2\\files NAS -o user=MyName,password=MyPass,uid=user,gid=user
    
    It's correct that there should double up with back-slashes.

    5. Leave the terminal by typing the exit command twice.


    I chose to put the mount commands for my shares into a shell script file Mount.sh in my home directory. So whenever I need my shares, I just double click that file. Then, you need to prefix the mount.cifs command with sudo, like this

    Code:
    sudo mount.cifs .....
    
    After creating the file with the Mousepad editor, I make it executable by right-clicking it, selecting properties and setting Open with to bash.

    If you use a wireless network, remember that you need to be connected before mounting the shares. This means that you cannot put the mount commands into a start up script.

    I also tried the tool pyNeighborhood, but found it easier to use the shell script approach above. If anybody knows a better - or easy way - I'd be happy to know.

    Good luck!
     
    hkalnes, Aug 1, 2008
    #2
    1. Advertisements

  3. Aviel

    fuzz

    Joined:
    Aug 1, 2008
    Messages:
    29
    Likes Received:
    0
    Location:
    Bristol, UK
    Thanks for that! Works great for me, although my nas uses guest logins so I had to use something like:
    Code:
    mount.cifs \\\\storagebox\\songs Songs -o guest
     
    fuzz, Aug 2, 2008
    #3
  4. Aviel

    hkalnes

    Joined:
    Aug 1, 2008
    Messages:
    15
    Likes Received:
    0
    There's also the possibility to make the mounts "permanent" by adding them to the /etc/fstab file, as explained in this post: http://www.aspireoneuser.com/forum/...99&sid=6f5f990ae0a79af33c37c534399810dc#p4864.

    According to guides out there, the auto option (default) should cause the share(s) to be automatically mounted at boot time. This seems not to be the case with Linpus, or there is something missing in the guide. As far as I can tell, you need to use the terminal command
    Code:
    sudo mount -a
    before you need your shares.

    Beware of the codepage option if you have file names in other languages than English. In Norway the Danish/Norewgian letters æøå often occur in file names, and code page 850 causes these letters to be displayed incorrectly. I deleted the codepage option, and it actually worked as it should.

    There is also an extra option _netdev which should defer mounting until a network connection is present. Since the shares aren't mounted automatically at boot time anyway, it seems to have no effect.

    The following guide is quite good, even if it's for openSUSE:
    http://www.swerdna.net.au/linhowtosambacifs.html
     
    hkalnes, Aug 4, 2008
    #4
  5. Aviel

    stevenross

    Joined:
    Aug 23, 2008
    Messages:
    1
    Likes Received:
    0
    I seem to be getting the following error when trying to map a network share using this method:

    'can not change directory into mount target share'

    I'm a total newbie to linux so this has thrown me. Any suggestions?

    Thanks.
     
    stevenross, Aug 26, 2008
    #5
  6. Aviel

    bigroma

    Joined:
    Aug 24, 2008
    Messages:
    1
    Likes Received:
    0
    One more way
    In terminal run

    #sudo yum -y install fuse-smb

    after this create mount point, for example

    #sudo mkdir /mnt/samba

    and run

    #sudo fusesmb -o allow_other /mnt/samba

    After this in /mnt/samba U have access to all workgroups

    Bigroma
     
    bigroma, Aug 27, 2008
    #6
  7. Aviel

    bciprez

    Joined:
    Aug 28, 2008
    Messages:
    3
    Likes Received:
    0
    Thanks much.. this really helped me out!!

    Is there a way to run the fuse-smb command at bootup so shares are avaialble at boot?
     
    bciprez, Aug 28, 2008
    #7
  8. Aviel

    Flux101

    Joined:
    Aug 11, 2008
    Messages:
    63
    Likes Received:
    0
    I had that problem, don't know what it was, but using the instructions on this page, it ended up working, I think it needed some extra parts in the command
    http://thatsquality.com/linux/mounting- ... using-cifs

    The command:
    sudo mount -t cifs //192.168.1.102/share_name /media/my_share -o username=theuser,password=thepass,iocharset=utf8,file_mode=0777,dir_mode=0777

    Are you trying to connect to Vista, by any chance? I was, perhaps it needs the 0777 chmod stuff at the end.
     
    Flux101, Sep 2, 2008
    #8
  9. Aviel

    dippergt750

    Joined:
    Aug 27, 2008
    Messages:
    8
    Likes Received:
    0
    Great instructions, but drive unmounts when the machine is rebooted/switched off. I've written a simple script to activate the mounting: in terminal I type:-

    cd /home
    sh ./script.sh

    But I can't execute it in XWindow. I have used:

    chown user script.sh

    and made the file executable then tried executing it. Nothing.
    I tried executing after "chown root script.sh" and still nothing.
    If I can have this file executable there is no problem, but otherwise I have to type "fusesmb -o allow_other /mnt/samba" every boot-up.

    It occurs to me that I may have completely the wrong file extension. My programming skills are INCREDIBLY limited - I have only ever written the odd .bat file on windows and I was under the impression that a .sh was the linux equivalent. perhaps give me a pointer on the correct extension?

    I'd like it simple to activate, is all.

    Anyone got any thoughts?
     
    dippergt750, Sep 2, 2008
    #9
  10. Aviel

    jukk

    Joined:
    Jul 31, 2008
    Messages:
    54
    Likes Received:
    0
    You can't run a shell script directly by pointing and clicking in the GUI. As the name implies, it has to run within the shell, e.g. a in a terminal. Extensions doesn't matter in Linux/Unix.
     
    jukk, Sep 2, 2008
    #10
  11. Aviel

    dippergt750

    Joined:
    Aug 27, 2008
    Messages:
    8
    Likes Received:
    0
    Okay, in that case can we think of an easy way to have it mounted after startup?
     
    dippergt750, Sep 2, 2008
    #11
  12. Aviel

    jmorales22

    Joined:
    Aug 7, 2008
    Messages:
    16
    Likes Received:
    0
    I'm sure it's not supposed to work like that in linux, but applying a windows approach works: you can rename the file to .sh, then right click to open it with bash, make sure it's checked to open with bash everytime, and there you have it... a shell script you can click on.
     
    jmorales22, Sep 3, 2008
    #12
  13. Aviel

    N6546R

    Joined:
    Aug 27, 2008
    Messages:
    126
    Likes Received:
    0
    N6546R, Sep 3, 2008
    #13
  14. Aviel

    gadgetmind

    Joined:
    Aug 1, 2008
    Messages:
    84
    Likes Received:
    0
    I'm working on a scheme to get fusesmb kicked off on boot and also a script that installs all of this automagically for people. Search for "fusesmb" for the thread where I#m woffling on about this, but I#ll make a guide once it's all working.
    Ian
     
    gadgetmind, Sep 10, 2008
    #14
  15. Aviel

    gadgetmind

    Joined:
    Aug 1, 2008
    Messages:
    84
    Likes Received:
    0
    OK, this is ready for testing, initially by someone who knows what they are doing. I have not yet tested this script as my wife won't allow me to potentially mess up the machine as I don't have time to fix it tonight. Also, this is already done on my machine, so it isn't a great test.

    Anyway, copy this text to a file in your home directory, start the terminal, use "chmod +x thefile" to make it executable, and then run with "./thefile" I have deliberately not given lots of detail here!

    I think you should be able to read this file and see what it's doing. Note the last line - if your workgroup has a different name, you'll need to change it. A release script would have this as an optional parameter. A release script can also be a tarball that can just be opened and the script executed.

    ----------------- starts here ------------
    #! /bin/sh
    # Move to users home
    cd ~
    # Exit script if anything fails
    set -e
    # Install fuse-smb
    sudo yum -y install fuse-smb
    # Create a mount point
    sudo mkdir /mnt/net
    # Create the xfce autostart file to run fusesmb at boot
    cat > Fusesmb.desktop <<EOF
    [Desktop Entry]
    Encoding=UTF-8
    Version=0.9.4
    Type=Application
    Name=Fuse
    Comment=Connect to Windows network
    Exec=/usr/local/bin/auto-fusesmb
    StartupNotify=false
    Terminal=false
    Hidden=false
    EOF
    chmod +x Fusesmb.desktop
    mv Fusesmb.desktop .config/autostart/
    # Create the script that keeps trying until fusesmb runs (it fails if the network isn't up)
    cat > auto-fusesmb <<EOF
    #! /bin/sh
    false
    until [ $? -eq 0 ]; do
    sleep 5
    sudo fusesmb -o allow_other /mnt/net
    done
    EOF
    chmod +x auto-fusesmb
    sudo mv auto-fusesmb /usr/local/bin/
    # Start fusesmb so user doesn't have to reboot
    sudo /usr/local/bin/auto-fusesmb
    # Create link - maybe not a good idea as workgroup might not be called HOME?
    ln -s /mnt/net/HOME Network
    ----------------- ends here ------------

    After this has run, you should have a folder in your home called "Network" that shows your workgroup. If you want shortcuts directly to machines, use your own version of "ln" to create them.

    Ian
     
    gadgetmind, Sep 10, 2008
    #15
  16. Aviel

    Guest Guest

    Ian,

    Tried using your script, some success, some failure.

    everything appear to work, and could indeed access ALL of the shared drives on my windows network, including those that periodically appear when for example my wifes laptop is on.

    What doesn't appear to work (for me at least) is the autostart entry, I ran xfce4-autostart-editor to check the autostart entry, and looks OK, but the link shows broken.

    sudo fusesmb -o allow_other /mnt/net, or re-run the script (the script will produce errors because the files and links already exist)

    auto-fusesmb is in the autostart folder, and I can confirm all the directories and files exist as per the script.

    Regards,

    Cookie.
     
    Guest, Sep 14, 2008
    #16
  17. Aviel

    sinc

    Joined:
    Sep 14, 2008
    Messages:
    17
    Likes Received:
    0
    Just one addition to hkalnes excellent post. This will be obvious to most but I'm adding this for all the newbies like me. When I tried to make the 'mount.sh' executable the way he/she says, I didn't have I didn't have 'Bash' as an option in the properties. Instead, I clicked on the permissions tab and checked 'allow this file to run as a program'. I can then double click to execute.
    Although we'd all like to see all our files without running a script, it's really not very inconvenient- you just leave the script file beside the NAS folder and run it before opening the folder, once each session.

    Thanks for your help.
     
    sinc, Sep 15, 2008
    #17
  18. Aviel

    GavinK151

    Joined:
    Sep 8, 2008
    Messages:
    14
    Likes Received:
    0
    Does anyone get "permission denied" responses with Fuse-smb?

    I installed it via add/remove software and can browse to my "workgroup" and see all the folders therein but whenever I try to access any fodler I get permission denied... they are unprotected as I can access them no problems on my other Linux system using Nautilus with no credentials....

    I ran:

    sudo fusesmb -o allow_other /mnt/samba

    then browsed to /mnt/samba in both the terminal and Thunar - same error.

    What have I missed!?

    thanks!
     
    GavinK151, Sep 18, 2008
    #18
  19. Aviel

    Marathon

    Joined:
    Aug 29, 2008
    Messages:
    21
    Likes Received:
    0
    The script has a small error which means that the auto start does not work (as Cookie reported). The problem is that the "$?" needs to be escaped in the original script otherwise it is just substituted as "0". Take a look in the generated /usr/local/bin/auto-fusesmb file and the line:

    until [ 0 -eq 0 ]; do

    should be:

    until [ $? -eq 0 ]; do

    [One can probably escape it with quotes or a \ but I haven't tried it!]

    Marathon
     
    Marathon, Sep 28, 2008
    #19
  20. Aviel

    gadgetmind

    Joined:
    Aug 1, 2008
    Messages:
    84
    Likes Received:
    0
    Oops, my bad. Here is a fixed version, and I have confirmed it writes auto-fusesmb correctly.

    Anyone who has a broken auto-fusesmb can edit it using "sudo mousepad /usr/local/bin/auto-fusesmb" and change the until line to have $? in place of the first 0.

    ----------------- starts here ------------
    #! /bin/sh
    # Move to users home
    cd ~
    # Exit script if anything fails
    set -e
    # Install fuse-smb
    sudo yum -y install fuse-smb
    # Create a mount point
    sudo mkdir /mnt/net
    # Create the xfce autostart file to run fusesmb at boot
    cat > Fusesmb.desktop <<EOF
    [Desktop Entry]
    Encoding=UTF-8
    Version=0.9.4
    Type=Application
    Name=Fuse
    Comment=Connect to Windows network
    Exec=/usr/local/bin/auto-fusesmb
    StartupNotify=false
    Terminal=false
    Hidden=false
    EOF
    chmod +x Fusesmb.desktop
    mv Fusesmb.desktop .config/autostart/
    # Create the script that keeps trying until fusesmb runs (it fails if the network isn't up)
    cat > auto-fusesmb <<EOF
    #! /bin/sh
    false
    until [ \$? -eq 0 ]; do
    sleep 5
    sudo fusesmb -o allow_other /mnt/net
    done
    EOF
    chmod +x auto-fusesmb
    sudo mv auto-fusesmb /usr/local/bin/
    # Start fusesmb so user doesn't have to reboot
    sudo /usr/local/bin/auto-fusesmb
    # Create link - maybe not a good idea as workgroup might not be called HOME?
    ln -s /mnt/net/HOME Network
    ----------------- ends here ------------

    Ian
     
    gadgetmind, Oct 4, 2008
    #20
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.