Specify Users Maximum 'DiskSpace'

peshua19

Member
May 25, 2018
897
0
16
I was wondering if there was a way of specifying to rutorrent the maximum disk space for a particular user?

For instance I run multiple users on some boxes, and use userquota/groupquota for diskspace restriction.
I am able to edit the values passed via the 'disk_total_space() & disk_free_space()' functions in the action.php file located in the diskspace plugin folder, but being that I must specify a directory, it takes the total of the partition which is then an inaccurate representation of the available space for that user.

Does anyone know a way to perhaps tell rutorrent that the max space for that instance/user is only say 300GB instead of 2TB?
 

saroos1

Member
May 25, 2018
718
0
16
...and when some user reach this quota, rtorrent will hang. It can't normal working on quota's partition. AFAIK.
 

randac56

Member
May 25, 2018
915
0
16
I have been sort of messing with this. Here is an option but its slow to create new users...

steps:

1 time:
mkdir /user_images
cd /user_images
dd if=/dev/zero of=20GB_home.ext2 bs=1G count=20
mkfs -t ext2 -m 0 -q ./20GB_home.ext2 -F

per user:
(if below copy process is slower than DD and mkfs then just create all new environment with dd/mkfs)
cp /user_images/20GB_home.ext2 /user_images/MyNewUser.ext2
mkdir /home/MyNewUser
mount -o loop,rw /user_images/MyNewUser.ext2 /home/MyNewUser
useradd MyNewUser
chown -R MyNewUser:MyNewUser /home/MyNewUser

add below to /etc/fstab for each user to persist across reboots.
/user_images/MyNewUser.ext2 /home/MyNewUser ext2 rw,loop 0 0

Now the disk usage plugin will work perfectly fine for each user and show them their usage of their 20gb set the top level directory in config to their home directory. If you have a fast disk server or don't care if it takes a while to create their environment then this is a good way to control disk usage.

Pros:
1) Gives exact control over disk size
2) don't need to use quota
3) works with disk plugin
4) you can use rtorrent schedule to automatically close torrents when disk space gets low.
schedule = low_diskspace,5,60,close_low_diskspace=100M
5) rtorrent isn't quota aware, this works perfect
6) disk space is always set aside you know exactly how much disk space is sold/remaining.

Now the Cons:

1) it takes a long time to cp /user_images/20GB_home.ext2 /user_images/MyNewUser.ext2
2) disk access is slower on loop device than real device
3) perhaps more complicated setup, but I assume everyone should do this automatic via scripts, so that shouldn't be an issue.
4) with quota a user may not use all their quota leaving extra free space on system.



-HR

creation times on my server (which is quite active with transmission and rtorrent and httpd):

dd, almost 9 minutes
mkfs, 30 seconds
cp file system, 37 min
 

simur612

Member
May 25, 2018
879
0
16
i've used something similar to this back in the day....there are some serious performance issues with creating new filesystems on top of a file...but other than that...i dont' see a major problem


not great, but usable
 

randac56

Member
May 25, 2018
915
0
16
Did a performance test on my running system of DD creations.

20 gb dd on raw = 7min 16 sec (49.6 MB/s)

now I mounted that 20gb file system drive and then ran dd from it:

10 gb dd on loop = 5 min 16 sec (34.0 MB/s)

So yip, definitely a slower file system but may be adequate for most torrent operations.
 

lisas4567

Member
May 25, 2018
773
0
16
wink.gif
Why not write a basic php script to display in a new tab ( in conjunction with your userquotas you have set) how much space the user has to use and the php script will show how much space is left for that specific user.

Your quotas will keep them in check and the php script will tell the user how much space they have used pretty accurately without having to call on too much system resources.
A basic but very simple way of tackling this problem.
 

Attachments

randac56

Member
May 25, 2018
915
0
16
Talks about stopping all downloading torrents here:

http://libtorrent.rakshasa.no/ticket/1137


xmlrpc localhost d.multicall '' f.multicall=,,f.set_priority=0

xmlrpc localhost d.multicall '' d.update_priorities=

Change 0 to 1 to set normal file priorities again and it'll resume downloading. If you've modified your file priorities manually, that will undo your settings however.

I suppose this should probably run by cron though instead of php. The cron script would run every minute checking everyones quota's if too low then issue those commands. If normal, issue activate commands.

php probably only good for monitoring usage. if it only ran via php then it would only work while user has web page up.
 

saroos1

Member
May 25, 2018
718
0
16
This doesn't work for me...

After I enter: dd if=/dev/zero of=20GB_home.ext2 bs=1G count=20

... i get the following message

20+0 records in
20+0 records out
21474836480 bytes (21 GB) copied, 212.64 s, 101 MB/s

But then when I try to enter: mkfs -t ext2 -m 0 -q ./20GB_home.ext2 -F
I get this: mkfs -t ext2 -m 0 -q ./20GB_home.ext2 -F mkfs.ext2: No such file or directory


Can anyone offer me help here... and is there a better way to limit user space since this was posted?

I can't enable quota because I use VPS and my filesystem doesn't support quota sad.gif
 

Attachments