28

I have Raspberry Pi running RaspBMC with a WD MyBook connected using USB. The drive is automatically mounted to /media/My Book. I have created a folder /media/My Book/downloads and I have set Trasmission's download directory to be /media/My Book/downloads.

When I try to download a file, Transmission says

Error: Permission denied (/media/My Book/downloads/The.Simpsons.S24E09.720p.HDTV.X264-DIMENSION [PublicHD]/The.Simpsons.S24E09.720p.HD

ls -la gives me

drwx------ 1 pi       0 Dec 15 16:24 downloads 

So I guess the problem is that transmission runs under different user than pi and cannot write to the folder. However when I execute

chmod 777 downloads -R

the operations succeeds without any error but the permissions do not change, they stay 700 just for the owner.

What am I doing wrong and how can I enabled Transmission to write to that directory?

Igor Kulman
  • 551
  • 1
  • 6
  • 13

16 Answers16

26

After lots of reading and frustration. First of all, make sure the normal user has read and write acces to the USB drive. The correct 'non-root' fix for having write acces to the USB drive is:

Step 1: Stop transmission daemon

sudo service transmission-daemon stop

Step 2: Add pi to debian-transmission group

sudo usermod -a -G debian-transmission pi 

Step 3: changing the daemon-user

sudo nano /etc/init.d/transmission-daemon

Change USER to pi.

Step 4 Change the rights of the configuration files folder

sudo chown -R pi /var/lib/transmission-daemon/info/
sudo chmod 755 /var/lib/transmission-daemon/info/settings.json 

Step 5: Set the correct permissions for the download / incomplete folders

sudo chown -R pi /somewhere/downloads
sudo chown -R pi /somewhere/incomplete

Step 5: Start transmission daemon

sudo service transmission-daemon start

Compiled from:

Biketire
  • 361
  • 1
  • 4
  • 7
12

The problem was the way the USB disk was automonted. I mounted it manualy with mount -t ntfs-3g and it started working.

Igor Kulman
  • 551
  • 1
  • 6
  • 13
10

I'm no linux expert, but you could try this, might work. Most of this is info came from http://www.superfecta.ca/?p=44

sudo service transmission-daemon stop
sudo nano /etc/init.d/transmission-daemon

change

USER=debian-transmission

to

USER=root
ctrl-x
Y
# hit enter to overwrite
sudo service transmission-daemon start

I know running as root is a big linux no no (not sure if that counts as running in root) but it worked for me so I'm fine with it. You could try USER=pi instead but I got no love there, so I stuck with root

Lukas Knuth
  • 949
  • 2
  • 7
  • 19
Spasmodean
  • 101
  • 2
8

None of the answers here worked for me, so I am writing a new one referencing https://pimylifeup.com/raspberry-pi-torrentbox/ which worked great for me and allowed me to run transmission as pi user to access my USB drive. This is not directly answering the OP but this question is very popular (first Google result) for this sort of problem so I put it here.

Enter:

sudo vi /etc/init.d/transmission-daemon

and find USER in the top of the file and change to:

USER=pi

Then we need to chown some files into our permissions scope:

sudo chown -R pi:pi /etc/transmission-daemon
sudo chown -R pi:pi /etc/init.d/transmission-daemon
sudo chown -R pi:pi /var/lib/transmission-daemon

And then run (this is really important else the daemon from the service will just run as debian-transmission)

sudo vi /etc/systemd/system/multi-user.target.wants/transmission-daemon.service

and find user there and change to:

user=pi

and the reload the service unit

sudo systemctl daemon-reload

And finally we need to symlink our settings file to the pi home directory and give it permissions:

sudo mkdir -p /home/pi/.config/transmission-daemon/
sudo ln -s /etc/transmission-daemon/settings.json /home/pi/.config/transmission-daemon/
sudo chown -R pi:pi /home/pi/.config/transmission-daemon/

And then start transmission again:

sudo service transmission-daemon start

and you're done. It should now work.

Sammaye
  • 191
  • 1
  • 5
5

I believe your problem is your USB stick is formatted as NFTS or FAT, filesystems that do not support the per-user/group permissions. The solution is to reformat as ext4. If you do that, you will also have much less lag if you are using your Pi as a media center. The drivers for the Pi are much faster when you use ext4.

hifkanotiks
  • 1,901
  • 3
  • 16
  • 28
2

I think one of the main things people are overlooking is that you should mount your usb/external drive in /mnt/myUsbDrive folder, and NOT in /media/pi/myUsbDrive.

sudo umount /media/pi/usb_disk
sudo mkdir /mnt/usb_disk
sudo mount -t ntfs-3g -o uid=pi,gid=pi /dev/sda1 /mnt/usb_disk

I tried every single answer given on this discussion (including root) in a hundred different ways with different options and could not get transmission to save on my usb SSD drive. Then while reading something different, it was mentioned not to mount in /media/pi since daemons or other groups may not have access. So i mount the USB drive to /mnt/usb_disk, set the paths in /etc/transmission-daemon/settings.json to /mnt/usb_disk/downloads and transmission starts saving to the disk.

FYI, I do have user=pi in /etc/init.d/transmission-daemon.

FYI, I did change owner of /mnt/usb_disk/downloads to pi and group to debian-transmission with 777 permissions.

2

I found that the file system was the problem for me. Luckily it was a brand new usb hard drive so wasn't an issue to format it.

I first formatted the hard drive to ext4

sudo mkfs.ext4 /dev/<usb disk> -L <diskname>

Then I mounted the usb hard drive

sudo mount /dev/<usb disk> /mnt/<my mount folder>

Once mounted I changed the group for the hard drive to debian-

sudo chgrp debian-transmission /mnt/rpi_nas/

Finally I added the pi user to debian-transmission group and it worked great for my use case.

Nick
  • 203
  • 1
  • 8
1

I found the same solution as Igor and puigcerber. My drive was set to auto mount, so I edited my fstab to remove the automount, then used sudo mount -t vfat -o uid=pi,gid=pi /dev/sda1 /media/*mymountpoint/

dollerbill
  • 11
  • 2
1

While biketire's answer is correct debian switched to systemd recently and you have to change the user now here

sudo nano /etc/systemd/system/multi-user.target.wants/transmission-daemon.service

and make sure that in the section

[Service]

you have the line

User=pi
cstich
  • 11
  • 1
1

Solution:

After a lot of reading and frustration.

First of all, make sure the normal user has read and write access to the USB drive. The correct 'non-root' fix for having write access to the USB drive is:

Step 1: Stop transmission daemon

sudo service transmission-daemon stop

Step 2: Add pi to debian-transmission group

sudo usermod -a -G debian-transmission pi

Step 3: changing the daemon-user

sudo nano /etc/init.d/transmission-daemon

Change USER to pi.

sudo nano /etc/systemd/system/multi-user.target.wants/transmission-daemon.service

Change USER to pi.

Step 4: Change the rights of the configuration files folder sudo chown -R pi /var/lib/transmission-daemon/info/ sudo chmod 755 /var/lib/transmission-daemon/info/settings.json

Step 5: Set the correct permissions for the download / incomplete folders sudo chown -R pi /somewhere/downloads sudo chown -R pi /somewhere/incomplete

Step 6: Start transmission daemon

sudo service transmission-daemon start

tlhIngan
  • 3,372
  • 5
  • 21
  • 33
Sabi
  • 11
  • 1
1
sudo chown debian-transmission /downloads

where /downloads is the directory you want your downloads to be in (or mount location).

this is safer than using root.

this gives the 'user' known as 'debian-transmission' rights to the folder

kolin
  • 950
  • 2
  • 12
  • 25
drop
  • 11
  • 1
0

The problem relates to FAT not recognising multiple users.

If you use a line in your fstab file such as /dev/[your dev] /mnt/usb1 vfat defaults,uid=65534,gid=65534,dmask=000,fmask=111 0 0

it should mount your filesystem with folders 777 and files as 666 owned by "nobody" belonging to "nogroup"

you will need to remount (or reboot) for the changes to be seen.

JonH
  • 1
0

Finally found a working solution.

I turned of autosharing removable devices in XBIAN settings and added the disk to shares.conf by hand

[mybook]
    path = /media/mybook
    guest ok = yes
    read only = no
    browseable = yes
    writeable = yes
    force user = xbian

Just adding it to shares.conf is not enough, autosharing must be turned off.

Igor Kulman
  • 551
  • 1
  • 6
  • 13
0

Once you change the transmission-daemon user to root the permissions problem is gone with either a usb or smb share.

sudo nano /etc/init.d/transmission-daemon

then change the user line to:

USER=root

user6220
  • 9
  • 1
0

I had a similar permissions problem.

I tried following sabi's solution blindly and found that it did not work. Not only that, but I believe it's a bit overkill.

In my situation I simply overlooked the fact that transmission-daemon was running as user:debian-transmission.

Hence in order to grant permission for transmission-daemon to write to a folder(folder_name), you just need to do the following commands:

chgrp -R folder_name
chmod -R 765 folder_name

This is assuming of course that you've properly configured settings.json already

Liang
  • 101
  • 2
-1

chmod 777 should give every user all permissions to a file or directory. If that doesn't work, it's likely that the user that execute that chmod command does not own the directory or file. For example, if root owns /media/My Book/ and the pi user will not be able to change the permissions of that file. The three numbers you pass to the chmod command affect the owner, the group, and everybody else, in that order. Thus the most common settings for a directory are "chmod 755 somedirectory". That mean the owner can read, write and change into the directory, but group and everyone else can only read files and change into the directory.

shapr
  • 389
  • 1
  • 6