8

Yesterday I was able to mount my smb share with the following command:

sudo mount -t cifs //XXXX/share /media/share -o user=Ben,password=XXX,workgroup=WORKGROUP,ip=XXX.XX.XX,uid=ben,gid=ben,rw

I don't know why it is not working anymore. (Maybe from system update).

I got the following error :

mount: only root can mount //XXX.XXX.XXX/share on /home/ben/share

I don't know how to fix this problem..

I've also tried to mount it with su -, and Smbclient is working.

I'm Running ArchLinux.

Ben D
  • 671
  • 3
  • 11
  • 26
  • 1
    What is the output of `echo "$EUID"`? – Chris Down Mar 01 '12 at 20:53
  • Have you tried doing `sudo su -` and then run the same command? – Karlson Mar 01 '12 at 21:46
  • 1
    @ChrisDown echo $EUID = 1000 – Ben D Mar 01 '12 at 22:45
  • 7
    @BenD - In which case you are not effectively running as root. (Obviously this should be run in the same environment as you are trying to mount in, so you should make sure it is the root shell that is expanding `$EUID`.) – Chris Down Mar 01 '12 at 22:46
  • @Karlson I've tried sudo su- but same result – Ben D Mar 01 '12 at 22:49
  • @ChrisDown How can I check that ? – Ben D Mar 01 '12 at 22:50
  • `sudo su -c 'echo "$EUID"'` should do it. – Chris Down Mar 01 '12 at 22:52
  • @ChrisDown When I type su -c and then echo $EUID I got 0 – Ben D Mar 01 '12 at 22:53
  • @ChrisDown The weird thing is that when I try to mount a local disk it works. – Ben D Mar 01 '12 at 22:56
  • Samba may act weird if something _else_ is incorrect. Check your credentials, DNS, domain name, etc, add verbose logging. Maybe the problem is not in EUID at all. – 9000 Mar 02 '12 at 03:00
  • All of these are correct, I can loggin using smbclient and see the content of my HDD. Another solution ? – Ben D Mar 02 '12 at 09:23
  • 3
    Why is the path different between the error message and the mount command? One is `/media/share` and the other is `/home/ben/share`. Also, I recomment using `/mnt` for manual or static mounts. `/media` was created for the HAL/udev daemons to mount dynamically created disks like a USB drive. – penguin359 Mar 02 '12 at 19:19
  • @penguin359 It's just a copy error. Thanks for the 'mnt' advise. However it's still not working. – Ben D Mar 03 '12 at 00:47
  • 1
    As @9000 mentioned, see what verbose mode says by adding a -v to your mount command. Also check your system logs if you haven't already, and dmesg, and perhaps run an strace on the command for deeper troubleshooting. – Banjer Mar 04 '12 at 15:38
  • I doubt this is related, apparently [a change in samba disabled setuid](https://bugs.gentoo.org/315445?id=315445) — but this should not be relevant at all if you are already running it with EUID=UID=0... – njsg Mar 05 '12 at 10:40
  • Does it have to be samba, have you tried sshfs? – Mark D Mar 06 '12 at 16:12
  • Have you tried mounting in another path instead /media/share? let´s say something like: /mnt/mysamba? – Mariano Montañez Ureta Mar 07 '12 at 20:23
  • Try being root on remote computer? – Not a Name Mar 10 '12 at 18:17

2 Answers2

0

If you don't know, what is happen, try strace:

sudo strace -f -F -o mount.strace mount -t cifs //XXXX/share /media/share -o user=Ben,password=XXX,workgroup=WORKGROUP,ip=XXX.XX.XX,uid=ben,gid=ben,rw

Then try search file mount.strace from bottom for some errors, you will obviously found reason... It is hard method, I know...

Jan Marek
  • 3,837
  • 1
  • 14
  • 12
0

As I don't see any proper reason for your error, I would propose a slightly different syntax.

First I will create a new directory as root (to be sure root can create it) and then mount the share with slightly different options. Here are the commands (they should all succeed):

sudo mkdir /mnt/smb_share
sudo touch /mnt/smb_share/test && sudo rm -f /mnt/smb_share/test && echo "Permissions are OK"
sudo mount -t cifs //(hostname)/share /mnt/smb_share -o user=Ben,domain=(WORKGROUP)

The mount command should ask you for your Samba user Ben password. I have removed the uid and gid options just to remove some "noise". With this command you should be able to verify that you can mount the share. Of course you need to replace:

  • (hostname) by the share server hostname. If it does not work with the hostname, try again but use the IP address instead;
  • (WORKGROUP) by your workgroup or domain.

If this work. Try unmounting the share and remounting it with uid only:

sudo umount /mnt/smb_share
sudo mount -t cifs //(hostname)/share /mnt/smb_share -o user=Ben,domain=(WORKGROUP),uid=ben

If this is working, add the gid, then add the rw and then finally add the password option (step by step). So you can identify which of the options is not understood.

Huygens
  • 8,985
  • 3
  • 31
  • 36