LXC/LXD quotas, rutorrent diskspace module



I am running my Quickbox setup inside an LXD container. User quotas are my only issue, and I am stuck finding a solution and would like help on how to debug the rutorrent diskspace module. I do not know PHP and only a rudimentary understand of how this module works.

the Quota system inside an LXD does not work yet. They have implemented it, but have not seemed to get it functioning for user/group quotas. the ZFS file system work for quotas, but not user/group quotas.

I will describe an overview of what I have done, and where I am stuck and will post code and more information if someone wishes to bust their brain with me on this. I am at work and do not have access to my files.

In the diskspace module it runs the command “repquota -u / | etc”. This fails inside the container, but works perfectly on the host.

The quota system has been installed on the host, and i have mapped the users inside the container to the host system. In the container the user id is 1000. The host sees that user as user id 166536. I created the user on the host with the same name but user id of 166536.

When repquota is run on the host it gives exactly the same output as if it was run inside the container. and pipe the output to a file “/srv/quotafile”. The file is then rsync’d into the container “/srv/quotafile”

I changed the rutorrent module diskspace from “repquota -u / | etc” to “cat /srv/quotafile | etc”. I have tried this commands in SHELL and they work perfectly, but not in rutorrent.

I am here in the hopes of getting help with the diskspace module debugging.


Update: I tried setting $free and $total variables to numbers in diskspace and rutorrent displayed everything properly.

I set the value for quotaUser to the username and ran the script in bash “PHP ./action.php” and it worked as above, and also with shell_exec as described in the first post.

for some reason, shell_exec is not running under rutorrent. If I can figure that out then this is solved.


I clued in last night that i do not need exec_shell since i no longer need to run repquota. Today I wrote the fold diskspace module in PHP and it seems to be working fine. I am testing it now.


I’d be very interested in seeing what you come up with :smiley:


on the HOST:

1,5,10,15,20,25,30,35,40,45,50,55 * * * * log=$(date)" quota exchange\n"$( /usr/bin/sudo /usr/sbin/repquota -u / > /srv/quota/repquota.host; rsync -avzq -e "ssh -p 4747" /srv/quota/repquota.host [email protected]:/srv/quota/ ; rsync --remove-source-files --ignore-missing-args -avzq -e "ssh -p 4747" [email protected]:/srv/quota/newuser_????.lst /srv/quota/ ; /opt/dupcuser.sh ) ; echo "\n"$log"\n" | tee -a /var/log/system_ip.log

In the briefest of terms this runs repquota and generates the file that has all the user quota information. rsync copies it into the host container at *.107 . rsync uses passwordless key so root can access the server.

While we are at it, it grabs the newuser_*.lst file if one exists and executes the script that will add a new user with the right UID and GID and set up the quota for the user. The quota is set with a 100% soft limit and a 125% hard limit.

for file in /srv/quota/newuser_*.lst ; do
if [ ${#file} -le 25 ]; then exit; fi
source $file
rm -rf $file
newUID=$(( 165536 + $userID ))
addgroup --gid “${newUID}” “${username}”
adduser --no-create-home --uid “${newUID}” --gid “${newUID}” --gecos “” --disabled-login “${username}”
case $SIZE in
QUOTASIZE=$(echo $SIZE|cut -d’T’ -f1)
DISKSIZE=$(($QUOTASIZE * 1024 * 1024 * 1024))
setquota -u ${username} ${DISKSIZE} $(($DISKSIZE
125/100)) 0 0 -a
# echo -e “$SIZE:” >>/root/${username}.info
QUOTASIZE=$(echo $SIZE|cut -d’G’ -f1)
DISKSIZE=$(($QUOTASIZE * 1024 * 1024))
setquota -u ${username} ${DISKSIZE} $(($DISKSIZE
125/100)) 0 0 -a
# echo -e “quota:$SIZE” >>/root/${username}.info
echo “Creating a 20GB quota as default. Thank you for playing.”
QUOTASIZE=$(echo $SIZE|cut -d’G’ -f1)
DISKSIZE=$(($QUOTASIZE * 1024 * 1024))
setquota -u ${username} ${DISKSIZE} $(($DISKSIZE
125/100)) 0 0 -a
# echo -e “quota:$SIZE” >>/root/${username}.info


In the Container:
These lines are added to the CreateSeedBoxUser (or whatever) in your /root/.bashrc. Maybe near the end of that portion?

 echo "userID=\"${UPORT}\"" >> "$qdir/newuser_${UPORT}.lst"  
 echo "username=\"$username\"" >> "$qdir/newuser_${UPORT}.lst"
 echo "quota=\"${quota}\"" >> "$qdir/newuser_${UPORT}.lst"


    require_once( '../../php/util.php' );
 $lines = file($filename);
     foreach($lines as $index => $string) {
         if (strpos($string, $quotaUser) !== FALSE)
             $line = $index;
 $words = preg_split('#\s+#', $lines[$line]);
 $total = $words[3]*1024;
 $free = ($words[3]-$words[2])*1024;
 cachedEcho('{ "total": '.$total.', "free": '.$free.' }',"application/json");