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 toapp
:# 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