I was trying implement disk user and group quotas at Google Compute Engine with Ubuntu 16.04 LTS, but till now i'm unsuccessful.

Quota allows you to specify limits on two aspects of disk storage: the number of inodes a user or a group of users may possess; and the number of disk blocks that may be allocated to a user or a group of users.

The idea behind quota is that users are forced to stay under their disk consumption limit, taking away their ability to consume unlimited disk space on a system.

sudo -s
apt-get -y install quota quotatool
nano /etc/fstab

then I used

LABEL=cloudimg-rootfs   /    ext4   defaults,usrjquota=quota.user,grpjquota=quota.group,jqfmt=vfsv0 0 0

then I tried activate quota:

mount -o remount /
quotacheck -avugm
quotaon -avug
quotaon: using //quota.user on /dev/sda1 [/]: No such process
quotaon: Quota format not supported in kernel

Quota module not in kernel, I create the user and group quota.

touch /aquota.user /aquota.group
chmod 600 /aquota.*
mount -o remount /
quotacheck -avugm
quotaon -avug
quotaon: using //quota.user on /dev/sda1 [/]: No such process
quotaon: Quota format not supported in kernel

Didn't work.

I remembered a way used in AWS EC2:

apt-get -y install linux-image-extra-virtual

echo quota_v1 >> /etc/modules
echo quota_v2 >> /etc/modules

reboot

sudo -s
cat /proc/modules | grep -i quota

Nothing, Didn't work either.

modprobe quota_v1
modprobe: FATAL: Module quota_v1 not found in directory /lib/modules/4.8.0-46-generic

quotaon -pa
group quota on / (/dev/sda1) is off
user quota on / (/dev/sda1) is off

I made this work at EC2 but no luck with Google Compute Engine. Any idea what I can try more?


Solution 1:

I have same problem running Ubuntu 18.04 on AWS instance

removing aws kernel and install the Generic one seems to fix the problem

here is what i do:

# Remove Aws Kernel | find your own kernel version
apt-get remove linux-image-4.15.0-*-aws

# Install Generic Kernel
apt-get -y install linux-image-generic
apt-get -y install linux-headers-generic

# Makesure everything is ok
reboot

modprobe quota_v2
modprobe quota_v2

# if no error on modprobe then add it to modules
echo quota_v1 >> /etc/modules
echo quota_v2 >> /etc/modules

# after that you can add quota options on fstab

Solution 2:

Ok, found a solution. I do not need install linux-generic at EC2 but seems need be a procedure at Google Compute Engine. All procedure to get quota work:

sudo -s
apt-get -y install quota quotatool

nano /etc/fstab

Edit fstab:

LABEL=cloudimg-rootfs   /    ext4   defaults,usrjquota=quota.user,grpjquota=quota.group,jqfmt=vfsv0 0 0

Check for missing packages.

dpkg -s linux-generic
dpkg-query: package 'linux-generic' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.

We can install the full missing linux-generic package:

apt-get -y install linux-generic

Or only the extras packages (I prefer this):

apt-get -y install linux-image-generic
apt-get -y install linux-headers-generic
apt-get -y install linux-image-extra-`uname -r`

We need add the quota modules to start with boot:

echo quota_v1 >> /etc/modules
echo quota_v2 >> /etc/modules

reboot

Check if it's working:

sudo -s
cat /proc/modules | grep -i quota

quota_v1 16384 0 - Live 0xffffffffc037c000
quota_v2 16384 2 - Live 0xffffffffc0377000
quota_tree 20480 1 quota_v2, Live 0xffffffffc0250000

quotaon -pa

group quota on / (/dev/sda1) is on
user quota on / (/dev/sda1) is on

Both quotas are activated.