[SOLVED] Solution to SMB "Operation not permitted" - Printable Version

+- Forum (
+-- Forum: Software (/forum-6.html)
+--- Forum: Configuration (/forum-17.html)
+--- Thread: [SOLVED] Solution to SMB "Operation not permitted" (/thread-1883.html)

Solution to SMB "Operation not permitted" - beeftube - 11th Dec, 2013 12:28 PM

Hello people.

I'm new here -- in fact today I just tried out XBian for the first time. I'd used RaspBMC for a few months before now, but I'd found a few issues that had popped up in recent builds that seemed to be mum from the devs about fixes (not bashing them, I'm sure they're busy with other things), so I was looking for something else.

The first major issue I noticed with XBian was the inability to add SMB/CIFS shares. More accurately, my inability to add them, as I'm not sure if this is occurring with everybody. Having used Linux and other Unix-like systems since the mid-1990's, however, a workaround wasn't too hard for me to find.

In searching for solutions to this problem, I noticed others having similar issues. They found some OK solutions (such as restarting xbmc as root), but I think there's a cleaner way. In this post I'll highlight what to do if you run across them.

My particular problem:
When I'd go to add my SMB share via Videos -> Files -> Add, then selecting Windows Network (SMB), I could browse my workgroup, find the Windows machine with the configured CIFS share, but when clicking on it I would receive a window with the text "Operation not permitted".

To me, this looked like XBian is simply populating the window contents with the direct output of some shell command that it's executing on the back end. In fact, there's lots of things you can execute on the command line of any Linux system that would spit out the same error. This usually occurs when a user does not have sufficient permissions to execute a specific action -- I'm guessing that whatever XBian is attempting to do in the background (mount the CIFS share?) is being executed as the "xbian" user, and not a user with sufficient privileges to do that specific action, and thus the error.

Other workarounds:
When looking for solutions to this initially, I'd found some other suggestions including updating packages (eh... maybe) and re-launching the underlying xbmc process as root via the command line (no). I don't like these approaches for a few reasons:

1) My packages were already up to date (I'm running the latest XBian build at the time of this posting, which seems to pull in the standard Raspbian repos as well as some of its own), and the two packages suggested to be updated in other posts should not affect this behavior anyways, and

2) Relaunching the xbmc process as root is a brute-force maneuver. It's the strong-arm solution -- sure, it works, but it's almost like cheating. It also just feels wrong being a long-time user of unix-like systems, and there was no obvious way to make XBian repeat this behavior on boot (maybe updating some init scripts, but I didn't look into it that far, because I didn't like the solution). Plus, the actual "xbmc" process that was being talked about, I couldn't find in the latest build of XBian anyways... so screw it.

My proposed workaround:
My proposed workaround is rather simple, but does require just a little bit of command-line-fu. If you're scared of a command line, you may want to enlist the help of somebody who's not, just to be sure. I'm happy to help others work through these problems, but preferably not because of basic usage issues with a Linux command prompt in general.

First, make sure you're receiving some sort of "Operation not permitted" error when you attempt to add an SMB share via the normal method using the XBMC GUI. This may also apply to NFS shares, as well, but I didn't test that.

Second, make sure you've got SSH enabled on your XBian pi, and then SSH into it with the 'xbian' user. The default password is available via a google search (unless you've changed it). How to SSH will be out of the scope of this thread.

Third, sudo to the root user and make your directory structure for your mounted shares. In general, these shares seem to be mounted under the "/media" directory normally (if things were working as intended), so we'll be working from there. Make a directory under "/media" which will be named whatever you'd like to call your share.

Note that in my example below, I will be mounting two shares; one for "Movies", and one for "TV", so I'll make those two directories accordingly:

xbian@xbian ~ $ sudo su
[sudo] password for xbian:
root@xbian:/home/xbian# cd /media
root@xbian:/media# mkdir Movies TV
root@xbian:/media# ls
Movies    TV

Fourth, try to mount your share manually from the command line, as root. If this works, proceed to the next step. If it doesn't work, then it's very likely that there is either a connectivity issue between the XBian pi device and the device hosting the SMB/CIFS share, or there are permissions issues with the user you are connecting to the share as. Check those on the Windows host and try again, or examine event logs on the Windows side (outside of scope for this post).

The below example is for mounting an SMB/CIFS share. Mounting an NFS share is similar, but you would replace "cifs" with "nfs". Make sure you replace "USERNAME" and "PASSWORD" in the below examples with your username and password on the Windows host you are connecting to. Similarly, replace the IP address of the Windows host with what you are connecting to.

root@xbian:/media# mount -t cifs -o ro,username=USERNAME,password=PASSWORD // Movies/

