27

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?

16 Answers 16

25

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:

5
  • 3
    This is the only correct answer. Running as root is wrong. Doing a chmod 777 is wrong. Setting the correct group and user is the only correct way. Jun 7, 2015 at 18:51
  • 1
    Maybe it’s correct answer but it doesn’t work for me.
    – rebolek
    Feb 13, 2016 at 9:00
  • I have renamed my username from pi to something else. However, when I do ls -al it appears my files are still in a pi group. With the above instructions, should I change every instance of pi to my new username, or do any refer to the group which is still pi? These instructions don't work when I changed every pi to my username.
    – Keavon
    Dec 26, 2018 at 12:38
  • @Keavon "should I change every instance of pi to my new username" Yes, also is the new user in the debian-tranmission group?
    – Biketire
    Jan 2, 2019 at 7:23
  • I was having the input/output problem with transmission, but this make it works, thanks a lot!! This is the right way of doing it Dec 19, 2020 at 23:47
12

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

2
  • 4
    Same happened to me. With the HDD auto-mounted all the permissions were set to 0700, but mounting it with sudo mount -t ntfs-3g -o uid=pi,gid=pi /dev/sda1 /media/HDD/ they are 0777 and transmission works perfectly, really weird.
    – Puigcerber
    Sep 29, 2014 at 18:31
  • My ExFAT was auto-mounting with exfat defaults,auto,umask=000,users,rw 0 0, I changed that to mount with pi user IDs exfat defaults,uid=1000,gid=1000 0 0 and it worked. Check this AskUbuntu answer: Ownership/permission problem with automounting exfat drive
    – brasofilo
    Apr 29, 2019 at 7:17
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

4
  • 4
    Of course running as root works, it's just a security risk. Mar 2, 2013 at 1:47
  • Just something to add: Linux uses /etc/fstab file to set up mount points and permissions/ownership of the drive. So, you have three choices, run transmission as root, run transmission as the owner of the folder where the drive resides (ls -l will tell you who owns it), or modify the /etc/fstab file to show a different owner (i.e. debian-transmission).
    – Terry
    Nov 16, 2013 at 6:56
  • I was facing a similar problem with saving torrents on a NAS drive mounted as guest. I tried all solutions mentioned everywhere, but nothing worked for me, so I gave up and made transmission-daemon run as root. I don't like it, but it's the only thing that works.
    – aalaap
    Nov 18, 2014 at 15:15
  • 1
    This is wrong and daemons like this should never run with root privileges. You should remove this answer because this will damage other peoples setup. Jun 7, 2015 at 18:57
7

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.

2
  • This was great! In addition to this I also had to make sure, that the mounted external harddrive had the main folder (in my case /mnt/raid1) as listable by other users.
    – xyz
    Feb 4, 2023 at 20:34
  • So even though pi:debian-transmission had 774 on /mnt/raid1/_download/torrent-complete it wasn't enough. I also had to do chmod o+X /mnt/raid1
    – xyz
    Feb 4, 2023 at 20:35
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.

2
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.

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

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/

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
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

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

2
  • 7
    That's a security risk. Mar 2, 2013 at 1:47
  • This is wrong and daemons like this should never run with root privileges. You should remove this answer because this will damage other peoples setup. Jun 7, 2015 at 18:59
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.

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.

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

-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.

1
  • 1
    This answer really doesn't answer the question. The asker has already tried chmodding the file and it didn't work. Feb 9, 2013 at 8:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.