Qbittorrent and stalled downloads

Hi there,

I connected an external HDD and mounted it on mnt/ext and then created a few folders on Windows using Samba. My samba conf looks like this for this:

[External Drive]
path = /mnt/ext
browseable = yes
writeable=Yes
create mask=0777
directory mask=0777
public=yes


I have Qbittorrent installed and I forwarded its port on my router settings on my Dietpi local IP.
As I have already created a Downloads folder, I set qbittorrent download folder to mnt/ext/Downloads

However, as soon as I add a new torrent, it mght connect to 1 or 2 peers and then everything drops to 0 and the torrent gets stalled. Am I missing something?

I searched on the forum and found this topic, which describes the same situation I´m having: https://dietpi.com/forum/t/qbittorrent-and-nas-stalled-downloads-rpi3/3627/1

Thanks!

Hi,

did you tried changing download directory to some other place like /mnt/dietpi_userdata/downloads to rule out issues with the external device.

Yep, with a local location like that one it works. But not with the external drive. On the bottom of qBitorrent where it says the drive capacity it says “unknown”, so a connection with it between qBitorrent and the external drive is not being established I guess.

Just solved it by chmoding 777 the folder!

what file system format you are using on your disk? ext4? You would need to ensure write permission of Qbittorrent user. Yes 777 is an option but not really secure :wink:

Hi Joulinar, thanks for your asnwer.

I´m indeed using EXT4 on my external drive, but not sure what you say I should do instead of the chmod 777.
Thanks

can you provide following

ls -la /mnt/ext/

Sure, here you go:

total 44
drwxrwxr-x 8 root users 4096 Dec 17 01:57 .
drwxr-xr-x 7 root root 4096 Dec 16 21:25 …
drwxrwxr-x 2 root users 4096 Dec 17 01:08 Backups
drwxrwxrwx 4 root users 4096 Dec 17 19:42 Downloads
drwxrwxr-x 2 root users 4096 Dec 17 01:08 Movies
drwxrwxr-x 2 root users 4096 Dec 17 01:07 Pictures
drwxrwxr-x 2 root users 4096 Dec 17 01:08 TV
drwxrwxr-x 2 root users 16384 Dec 16 17:21 lost+found

ok all files and directories are owned by user root and group user. For sure Qbittorrent is not able to write to your disk. You could change group ownership to group dietpi and ensure that Qbittorrent is part of this group.

Thank you, I´ll see if I can find on Google how to change group ownership and add qBitorrent to that group.
Regards!

I executed this: chown -Rv root:dietpi /mnt/ext

Now the output shows:

drwxrwxr-x 8 root dietpi 4096 Dec 18 15:25 .
drwxr-xr-x 7 root root 4096 Dec 16 21:25 …
drwxrwxr-x 3 root dietpi 4096 Dec 18 15:28 Backups
drwxrwxrwx 4 root dietpi 4096 Dec 18 15:30 Downloads
drwxrwxr-x 2 root dietpi 4096 Dec 17 01:08 Movies
drwxrwxr-x 2 root dietpi 4096 Dec 17 01:07 Pictures
drwxrwxr-x 2 root dietpi 4096 Dec 17 01:08 TV
drwxrwxr-x 2 root dietpi 16384 Dec 16 17:21 lost+found

Would that be correct? Now I would need to see how to add qBitorrent to dietpi group, right?

something about groups https://www.howtogeek.com/50787/add-a-user-to-a-group-or-second-group-on-linux/

changing groups on file/folder https://linuxize.com/post/linux-chown-command/

Thanks, I think I did it now.

qbittorrent.service:

[Unit]
Description=qBittorrent (DietPi)
Documentation=man:qbittorrent-nox(1)
Wants=network-online.target
After=network-online.target dietpi-boot.service

[Service]
User=dietpi
Group=dietpi
UMask=002
ExecStart=/usr/bin/qbittorrent-nox
Restart=on-failure

[Install]
WantedBy=multi-user.target

ls -la /mnt/ext/:

drwxrwxr-x 8 root dietpi 4096 Dec 18 15:25 .
drwxr-xr-x 7 root root 4096 Dec 16 21:25 ..
drwxrwxr-x 3 root dietpi 4096 Dec 18 15:28 Backups
drwxrwxrwx 4 root dietpi 4096 Dec 18 15:30 Downloads
drwxrwxr-x 2 root dietpi 4096 Dec 17 01:08 Movies
drwxrwxr-x 2 root dietpi 4096 Dec 17 01:07 Pictures
drwxrwxr-x 2 root dietpi 4096 Dec 17 01:08 TV
drwxrwxr-x 2 root dietpi 16384 Dec 16 17:21 lost+found

usually it’s not needed to change qbittorrent.service. It’s totally fine to have it running as user qbittorrent. Important thing is to have user qbittorrent being a member of user group dietpi. This can be checked as follow

groups qbittorrent

It should return dietpi as group membership.

Thank you Joulinar, it does return dietpi now :slight_smile:

if you like, you could remove 777 permission from Downloads folder an d set it to something like 664. This should give rw access

based on my test 764 is not enough, if the service runs under qbittorrent, which is in dietpi group, the /mnt/data (path to external drive) still needs 776 (or 77x) otherwise qbittorrent goes stalled when checking the files and so.
My setup:

  • Service as default runs under user qbittorrent
  • User qbittorrent is in dietpi group
  • Mount point of external drive (eg. /mnt/data) is owned by dietpi:dietpi
  • chmod 776 (owner: rwx, group: rwx, public: any) is set recursively on /mnt/data