2

I'm trying to mount a samba share on a Ubuntu 12.04 desktop from a Fedora 17 desktop.

I can create, edit and delete files with no problem but when I try to run python scripts on the share i get a permission denied error.

I've tried mounting as root and using sudo with the following commands:

mount -t cifs //192.168.0.3/homeshare netbook -o user=james

mount -t cifs -o exec //192.168.0.3/homeshare netbook -o user=james

the file permissions have a . after them but i cant find out what that means

-rw-rw-r--. 1 james james 31804 Aug 14 18:20 cronlog.txt

-rwxrwxr-x. 1 james james   666 Aug 16 17:49 current.py

How can I mount this share in Fedora 17 and run scripts?

1
  • 1
    I'm using Fedora 17 too and I can run scripts over a Samba share mounted with mount -t cifs -o guest //ntinstall...tld/superuser /mnt/cifs/superuser. As for the permissions, the original looks like -rwxr-xr-x. 1 root root 41 Aug 19 06:28 /srv/superuser/script1.py and the mounted one like -rwxr-xr-x. 1 root root 41 Aug 19 06:28 /mnt/cifs/superuser/script1.py. I'm using samba-3.6.6-92.fc17.1.i686 for the server and cifs-utils-5.6-1.fc17.i686 for the client, along with kernel-PAE-3.5.2-1.fc17.i686. Aug 19, 2012 at 3:34

2 Answers 2

3

I would not use samba to connect two linux machines. Samba is designed to let linux/unix machines communicate with windows and vice versa. NFS is much better for two linux machines. You can probably tweak the samba settings to allow you to execute scripts, but you really will be better off using a native linux method. On my system, I have the same directory exported using samba (for the windows on my home network) and nfs for the linux and OSXes.

To export a directory using nfs, first, on both server and client, install autofs5 and nfs-common (the autofs is used to automatically mount/unmount the share as explained below). On the server, install nfs-kernel-server.

Then (all these commands should be run as root):

  1. Create the directory you will export, eg /nfs_shares:

    sudo mkdir /nfs_shares
    
  2. Set up the export rules. On the server, edit /etc/exports and add these lines:

    /nfs_shares       192.168.0.XX(rw,sync,no_subtree_check)
    

    Where 192.168.0.XX is the client's (your Ubuntu Desktop) IP.

  3. Mount (bind) the directory you will export to this new location. First add this line to /etc/fstab:

    /path/to/exported/homeshare /nfs_shares bind bind 0
    

    Then, mount it:

    mount /nfs_shares
    
  4. On the client, create the directory where you will mount the share (e.g. /mnt/homeshare):

    mkdir /mnt/homeshare
    

    At this point you should be able to manually mount the share. On the client:

    mount -t nfs 192.168.0.XX:/nfs_shares/ /mnt/homeshare
    
  5. Now, lets automate. On the client, create a file called /etc/auto.master with these lines (change SERVERNAME to whatever you want to call it):

    +auto.master
    /mnt/homeshare  /etc/auto.SERVERNAME   --timeout 60 --ghost
    
  6. On the client, create a file called /etc/auto.SERVERNAME (change SERVERNAME to whatever you used in step 4) with these lines (you can use the server's network name or IP if static, change the XXs for whatever is your server's IP):

    homeshare  -rw,soft,intr,bg,rsize=8192,wsize=8192 192.168.XX.XX:/nfs_shares/homeshare
    
  7. Run it! On the server, run service nfs-kernel-server restart and on the client run service nfs-common restart; service autofs restart

So, this makes it so the share is mounted automatically. If it is incative for one minute it will be unmounted and remounted as soon as you try to access it (eg ls /mnt/homeshare). Make sure you set the permissions the way you need them (chmod) for the directories you use.

7
  • Hi, Thanks for the detailed response. Your right something native probably would be better. I'm only using windows for gaming now. I've tried setting up NFS but am getting permission denied when mounting the share. I've set up a fedora 17 minimal install no gui and installed nfs-utils system-config-nfs then added /home/james 192.168.0.6(rw) 192.168.0.4(rw) to /etc/exports the restart nfs [root@hal etc]# service nfs restart Redirecting to /bin/systemctl restart nfs.service when I mount the share from my desktop i get permission denied? sudo mount.nfs netb:/home/james /home/james/netbook
    – James
    Aug 18, 2012 at 12:22
  • I just realised the permissions on the directory I'm mounting to are changing drwx------. 3 1001 1001 4096 Aug 18 2012 netbook
    – James
    Aug 18, 2012 at 12:34
  • @James Hang on, do you get the permission error when you try to mount or when you try to access the mounted share? Is netb the name of the fedora server? Have you tried mounting using the server's IP instead?
    – terdon
    Aug 18, 2012 at 15:35
  • netb was ubuntu 12 but I installed fedora 17 minimal. I was getting the error when I tried to list the directory. The UID and GID didnt match as it was a directory in a home directory so have sorted that now. Its working and tomorrow I'm gonna set up the auto part. Thanks for you help.
    – James
    Aug 18, 2012 at 23:38
  • @James You're very welcome, glad to hear you sorted it out. And +1 for figuring out the /etc/exports bit. I had forgotten that step, sorry, I've now updated my answer to include it.
    – terdon
    Aug 19, 2012 at 3:05
0

If you don't care too much about performance and some quirks, there's also the option of using SSHFS.

With Nautilus it's very easy. Go to File, Connect to Server..., select SSH as the type, fill in the details and that's it. The share will be mounted under /run/user/james/gvfs/. To unmount it, go to Computer in Nautilus, right click the share and select Unmount.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .