Disk managements

Example 1
Quota is implemented on /home but not working properly. Find out the Problem and implement the quota to vinita to have a soft limit 50 inodes (files) and hard limit of 100 inodes (files).

Example 2
vinita user tried by:
dd if=/dev/zero of=/home/vinita/test bs=1024 count=50
files created successfully. Again vinita tried to create file having 100k using following command:
dd if=/dev/zero of=/home/vinita/test1 bs=1024 count=100
But she is unable to create the file. Make the user can create the file less then 100K.

Solutions

Example 2 is extremely complicated question from Redhat. Actually question is giving scenario to you to implement quota to vinita user. You should apply the quota to vinita user on /home that vinita user shouldn’t occupied space more than 100K.

To solve disk quota question follow this guide

Check the quota RPM (installed by default)
disk quota rpm
Now open /etc/fstab file to enable quota entry
/etc/fstab

You can tell Linux to start tracking user quotas by adding the keyword usrquota under the options column. Similarly, you can tell Linux to start tracking group quotas with the grpquota option.

I add both user and group quotas to the /home directory filesystem

/etc/fstab

Either Reboot the System or remount the partition and verify it
 remount home partition

The next step is to create quota files. For user and group quotas, you will need to create the aquota.user and aquota.group files in the selected filesystem before you can activate actual quotas.
You can do it either manually or the appropriate quotacheck command will create them automatically.
For the /home directory described earlier, you would use the following commands:

# mount -o remount /home
# quotacheck -cugm /home

The options for quotacheck are

  • -c Performs a new scan.
  • -v Performs a verbose scan.
  • -u Scans for user quotas.
  • -g Scans for group quotas.
  • -m Remounts the scanned filesystem.

This will check the current quota information for all users, groups, and partitions. It stores this information in the appropriate quota partitions. Once the command is run, you should be able to find the aquota.user and aquota.group files in the configured directory.


or you can create these files manually

#touch /home/aquota.group
#touch /home/aquota.user

aquota.group aquota.user files
On this quota by quotaon command and create an example user named vinita. use edquota command to set quota on vinita user.

edquota command will edits the aquota.user or aquota.group file with the vi editor. In our example, we have a user named vinita, and we want to restrict how much disk space she is allowed to use.

Set softlink to 50 and 100 to hard link

You can also set grace period for user ( set only if you are asked by examiner)

We will change default 7 days grace period to 10 days.

Remount the partition and verify it

 remount home partition
Verify that you have successfully implemented disk quota

Now login from vinita

When testing quotas, there is one useful technique that creates a blank file of the desired size. For example, if you want to create a 100MB file named test in the local directory, run this command
dd if=/dev/zero of=test bs=1k count=100000 .

impletementing disk quota

When user vinita run dd command first time to create a blank file more then 50 Mb she got an warning and the file was created. As she is allowed to exceed her soft limit for 10 days.

Second time she tried to create a file of 500 Mb. As you can see in image she was able only to create a file of 20 Mb. As she can not exceed her hard limit that is set to 100 inode.

In third time she is denied to use any more space as she have already crossed her hard limit.

You can verify the space of created file by du command with -h options.

After successfully completing your practical remove quota entry /etc/fstab

Now turn off quota by quotaoff command and remount home partition for further practical