...if you didn't see any output, great. The command worked. You should be able to cd into the directory you just mounted, do an ls, and see all of your content. If that worked, then move on to the next step. If it didn't, then check connectivity, permissions, etc. on the remote Windows host.

Make another directory and mount other shares as needed for your environment.

Fifth, let's make sure that Xbian mounts this share every time it boots up. For this, we simply need to make an entry in /etc/fstab for every share we need to mount to get to our media.

Before doing this, we'll make a file called "smbcredentials" under /home/xbian. This file will contain the username and password for the Windows share, and will be set to only be readable by root. Remember to substitute "USERNAME" and "PASSWORD" with your appropriate values:

root@xbian:/media# cd /home/xbian
root@xbian:/home/xbian# echo "username=USERNAME" >> smbcredentials
root@xbian:/home/xbian# echo "password=PASSWORD" >> smbcredentials
root@xbian:/home/xbian# chmod 600 smbcredentials
root@xbian:/home/xbian# cat smbcredentials
root@xbian:/home/xbian# ls -l smbcredentials
-rw------- 1 root root 31 Dec 11 02:10 smbcredentials

Once that file has been created, make an entry in /etc/fstab for each share that we need to mount. Remember that in my case I'm using two, you may be using one or 50, I don't know, but make the appropriate entries. Below is my example -- note that the two bottom lines (under the snarky comment) are the lines I added to the file:

root@xbian:/home/xbian# cat /etc/fstab
/dev/mmcblk0p1        /boot                   xbian   rw                              0       1
/dev/root             /home                   xbian   subvol=home/@,noatime           0       0
/dev/root             /lib/modules            xbian   subvol=modules/@,noatime        0       0
none            /run/lock                       tmpfs                   noauto                  0       0
none            /run/shm                        tmpfs                   noauto                  0       0
none            /run/user                       tmpfs                   noauto                  0       0
none            /sys/kernel/debug               debugfs                 noauto                  0       0
none            /sys/kernel/security            securityfs              noauto                  0       0

# XBian won't let me add these normally
//           /media/TV       cifs    credentials=/home/xbian/smbcredentials,ro       0       0
//       /media/Movies   cifs    credentials=/home/xbian/smbcredentials,ro       0       0


Remember to substitute your own values in for the IP address, and if you're attempting to do this with NFS and not CIFS, you should change "cifs" to "nfs", obviously.

Sixth, reboot. Type "reboot" at the command line. Your Xbian pi should come back up after a minute or two, and when it does it should have automatically mounted the shares that you put into /etc/fstab. You can check this with "df" once the Xbian comes back up from the reboot:

xbian@xbian ~ $ df -h
Filesystem                 Size  Used Avail Use% Mounted on
rootfs                     3.5G  539M  2.8G  16% /
/dev/mmcblk0p2             3.5G  539M  2.8G  16% /
devtmpfs                   125M  4.0K  125M   1% /dev
none                        25M  268K   25M   2% /run
/dev/mmcblk0p1              34M   14M   21M  40% /boot
/dev/mmcblk0p2             3.5G  539M  2.8G  16% /home
/dev/mmcblk0p2             3.5G  539M  2.8G  16% /lib/modules
/dev/mmcblk0p2             3.5G  539M  2.8G  16% /xbmc-backup
//      4.0T  993G  3.1T  25% /media/TV
//  4.0T  993G  3.1T  25% /media/Movies
xbian@xbian ~ $ I can see that the shares are indeed mounted as intended. Great!

Finally, go back into XBMC on your TV, and add the source -- EXCEPT, don't add the source as SMB. Add it as a local file -- choose "Root Filesystem" from the list, and then navigate to /media. You should see the shares you just mounted. Add each one individually, and Xbian should categorize them as normal.

I hope this helps. I know I was a little frustrated by Xbian seemingly not running with enough permission to mount these shares direct from the GUI, but a little command line fu and nothing is impossible.


RE: Workaround for SMB "Operation not permitted" and other remote filesystem issues - IriDium - 15th Dec, 2013 04:12 AM

Changed title

RE: Solution to SMB "Operation not permitted" - 172pilot - 16th Apr, 2019 06:37 AM

(11th Dec, 2013 12:28 PM)beeftube Wrote:  I hope this helps. I know I was a little frustrated by Xbian seemingly not running with enough permission to mount these shares direct from the GUI, but a little command line fu and nothing is impossible.


Thanks - Having the same problem, but can't even do the commands you specify w/o sudo..

Once using sudo, it did seem to work, but definitely makes me wonder why this is necessary, and why others aren't having the same problem? What am I doing wrong?

I tried SMB shared on a linux based NAS and on my Win10 box, and I get the same errors on both..