ubuntu 22.04 / debian 11 aws ec2 disk quota's

Discussion in 'Tips/Tricks/Mods' started by nhybgtvfr, Jun 19, 2023.

  1. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    i know i've posted before about how to enable disk quota's on AWS ubuntu ec2 instances..
    it seems they've changed things around now.. the old method no longer works.

    the following method comes straight from aws support. and works on ubuntu 22.04, i've not tested it on anything else, but i'd assume the same issue would now exist on debian 11.
    the method i previously posted for ubuntu 18.04 may still work on that version on 20.04, this new method may work on previous versions of ubuntu.

    Code:
    sudo apt-get update && sudo apt-get upgrade >>> Restarted services when prompted
    sudo apt update
    sudo apt install quota
    
    find /lib/modules/ -type f -name '*quota_v*.ko*'
    --My initial output was empty:
    --I ran the "sudo apt install linux-modules-extra-aws" and then "sudo reboot" to use the newer kernal.
    --After rebooting I get the following output when running the command:
    /lib/modules/5.19.0-1027-aws/
    kernel/fs/quota/quota_v2.ko
    /lib/modules/5.19.0-1027-aws/kernel/fs/quota/quota_v1.ko
    
     Once the instance is restarted, modify /etc/fstab accordingly.
    --My Drive was named "xvda1", I suspect yours will be the same or very similar, replace "/dev/sda" with "/dev/xvda1" if so. If you are not sure, you can run "lsblk".
     
    sudo mount -o remount /
     cat /proc/mounts | grep ' / '
    --My output: /dev/root / ext4 rw,relatime,discard,quota,usrquota,grpquota,errors=remount-ro 0 0
    sudo quotacheck -ugm /
    Kernal version taken from step 4:
    sudo modprobe quota_v1 -S 5.19.0-1027-aws
    sudo modprobe quota_v2 -S5.19.0-1027-aws
    
     sudo quotaon -v /
      Tested using root user:
    sudo setquota -u root 100M 110M 0 0 /
    I get outputs successfully from:
    sudo quota -v root
    sudo repquota -s /
    
    
    as a warning to everyone.. i tested this manually on a completely new ec2 instance with multiple ebs volumes, adding the quota settings to each instance in /etc/fstab.
    it did have some issues:

    Code:
    quotacheck -avugm
    quotacheck: Your kernel probably supports ext4 quota feature but you are using external quota files. Please switch your filesystem to use ext4 quota feature as external quota files on ext4 are deprecated.
    quotacheck: Quota for users is enabled on mountpoint / so quotacheck might damage the file.
    Please turn quotas off or use -f to force checking.
    
    quotaon -avug
    quotaon: Your kernel probably supports ext4 quota feature but you are using external quota files. Please switch your filesystem to use ext4 quota feature as external quota files on ext4 are deprecated.
    quotaon: using //quota.group on /dev/root [/]: Device or resource busy
    quotaon: using //quota.user on /dev/root [/]: Device or resource busy
    quotaon: cannot find /media/mysqltest/quota.group on /dev/nvme2n1p1 [/media/mysqltest]
    quotaon: cannot find /media/mysqltest/quota.user on /dev/nvme2n1p1 [/media/mysqltest]
    quotaon: cannot find /media/webtest/quota.group on /dev/nvme1n1p1 [/media/webtest]
    quotaon: cannot find /media/webtest/quota.user on /dev/nvme1n1p1 [/media/webtest]
    quotaon: cannot find /var/log/quota.group on /dev/nvme3n1p1 [/var/log]
    quotaon: cannot find /var/log/quota.user on /dev/nvme3n1p1 [/var/log]
    
    repquota -a
    repquota: Cannot open quotafile /media/mysqltest/quota.user: No such file or directory
    repquota: Cannot open quotafile /media/webtest/quota.user: No such file or directory
    repquota: Cannot open quotafile /var/log/quota.user: No such file or directory
    *** Report for user quotas on device /dev/root
    
    however, removing all the quota settings in /etc/fstab, and remounting every volume again, i then tested running the automated install script.
    it completed successfully. (quota and quotatool were already installed prior to running the script, but caused no apparent issues)

    all that information above was for context, to hopefully help anyone that continues to have issues, but it would seem that just the following should be sufficient to get quota's working:

    Code:
    sudo apt install linux-modules-extra-aws
    reboot
    * sudo modprobe quota_v1 -S 5.19.0-1027-aws 
    * sudo modprobe quota_v2 -S5.19.0-1027-aws
    
    * it may not even be necessary to specify the kernel version here, just modprobe quota _v1 and modrobe quota_v2 may be enough.

    then just run the automated install script as normal.
     
    Th0m and ahrasis like this.

Share This Page