How to enable disk quotas for a filesystem in linux?

To enable disk quotas on a filesystem in Red Hat Linux-based distributions (such as Red Hat Enterprise Linux, CentOS, and Fedora), you can follow these steps:

1. Edit /etc/fstab:

Edit the ”etc/fstab” file to add “usrquota” and “grpquota” options to the desired filesystem entry.

For example:

/dev/sda1 /home ext4 defaults,usrquota,grpquota 0 2

In this example, quotas are enabled for the “/home” filesystem. Make sure to replace “/dev/sda1” with the appropriate device and “/home” with the correct mount point for your system.

2. Remount the Filesystem:

Remount the filesystem to apply the changes. You can either reboot your system or remount the filesystem manually. To remount it manually, use the following command:

sudo mount -o remount /home

Replace /home with the appropriate mount point if you used a different one in your “/etc/fstab” file.

3. Install the Quota Packages (if not installed):

Ensure that the necessary quota packages are installed. You can install them using the package manager (yum or dnf depending on your distribution version).

To verify whether the quota package is already installed or not, run the following command.

yum list installed | grep -i quota

Run one of the following commands to install quota package based on your package manager:

For systems using yum:

sudo yum install quota

For systems using dnf:

sudo dnf install quota
4. Enable Quota:

Edit the /etc/default/grub file to include quota options in the GRUB_CMDLINE_LINUX line.

For example:

GRUB_CMDLINE_LINUX="rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet rootflags=quota"

Make sure to replace rhel with centos when you are using centos systems.

5. Rebuild GRUB Configuration:

After editing the /etc/default/grub file, rebuild the GRUB configuration:

For GRUB 2 :
sudo grub2-mkconfig -o /boot/grub2/grub.cfg

For GRUB Legacy :
sudo grub2-mkconfig -o /boot/grub/grub.cfg
6. Initialize Quota Database:

Run the following command to initialize the quota database files:

sudo quotacheck -cug /home

This command creates the necessary quota files (aquota.user and aquota.group) in the specified filesystem (in this case, /home). Make sure to replace /home with your specific filesystem.

7. Enable and Start Quota Service:

Enable and start the quota service:

sudo systemctl enable quotaon.service
sudo systemctl start quotaon.service
8. Set User and Group Quotas:

Now that quotas are enabled, use the edquota command to set quota limits for a specific user.

For example, to set a soft limit of 1 GB and a hard limit of 1.2 GB for the user username, use the following command:

sudo edquota -u username
sudo edquota -g groupname

Replace ”username” with the username and “groupname” with the group name for which you want to set quotas.

9. Verify the quota Settings:

You can use the quota command to check the quota status for the user:

quota brett

After following these steps, disk quotas will be enabled and configured with specific hard and soft quota limit for the specified filesystem in your Red Hat Linux-based system.

Enabling disk quotas on a filesystem in Ubuntu/Debian Linux involves a few steps. Here’s a step-by-step guide to enable disk quotas for a specific filesystem:
1. Edit “/etc/fstab”:

Edit the “/etc/fstab” file and add the “usrquota” and “grpquota” options to the corresponding filesystem entry.

For example:

/dev/sda1 /home ext4 defaults,usrquota,grpquota 0 2

This line enables quotas on the “/home” filesystem. Make sure to replace “/dev/sda1” with the appropriate device and “/home” with the correct mount point for your system.

2. Remount the Filesystem:

Remount the filesystem for the changes to take effect. You can either reboot your system or remount the filesystem manually. To remount it manually, use the following command:

sudo mount -o remount /home

Replace “/home” with the appropriate mount point if you used a different one in your “/etc/fstab” file.

3. Install the Quota Utilities (if not already installed):

Make sure the “quota” package is installed on your system. If it’s not installed, you can install it using your package manager. For example, on Debian-based systems (like Ubuntu), you can use:

sudo apt-get update
sudo apt-get install quota
4. Initialize Quota Database:

Run the following command to initialize the quota database files:

sudo quotacheck -cug /home

This command creates the necessary quota files (“aquota.user” and “aquota.group”) in the specified filesystem (in this case, “/home”). Make sure to replace “/home” with your specific filesystem.

5. Enable and Start Quota Service:

Enable and start the quota service so that quotas are applied and enforced:

sudo systemctl enable quotaon.service
sudo systemctl start quotaon.service
6. Set User and Group Quotas:

Now that quotas are enabled, you can set quotas for individual users and groups using the “edquota” command.

For example, to set a quota of 1GB for a user named “brett”:

sudo edquota -u brett

This command opens a text editor where you can set the quota limits for the user.

7. Verify Quotas:

To verify that quotas are set and working correctly, you can use the “quota” command:

quota -u brett

This command displays the quota information for the user “brett“.

That’s it! Disk quotas are now enabled and configured for the specified filesystem in Linux.

Click Here!!! to know the uses of enabling the disk quotas on filesystems in linux.

How do you feel about this post? Drop your comments below..