Practices for Lesson 9: Overview
Practice 9-3: Setting Disk Quotas
Overview
In this practice, you set quotas on a directory for the oracle user. You also remove the quotas and the ACL on the directory.
Assumptions
You switch between the root user and the oracle user for this practice.
Tasks
1. As the root user, configure disk quotas.
a. Click the “root@host03” tab to enter commands as the root user. b. Use the umount command to unmount the file system on /Dev.
[root@host03]# umount /Dev
c. Use the mount command with the –o acl,usrquota,grpquota options to remount /dev/xvdb1 on /Dev.
• These options enable disk quotas for users and groups and also enable ACL support.
[root@host03]# mount –t ext4 –o acl,usrquota,grpquota /dev/xvdb1
/Dev
d. Use the quotacheck command to create disk usage tables for /Dev. [root@host03]# quotacheck –cug /Dev
e. Use the ls command to display the files created in /Dev. [root@host03]# ls –l /Dev
-rw---. root root ... aquota.group -rw---. root root ... aquota.user ...
f. Use the quotaon command to enable quotas on /Dev. [root@host03]# quotaon /Dev
g. Use the repquota command to report disk usage on /Dev. [root@host03]# repquota /Dev
*** Report for user quotas on device /dev/xvdb1 Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace --- root -- 20 0 0 2 0 0
oracle -- 0 0 0 1 0 0 h. Use the edquota command to limit the oracle user.
• This command invokes the vi editor.
juan corso arias (juanฺcorso@unimilitarฺeduฺco) has a
non-transferable license to use this Student Guideฺ
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Practices for Lesson 9: Advanced Storage Administration
• Change the block quota to set a hard limit of 2048 blocks (2 MB) for the oracle user.
[root@host03]# edquota oracle
Disk quotas for user oracle (uid 500):
Filesystem blocks soft hard inodes soft hard
/dev/xvdb1 0 0 0 1 0 0 (old entry) /dev/xvdb1 0 0 2048 1 0 0 (new entry) • Alternatively, you could use the setquota oracle 0 2048 0 0 /Dev
command.
i. Use the repquota command to report disk usage on /Dev. • Note that the hard limit for the oracle user is now 2048.
[root@host03]# repquota /Dev
*** Report for user quotas on device /dev/xvdb1 Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace --- root -- 20 0 0 2 0 0
oracle -- 0 0 2048 1 0 0 2. As the oracle user, verify the disk quota setting.
a. Click the “oracle@host03” tab to enter commands as the oracle user. b. Use the dd if=/dev/zero of=bigfile bs=1M count=4096 command to
attempt to create a 4 MB file on /Dev.
• Note the “Disk quota exceeded” error message. [oracle@host03]$ cd /Dev
[oracle@host03]$ dd if=/dev/zero of=bigfile bs=1M count=4096 xvdb1: write failed, user block limit reached.
dd: writing ‘bigfile’: Disk quota exceeded 3+0 records in
1+0 records out
2097152 bytes (2.1 MB) copied, ...
c. Use the ls command to display a long listing of the /Dev directory.
• Note that the bigfile is not 4 MB, but was truncated after quota limits were reached.
[oracle@host03]$ ls –l /Dev ...
-rw-rw-r--. 1 oracle oracle 2097152 ... bigfile ...
juan corso arias (juanฺcorso@unimilitarฺeduฺco) has a
non-transferable license to use this Student Guideฺ
d. Use the quota command to display quota information. [oracle@host03]$ quota
Disk quotas for user oracle (uid 500):
Filesystem blocks quota limit grace files quota limit grace /dev/xvdb1 2048* 0 2048 2 0 0
e. Use the rm command to delete the bigfile file in the /Dev directory. [oracle@host03]$ rm bigfile
f. Use the quota command to display quota information.
• Note the difference in the number of blocks and number of files from step 13. [oracle@host03]$ quota
Disk quotas for user oracle (uid 500):
Filesystem blocks quota limit grace files quota limit grace /dev/xvdb1 0 0 2048 1 0 0
g. Use the rm command to delete the test file in the /Dev directory. [oracle@host03]$ rm test
h. Use the cd command to change to the oracle user’s home directory. [oracle@host03]$ cd
3. As the root user, reset the /dev/xvdb1 partition for the next practice. a. Click the “root@host03” tab to enter commands as the root user.
b. Use the setquota oracle 0 0 0 0 /Dev command to reset the disk quota for the oracle user.
[root@host03]# setquota oracle 0 0 0 0 /Dev
c. Use the setfacl command to remove the ACL from the /Dev directory. [root@host03]# setfacl –b /Dev
d. Use the getfacl command to display the /Dev directory’s ACL.
• Note that the user:oracle:rwx line in the output has been removed. [root@host03]# getfacl /Dev
getfacl: Removing leading ‘/’ from absolute path names # file: Dev # owner: root # group: root user::rwx group::r-x other::r-x
e. Use the ls –ld command to display the permissions for the /Dev directory. • Note that there is no plus sign (+), indicating that the directory has no ACL.
[root@host03]# ls -ld /Dev drwxr-xr-x ... /Dev
juan corso arias (juanฺcorso@unimilitarฺeduฺco) has a
non-transferable license to use this Student Guideฺ
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Practices for Lesson 9: Advanced Storage Administration
f. Use the umount command to unmount /Dev. # umount /Dev
g. Click the “X” on the “oracle@host03” tab to close the tab.