Professional Documents
Culture Documents
Managing
Disk Quotas
Contents Related Courses
Create a Partition 1
LPIC-1: System
Create Filesystem 1 Administrator -
Exam 101
Mount the Partition 1
Turning Quotas On 6
Video
Review 6
Need Help?
Linux Academy
Community
In this lab, we’ll learn how to create partitions and filesystems to which we can apply user and group usage
quotas.
To get started, log in to one of the servers using the credentials provided on the Hands-on Lab page. Many
of the commands in this lab require elevated privileges, so be sure to switch to the root user.
Create a Partition
Let’s start by listing all of our partition tables:
[root@linuxacademy] fdisk -l
Here we’ll see a list of our available disks and their partitions. We’ll be focusing on the three ~20GB disks
that don’t have partitions created yet. We’ll choose one of these and create a partition:
At the command prompt, enter n for new. Enter p to create a primary partition, and use partition number 1.
Press enter when prompted for First cylinder to accept the default value of 1. Finally, enter +2G for the Last
cylinder to specify a 2GB partition.
When the command prompt is shown again, enter w for write to save the changes to the partition table.
We can check that the partition was created by listing the partition table for the disk we chose above:
Create Filesystem
Next, we’ll format the disk partition we just created, using the ext4 filesystem type:
-1-
Managing Disk Quotas Linux Academy
We can list the contents of the mount point directory to ensure the lost+found directory has been created
within it:
[root@linuxacademy] df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvde1 5.8G 1.4G 4.1G 26% /
tmpfs 299M 0 299M 0% /dev/shm
/dev/xvdf1 2.0G 68M 1.9G 4% /mnt/part1
Copy the partition’s UUID to the clipboard, and open the fstab file:
Save and exit the file once this has been added. To enable the option to create quotas, however, we’ll need
to unmount and remount the partition:
-2-
Managing Disk Quotas Linux Academy
[root@linuxacademy] mount -a
Exit the root shell and check that the new user was created successfully:
[root@linuxacademy] exit
[linuxacademy@linuxacademy] su myuser -
[myuser@linuxacademy] exit
[linuxacademy@linuxacademy] sudo su -
In order to provide access to all users, we’ll need to change the permissions on our mount point directory:
[root@linuxacademy] cd /mnt
[root@linuxacademy] chmod 777 part1
[root@linuxacademy] ll
total 4
drwxrwxrwx 3 root root 4096 May 19 11:06 part1
Next, we’ll create quota files so we can enforce usage quotas of our own:
We can see that the quota files were created by listing the contents of the directory:
-3-
Managing Disk Quotas Linux Academy
Save and exit the file. The quota now needs to be turned on for the filesystem we configured. We can check
the status to confirm this:
We can use the quotaon command with different options to turn the quota on:
If we check the user’s quota, we’ll see none because the user hasn’t created any files yet:
Let’s change to the myuser account to create some files and test the quota:
[root@linuxacademy] exit
[linuxacademy@linuxacademy] su myuser -
[myuser@linuxacademy] cd /mnt/part1
[myuser@linuxacademy] echo “hi” > test.txt
Now when we use the quota command as the user, we can see information about quotas and usage:
[myuser@linuxacademy] quota
Disk quotas for user myuser (uid 503):
Filesystem blocks quota limit grace files quota limit
grace
/dev/xvdf1 4 10000 11000 1 0 0
We can test that the quota is being enforced by creating a backup of the /etc directory, which should
-4-
Managing Disk Quotas Linux Academy
In the output, we’ll see that some directories are not created due to the quota being exceeded. We can check
the disk usage to see why:
[root@linuxacademy] du -sh .
11M .
If we try to create another file, we’ll be unable to do so since the quota has been exceeded:
However, we can delete some of our directories to free up space, taking our disk usage back within the
quota:
Quota Reporting
Sometimes we may need to provide a report on quota usage for all users. We can do so with the following:
[root@linuxacademy] repquota -a
Grace Period
The soft limits we’ve seen in quota configurations can be controlled by a grace period. To edit the grace
period:
-5-
Managing Disk Quotas Linux Academy
[root@linuxacademy] edquota -t
Turning Quotas On
Remember that quotas must be turned on upon boot. Rather than scripting this manually, we can edit our
rc.local file to enable this behavior:
quotaon -uagv
This will be the final process to run before the login prompt is shown on boot. By this point in the boot, our
disks will be mounted, and the quotas will be turned on before users are able to access the system.
Review
In this lab, you learned how to create a new disk partition, format it, and mount it to the system. You also
learned to create quotas and check disk usage for system users.
-6-