Mapping network drives in Ubuntu from Windows domain (script)

Chat about Linux in general
Post Reply
DiegoCorleone
Level 1
Level 1
Posts: 1
Joined: Sat Mar 23, 2019 9:13 am

Mapping network drives in Ubuntu from Windows domain (script)

Post by DiegoCorleone » Sat Mar 23, 2019 9:15 am

New Hi,


First of all, inform you that I am the most novice level that there is in Linux, I am starting in this world, and I am trying to perform a task.


After getting to put a Linux machine in a domain with Active Directory in Windows, I get to map the network units manually, however, my idea would be to make that when the session is already mapped. On Windows I use some .bat scripts, and when I log in, I'm already loaded with network drives and I wanted to get something like that on my Ubuntu computer.


I wanted to know, if you already use this method and know what is the philosophy to map automatically network units that are in a Windows domain on user logons from Ubuntu computers.


My question is, its possible in Ubuntu to do this, or in this aspect is it limited? For example, in the issue of permissions, in Ubuntu there are three types of permissions, however in Windows they can be put on demand. So my question is if in Ubuntu it is possible to do what I want to do, not to fight or spend time on something that maybe is not possible.


Thank you and I hope you have explained correctly.

User avatar
Moem
Level 19
Level 19
Posts: 9553
Joined: Tue Nov 17, 2015 9:14 am
Location: The Netherlands
Contact:

Re: Mapping network drives in Ubuntu from Windows domain (script)

Post by Moem » Sat Mar 23, 2019 9:17 am

Mod note:
Moved to the Chat area because this is not about Linux Mint.
Image

If your issue is solved, kindly indicate that by editing the first post in the topic, and adding [SOLVED] to the title. Thanks!

User avatar
AndyMH
Level 9
Level 9
Posts: 2641
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Mapping network drives in Ubuntu from Windows domain (script)

Post by AndyMH » Sat Mar 23, 2019 9:25 am

First you need to install samba if it is not already installed.

You can modify your fstab file to automatically mount network shares - there is some information here viewtopic.php?f=157&t=290553

Or you could use a utility like autoFS which is explained here viewtopic.php?f=42&t=144997&hilit=samba
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate

rene
Level 12
Level 12
Posts: 4320
Joined: Sun Mar 27, 2016 6:58 pm

Re: Mapping network drives in Ubuntu from Windows domain (script)

Post by rene » Sun Mar 24, 2019 4:24 am

Note, autofs is basically obsolete in these systemd days. See e.g. viewtopic.php?f=50&t=290507#p1610717; be sure to use type "cifs" for Windows/Samba shares. E.g.

Code: Select all

//NAME_OR_IP/ShareName          /mnt/share  cifs    noauto,guest,vers=1.0,x-systemd.automount,x-systemd.mount-timeout=10s,x-systemd.idle-timeout=10m

altair4
Level 19
Level 19
Posts: 9738
Joined: Tue Feb 03, 2009 10:27 am

Re: Mapping network drives in Ubuntu from Windows domain (script)

Post by altair4 » Sun Mar 24, 2019 12:16 pm

Since this is in the Chat section of the forum for some reason I have my own question. The only reason I prefer autofs for certain conditions vs the systemd method is that it can still do something that systemd cannot.

It does the auto-mount part just fine and as expected. What it cannot do is auto-unmount - at least for cifs mounts.

I have this set up in a Mint test box:
//gort.local/public /mnt/Test cifs noauto,guest,vers=1.0,x-systemd.automount,x-systemd.mount-timeout=10s,x-systemd.idle-timeout=10s 0 0
I connect to the share by accessing /mnt/Test, then close the file manager, and continue to run mount | grep Test at 5 minute intervals or so. It's been 45 minutes as of this post and it is still mounted.

AutoFs in this scenario will unmount precisely when I told it to unmount.

Is cifs incompatible with all of the features of a systemd automount?
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

rene
Level 12
Level 12
Posts: 4320
Joined: Sun Mar 27, 2016 6:58 pm

Re: Mapping network drives in Ubuntu from Windows domain (script)

Post by rene » Sun Mar 24, 2019 1:37 pm

Are you sure? Works fine for me:

Code: Select all

rene@t5500:~$ grep readyshare /etc/fstab
//READYSHARE/USB_Storage    /mnt/readyshare     cifs    noauto,noexec,guest,uid=rene,gid=rene,vers=1.0,x-systemd.automount,x-systemd.mount-timeout=10s,x-systemd.idle-timeout=10s
rene@t5500:~$ mount | grep readyshare
systemd-1 on /mnt/readyshare type autofs (rw,relatime,fd=57,pgrp=1,timeout=10,minproto=5,maxproto=5,direct,pipe_ino=1420)
rene@t5500:~$ ls /mnt/readyshare/
Music  Pictures  Videos
rene@t5500:~$ mount | grep readyshare
systemd-1 on /mnt/readyshare type autofs (rw,relatime,fd=57,pgrp=1,timeout=10,minproto=5,maxproto=5,direct,pipe_ino=1420)
//READYSHARE/USB_Storage on /mnt/readyshare type cifs (rw,noexec,relatime,vers=1.0,sec=none,cache=strict,domain=,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.1.1,soft,unix,posixpaths,serverino,mapposix,acl,rsize=61440,wsize=65536,echo_interval=60,actimeo=1,x-systemd.automount)
rene@t5500:~$ sleep 10
rene@t5500:~$ mount | grep readyshare
systemd-1 on /mnt/readyshare type autofs (rw,relatime,fd=57,pgrp=1,timeout=10,minproto=5,maxproto=5,direct,pipe_ino=1420)
I.e., please note, the "systemd-1" mount on the mountpoint means the actual share is unmounted. Also, if you edit fstab you'll need to unmount the share and

Code: Select all

# systemctl daemon-reload
# systemctl restart remote-fs.target
(or reboot) to have the changed rule active: systemd converts fstab to mount units only when starting up...

altair4
Level 19
Level 19
Posts: 9738
Joined: Tue Feb 03, 2009 10:27 am

Re: Mapping network drives in Ubuntu from Windows domain (script)

Post by altair4 » Sun Mar 24, 2019 1:53 pm

Pretty sure.

I'm not saying it doesn't work as an absolute. It works just as you described it on say ... Manjaro. Just not in Ubuntu or Mint. Never checked Debian itself.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

rene
Level 12
Level 12
Posts: 4320
Joined: Sun Mar 27, 2016 6:58 pm

Re: Mapping network drives in Ubuntu from Windows domain (script)

Post by rene » Sun Mar 24, 2019 2:00 pm

Well, certainly the above example was just now executed on this here Linux Mint 19.1 Cinnamon 64-bit system. Works For Me...

If it doesn't for you I'd assume something is keeping the mount busy. lsof might help to show what.

Post Reply

Return to “Chat about Linux”