Skip to main content

User quota in Linux step by step


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:

  1. 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.

  2. Locate the GRUB_CMDLINE_LINUX line: Within the bootloader configuration file, you should find a line starting with GRUB_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 include xfs, rootflags, and xfs_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 examplexfs_options=allocsize=64m,inode64.
  3. Note: Make sure to separate multiple options with spaces.

  4. Save the changes: After making the necessary modifications, save the file and exit the text editor.
  5. 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 or update-grub command. This step ensures that the changes take effect during the next boot.
  6. 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

To remount a file system in Linux, you can use the mount command with the appropriate options. Here's how you can remount a file system:

1. Identify the current mount point: Determine the mount point of the file system you want to remount. You can use the df command to list all mounted file systems along with their mount points. For example, if you want to remount the /dev/sda1 partition, you might see something like this:

In this example, the mount point is /mnt/myfilesystem.

2. Unmount the file system: Before remounting, you need to unmount the file system. Use the 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.

3. Remount the file system: Once the file system is unmounted, you can remount it with the desired options. Use the 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

These are used to store quota information for the quota enabled disks/partitions.
Following are the common quotacheck switches.

-uChecks for user quotas
-gChecks for group quotas
-cQuotas should be enabled for each file system with enables quotas
-vDisplays 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.

Define the quota limits: After executing the command, the 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.

For example:
Filesystem                   blocks       soft       hard     inodes     soft     hard
/dev/sda1                        100        10         20          5        0        0

In this example, the soft block limit is set to 10 and the hard block limit is set to 20.

Save and exit the editor: After setting the desired quota limits, save the changes and exit the editor. In Vi or Vim, you can typically do this by pressing Esc, followed by :wq and then pressing Enter.

Apply the changes: The quota limits will take effect immediately. The user will be subject to the defined quota limits on the specified file system.

You can repeat these steps for each user you want to set quota limits for. Remember to adjust the mount point and user name accordingly.

Note: Make sure you have the necessary permissions or use sudo to execute the edquota command with root privileges since modifying quotas typically requires administrative access.


Popular posts from this blog

Microsoft-windows-server-2019 New-Features

 windows server 2019is that latest windows server operating system till date and provides the best windows server  operating system for cloud solutions and provides the best integration with Azure  when compared to windows server 2016. The current version of windows server 2019 improves on the previous windows 2016 version in regards with better performance, improved security. better hyper-convergence and outstanding optimizations for hybrid integration. New Features in windows server 2019 Hybrid cloud option: windows 2019 server support Hybrid Cloud, Both on-premise and cloud solutions work together option. the cloud solution can work simultaneously with the on-premise version. New Features in windows server 2019 Storage Migration Service: storage Migration is a new feature/tool that helps migrate date from the legacy plat from to the new 2019 plat from. storage Migration services supports migrating data all the way from windows server 2023 to windows server 2019. it enables the inv

Crontab in linux- Examples and Command

A cron job in Linux is a time-based job scheduler. It is a utility that allows you to schedule and automate the execution of scripts, commands, or programs at specific intervals or at predetermined times. Cron jobs are commonly used in Linux and other Unix-like operating systems to automate repetitive tasks, such as system maintenance, log rotation, backups, and periodic data processing. The cron service is responsible for running these scheduled tasks. It reads a configuration file called the "crontab" (short for cron table) to determine when and which commands to execute. Each user on a Linux system can have their own crontab file, which lists the cron jobs specific to that user The crontab file uses a specific format to define the schedule of a cron job. It consists of six fields that specify the timing of the job: scss * * * * * command_to_be_executed | | | | | | | | | +----- Day of the Week ( 0 - 7 ) (Sunday = 0 or 7 ) | | | +------- Month ( 1 - 12 ) | | +--

How TO Manage Groups Ad User on linux

Linux Admin - User Managemen When discussing user management, we have three important terms to understand − Users   Groups Permissions We have already discussed in-depth permissions as applied to files and folders. In this chapter, let's discuss about users and groups. CentOS Users In CentOS, there are two types accounts –  System accounts − Used for a daemon or other piece of software .   Interactive accounts − Usually assigned to a user for accessing system resources . The main difference between the two user types is − System accounts are used by daemons to access files and directories. These will usually be disallowed from interactive login via shell or physical console login .. Interactive accounts are used by end-users to access computing resources from either a shell or physical console login. With this basic understanding of users, let's now create a new user for Bob Jones in the Accounting Department. A new user is added with the adduser command. Following

Why use vSAN in VMware?

 VMware vSAN, which stands for VMware Virtual SAN, is a software-defined storage solution offered by VMware. It is a component of VMware's vSphere virtualization platform and is designed to provide highly scalable, high-performance shared storage for virtual machines (VMs) in a vSphere environment. vSAN allows you to pool together the direct-attached storage devices (such as hard drives or solid-state drives) from multiple servers in a vSphere cluster and create a distributed storage infrastructure. By aggregating the storage resources from these servers, vSAN creates a shared storage pool that can be utilized by VMs running on those servers. Key features and benefits of VMware vSAN include: Hyperconverged Infrastructure (HCI): vSAN is a key component of VMware's HCI solution. It combines compute, storage, and virtualization resources into a single software-defined platform, simplifying data center operations and reducing hardware costs. Highly scalable and elastic : vSAN a

how to install VMware esxi tools in windows server 2019 step by step

To install VMware Tools on a Windows Server 2019 virtual machine running on VMware esxi, you can follow these step-by-step instructions: Start the Windows Server 2019 virtual machine. 2. From the VMware menu, go to VM -> Guest -> Install/Upgrade VMware Tools. This will mount the VMware Tools ISO to the virtual machine 3. Open File Explorer on the Windows Server 2019 virtual machine.  4.  Locate the CD/DVD drive, which should show the VMware Tools disc icon. 5. Right-click the CD/DVD drive and select "Open" or double-click it to open the contents. 6. Run the "setup.exe" file to begin the VMware Tools installation. 7. If prompted by User Account Control (UAC), click "Yes" to allow the installation to proceed. 8. The VMware Tools installation wizard will appear. Click "Next" to proceed. 9.  On the next screen, select the desired installation options. The default options are usually suitable for most installations,

windows server 2019 dns configuration step by step

To configure DNS on Windows Server 2019, you can follow these step-by-step instructions: 1. Install DNS Server role: 2. Open "Server Manager" by clicking on the Windows icon and selecting "Server Manager." 3. Click on "Manage" at the top-right corner and select "Add Roles and Features." 4.  Follow the wizard and select the appropriate options until you reach the "Server Roles" page. 5. Expand "DNS Server" and select it. 6. Click "Next" and then "Install" to start the installation process. 7. Wait for the installation to complete. 8. After the installation, open "Server Manager" again. 9. Click on "Tools" at the top-right corner and select "DNS." 10. Configure Forward Lookup Zone: 11 . In the DNS Manager, right-click on your server name and select "Configure a DNS Server." 12. Select the zone type (Primary, Secondary, or Stub) and click "Next." 13. Enter the