Linux User Management: Configuring Group Disk Quotas

30 minutes
  • 6 Learning Objectives

About this Hands-on Lab

User and group disk quotas set limits on how much storage a user can consume. Quotas are important to preventing users from consuming all of the disk space on a system. In this lab, students will install the `quota` package and learn to configure group and user quotas for a filesystem.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create the app Group as Well as appuser1 and appuser2, and Set the app Group as the Primary Group for Both Users
# groupadd app
# useradd -g appuser1
# useradd -g app appuser2
Create a Filesystem on One of the 2 GB Drives Configured on the System

Check to see what disks are available:

# lsblk

Create a partition on the /dev/xvdb disk:

# fdisk /dev/xvdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xb3c6ea84.

Command (m for help): n
Partition type:
  p   primary (0 primary, 0 extended, 4 free)
  e   extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-4194303, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303):
Using default value 4194303
Partition 1 of type Linux and of size 2 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Run the partprobe command to ensure the partition table has been updated:

# partprobe

Create an ext4 filesystem on the /dev/xvdb1 partition:

# mkfs -t ext4 /dev/xvdb1
Create the Directory for the Mount Point and Change the Group to app
# mkdir /app
Configure /etc/fstab with the UUID of /dev/xvdb1, Mount the Filesystem, and change the group of the filesystem to app.

Get the UUID for /dev/xvdb1:

# blkid /dev/xvdb1
/dev/xvdb1: UUID="d6a5691b-a045-463f-bf2b-74d0c71895e2" TYPE="ext4"

Paste the UUID into the /etc/fstab file with the following options:

# vim /etc/fstab
UUID=d6a5691b-a045-463f-bf2b-74d0c71895e2       /app    ext4    defaults,grpquota       1       2

Mount newly added filesytems configured in /etc/fstab:

# mount -a

Change the group of the /app filesystem to app:

# chgrp app /app
Install the quota Package, Create the Quota Files for the /app Filesystem, and Generate the Table of Current Disk Usage for Each Filesystem

Install the quota package:

yum install -y quota

Create the quota files for the /app filesystem:

quotacheck -cug /app

Generate the table of current disk usage per filesystem:

quotacheck -avug
Assign a Soft Quota of 512 KB and a Hard Quota of 1M (1024KB) to the app Group, Then Turn Quotas on and Check the Group Quota Configuration for /app

Assign a soft quota of 512 KB and a hard quota of 1M (1024KB) to the app group:

$ edquota -g app
Disk quotas for group app (gid 1004):
  Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/xvdb1                        4        512       1024          1        0        0

Turn quotas on for the filesystem:

$ quotaon -vug /app

Verify the group quota configuration for /app:

$ repquota -g /app
*** Report for group quotas on device /dev/xvdb1
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
Group           used    soft    hard  grace    used  soft  hard  grace
root      --      16       0       0              1     0     0       
app       --       4     512    1024              1     0     0       

Additional Resources

Please make sure to use the lab environment for this exercise and not the cloud playground, as the cloud playground servers aren't configured to support this lab.

The scenario for this lab is as follows:

ABC Company has hired a new team of application administrators to install a new application.

To complete this lab, two user accounts should be created, named appuser1 and appuser2, with the app group set as their primary group. Then the /app filesystem should be created on one of the 2GB disks allocated to the system, and its type should be ext4. Next, set a 500K soft limit and a 1M hard limit for the app group on the /app filesystem. Then verify the limits were set successfully. Good luck!

Please use the lab environment for this exercise, and not the Cloud Playground. To gain root access, log into the lab environment with the cloud_user account and issue sudo -i.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!