Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Auto mounting network drive after wireless conn is established

  1. #1
    Join Date
    Nov 2008
    Beans
    9

    Auto mounting network drive after wireless conn is established

    Hi everybody.
    I only connect to the network after I login and connect my wireless card .. I was wondering if there is a way to auto-mount a network drive after this connection has been established. or maybe with a delay after booting or logging in.

    Thank you very much in advance for any help ...

  2. #2
    Join Date
    May 2005
    Beans
    335
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Auto mounting network drive after wireless conn is established

    How good are you at scripting?

    If I* were attempting this I'd probably write a simple bash script to check the SSID of my wireless network (to make sure it's the right one, so I don't try to mount shares that don't exist) and to check whether they are already mounted. Then just make it run as a cron job.

    * I say "If I..." for a reason: I'm not the best scripter in the world and there may also be a much easier way to do this that I'm unaware of.

  3. #3
    Join Date
    May 2007
    Beans
    161

    Re: Auto mounting network drive after wireless conn is established

    You don't say how you are sharing you files. If you are using Samba, you should be able to see your files on demand, whenever you open the share from the desktop, once you connect.

    If you are sharing files FROM a *nix machine only to *nix machines, you can use NFS to share your files. See: <http://nfs.sourceforge.net/nfs-howto/>

  4. #4
    Join Date
    Nov 2008
    Beans
    9

    Re: Auto mounting network drive after wireless conn is established

    ohzopants :
    -----------
    I'm not that good at scripting but I am a fast learner
    and I would appreciate it if you could show me a sample script of how to do that. What interests me in your approach is that you check if you were connected to the right network before attempting the mount.

    bford16 :
    ---------
    I am using Samba. The network folders are on NAS (Network attached storage) which is of NTFS format.
    I don't get how you can see the files (Drives) from the desktop before you do the mounting ?!

  5. #5
    Join Date
    May 2007
    Beans
    161

    Samba from Linux to any OS

    PowerEngine,

    You don't say what your network mix is, but I am going to assume that your shared folders are hosted on a Linux machine.

    Ubuntu has some graphical front-ends for Samba, but I have found that the surest way to get folders shared is to edit /etc/samba/smb.conf. Since 'gedit' is installed, you might as well use that. Press Alt+F2, then
    Code:
    gksudo gedit /etc/samba/smb.conf
    There are three things to edit.

    Workgroup. You may want to set up a workgroup if you share to Windows machines.

    Security (in the 'Authentication' section. Setting security=user will force users to enter a username and password to access the shared folders.

    Finally, you need to enter something to show Samba what you want to share. Somethig like this, added to the end of the file, will work just fine.
    Code:
    [shared]
    path = /media/shared/shared
    available = yes
    browsable = yes
    public = yes
    writable = yes
    This sets up a shared folder, accessible by all users, with read&write access.

  6. #6
    Join Date
    Nov 2008
    Beans
    9

    Re: Auto mounting network drive after wireless conn is established

    Hi Pros .. before we get all technical let's have some popcorn

    alright ..down to business ..


    my network is like the following :

    Laptop :
    ---------
    OS : Ubuntu.
    Connectivity method : wirelessly connected to the network.

    This is my personal laptop and it is not the file server.

    NAS ( Network attached storage ):
    ---------------------------------
    Disk format : NTFS
    Connectivity method : connected to the router with an ethernet cable.

    - This is the file server (the folders that I want to mount are hosted here)
    - This is a home network, the NAS ip address is internal (192 ..etc )


    The wireless connection is established after logging in -> entering the password of the wireless network.

    I hope this info is more clear and helpful in defining the problem.

  7. #7
    Join Date
    May 2005
    Beans
    335
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Auto mounting network drive after wireless conn is established

    I'd really rather not provide you with a sample script, since I really have no idea where to even start. I know it can be done, but I'm just not that good and (no offense) I'm not going to google it for you. Check out iwconfig for figuring out which network you are connected to.

    You may want to look at a program called smb4k. It's a KDE program, but it still runs fine in Gnome. It's a very nice little samba graphical frontend for mounting windows shares.

    Also (I'm on a windows pc, so some of the wording may be off a little), try going to Places -> Connect to Network (...?). This should pop up a dialog box asking about the details of your server and if you connect successfully once it should then be listed under Places. From then on when you click on that server under places your drives should be mounted automagically.

  8. #8
    Join Date
    Nov 2008
    Beans
    9

    Re: Auto mounting network drive after wireless conn is established

    Thanks ohzopants .. the Places -> Connect to Network .... is a decent solution. it does the trick for me.

    But I noticed that when I do this mounting ubuntu takes longer to halt and restart. I looked at the "boot" log , but it says nothing has been added yet.

    Just to complete the topic .. is there a way to umount the mounted automatically before halting ( restart or power off ) ?

  9. #9
    Join Date
    Oct 2008
    Beans
    38

    Re: Auto mounting network drive after wireless conn is established

    I think i can help you. I recently did the same type of thing. I have windows shares on my network that i want to mount automatically. At first i wrote a bash script and did the trick but i still was running the bash script to mount them.

    The thing to do is to edit your fstab. This is located at /etc/fstab. You will want to add a line like this:

    //netbiosname/sharename /media/sharename cifs credentials=/root/.smbcredentials,iocharset=utf8,file_mode=0777,dir_ mode=0777 0 0

    The smbcredentials file is a file you make with your user and pass for the shares. The format of the file is:

    username=YOURUSERNAME
    password=YOURPASSAWORD

    This file can be put anywhere and make sure that you use a . in front of it so that it is hidden. Its really quite easy. After editing the fstab you can type sudo mount -a or restart your computer.

    For all the information you need about this check out this awesome post: http://ubuntuforums.org/showthread.php?t=288534
    Last edited by sauce345; November 18th, 2008 at 11:56 PM. Reason: no correct

  10. #10
    Join Date
    Nov 2008
    Beans
    9

    Re: Auto mounting network drive after wireless conn is established

    Thanks sauce345 .. but this only works if you are connected with ethernet. because the network connection has to be established before linux reads the fstab to mount the partitions. otherwise it will not be able to recognize the network address 192..... and thus won't mount all the partitions in the fstab.

    On the other hand ohzopants's approach works in a situation similar to mine.
    ----------------

    The only thing though is that I am not able to find the location where samba mounts these network folders.. I only see them in my places menu and a shortcut on my desktop..but I don't know where they are mounted in the filesystem.
    I need to know the mount location because on my network folder I have a TrueCrypt folder, and I need to know the path to feed it to TrueCrypt to mount my volume from the network folder.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •