Linux Admin – Quota Management
As a Linux administrator, quota management is an important
aspect of managing file systems and controlling disk usage by users. Quotas
allow you to set limits on the amount of disk space a user or a group can
consume. Here's a general guide on how to manage quotas in Linux:
Enabling Quota Management in C Linux is basically a 4 step process –
Step 1 − Enable quota management for groups and users in /etc/fstab.
Step 2 − Remount the filesystem.
Step 3 − Create Quota database and generate disk usage table.
Step 4 − Assign quota policies.
Enable Quota Management in /etc/fstab
- First, we want to backup our /etc/fstab filen −
[root@localhost ~]# cp -r /etc/fstab ./
We now have a copy of our known working /etc/fstab in the current working directory.
We made the following changes in the options section of /etc/fstab for the volume or Label to where quotas are to be applied for users and groups.
- usrquota
- grpquota
As you can see, we are using the xfs filesystem. When using xfs there are extra manual steps involved. /home is on the same disk as /. Further investigation shows / is set for noquota, which is a kernel level mounting option. We must re-configure our kernel boot options.
[root@localhost ~]# mount | grep ' / '
/dev/mapper/cl-root on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
[root@localhost rdc]#
Reconfiguring Kernel Boot Options for XFS File Systems
To reconfigure kernel boot options for XFS file system in Linux, you can follow these steps:
Edit the bootloader configuration file: The specific file you need to edit depends on your Linux distribution. For example, if you are using GRUB as the bootloader, you can edit the
/etc/default/grub
file. Use a text editor with root privileges to open the file.Locate the
GRUB_CMDLINE_LINUX
line: Within the bootloader configuration file, you should find a line starting withGRUB_CMDLINE_LINUX
. This line contains the kernel command-line options.
Add or modify the options: Add or modify the options related to the XFS file system. Some common options for XFS includexfs
,rootflags
, andxfs_options
. Here are a few examples- To
enable XFS support: Add xfs to the GRUB_CMDLINE_LINUX line.
- To
specify XFS file system options: Use the rootflags parameter. For
example, rootflags=defaults,noatime.
- To
pass specific XFS options: Use the xfs_options parameter. For example, xfs_options=allocsize=64m,inode64.
- To
enable XFS support: Add xfs to the GRUB_CMDLINE_LINUX line.
Note: Make sure to separate multiple options with spaces.
- Save the changes: After making the necessary modifications, save the file and exit the text editor.
- Update the bootloader: Run the appropriate command to update the bootloader configuration based on your distribution. For example, with GRUB, you can use the
grub-mkconfig
command orupdate-grub
command. This step ensures that the changes take effect during the next boot. - Reboot your system: Once the bootloader is updated, reboot your system to apply the new kernel boot options.
After the reboot, the kernel will use the updated boot options for the XFS file system.
Remount the file system linux
umount
command followed by the mount point. For instance:Make sure you have the necessary permissions or use sudo
to execute the command with root privileges.
mount
command along with the appropriate options. For example, to remount the file system with read-write permissions, you can use:Here, -o remount,rw
specifies the options to remount the
file system as read-write. Adjust the command based on your requirements
and the specific file system you want to remount.
Note: If you want to specify additional mount options (e.g., changing
file system type or modifying options), you can include them in the mount
command as well.
4. Verify the remount: You can use the mount
or df
command again to verify that the file system has been successfully
remounted. Check the mount options and ensure that the changes you
intended are reflected.
Create Quota Database Files
Linux is now capable of working with disk quotas on /home. To enable full quota supprt, we must run the quotacheck command.
quotacheck will create two files −
- aquota.user
- aquota.group
These are used to store quota information for the quota enabled disks/partitions.
Following are the common quotacheck switches.
These are used to store quota information for the quota enabled disks/partitions.
Following are the common quotacheck switches.
SWITCH | ACTION |
---|---|
-u | Checks for user quotas |
-g | Checks for group quotas |
-c | Quotas should be enabled for each file system with enables quotas |
-v | Displays verbose output |
Add Quota Limits Per User linux
To add quota limits per user in Linux, you can use the edquota
command. This command allows you to set disk quota limits for individual users on a file system. Here's how you can do it:
1 Identify the file system: Determine the file system on which you want to
set the quota limits. Make sure quotas are enabled on that file system.
You can check the /etc/fstab
file or use the mount
command to find the mount point of the file system
2 Set quota limits: Use the edquota
command to set the quota limits for a specific user. Here's the basic syntax:
Replace username
with the username of the user for whom you want to set the quota limits. Replace /mnt/myfilesystem
with the mount point of the file system on which you want to set the quotas.
edquota
command will open an editor (usually Vi or Vim) with the current quota settings for the specified user. You can modify these values to set the desired quota limits.The file typically contains columns for
Block soft limit
, Block hard limit
, Inode soft limit
, and Inode hard limit
. The soft limits define the threshold where users will start receiving warnings, while the hard limits are the actual quota limits. You can set these values based on your requirements.Filesystem blocks soft hard inodes soft hard
/dev/sda1 100 10 20 5 0 0
Comments
Post a Comment