- Lab
- A Cloud Guru
Linux User Management: Configuring Group Disk Quotas
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.
Path Info
Table of Contents
-
Challenge
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
-
Challenge
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
-
Challenge
Create the Directory for the Mount Point and Change the Group to app
# mkdir /app
-
Challenge
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
-
Challenge
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
-
Challenge
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
What's a lab?
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.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.