Linux disk quota (Quota) configuration process

  
 

The disk quota configuration of Linux system is mainly divided into seven steps, as follows:

1, partition mount option configuration:

Linux default mount (Mount) is not enabled Quota option Therefore, it needs to be added in the mount option as follows:

User quota option: usrquota

User group quota option: grpquota

  • Configure the fstab file Mount options:

    [root@update ~]# vim /etc/fstab## /etc/fstab# Created by anaconda on Wed Mar 27 17:57:37 2013## Accessible filesystems, By reference, are maintained under '/dev/disk'# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info#/dev/mapper/vg_muban-lv_root /Ext4 defaults 1 1UUID=60d6041c-d344-4b85-996e-beaff6277ff3 /boot ext4 defaults 1 2/dev/mapper/vg_muban-lv_home /home ext4 usrquota 1 2/dev/mapper/vg_muban-lv_var /var ext4 defaults 1 2/dev /mapper/vg_muban-lv_swap swap swap defaults 0 0tmpfs /dev/shm tmpfs defaults 0 0devpts /dev/pts devpts gid=5,mode=620 0 0sysfs /sys sysfs defaults 0 0proc /proc proc defau Lts 0 0## Note: The user quota option for enabling the home partition above is usrquota. If you want to enable group quota, the option is grpquota

  • Temporary mount is the option to add disk quota:
    < Br>

    [root@update ~]# mount -o usrquota /dev/sdb2 /mnt/homebak Note: -o post mount option

    2, remount requires Quota partition to be enabled< Br>

    Command: mount -o remount FS

    [root@update ~]# mount -o remount /home

    3, disk quota Quota check

    command :quotacheck -cum FS

    [root@update ~]# quotacheck -cum /home

    4, Enable Disk Quotas

    Command: quotaon FS

    [root@update ~]# quotaon /home

    5, edit user disk quota

    command: edquota user -f FS

    [root@update ~]# edquota barlow -f /home ##Edit the quota of the barlow user under /home Disk quotas for user barlow (uid 500): Filesystem blocks soft hard inodes soft hard/dev/mapper/vg_muban-lv_home 4144 0 102400 15 0 0## Column file system, the second column has used blocks (kb), the third column warning level, the fourth column limit level (I limit the barlow users to use up to 102400kb), the last three columns limit the number of files

    6, test check disk quota:

    command: dd; repquota -a;quota, etc.

    [barlow@update ~]$ dd if=/dev/zero of=testfiler bs=1M count=50 ##Build a 50M file

    Record a 50+0 read record 50+0 writes out 52428800 bytes (52 MB) has been copied, 0.118772 seconds, 441 MB/sec

    The above prompt appears, indicating normal write

    write again to a more than 120M Try the file:

    [barlow@update ~]$ rm testfiler ##First delete the last tested file [barlow@update ~]$ dd if=/dev/zero of=testfiler bs=1M count= 120 ##Write a 120M file dm-3: write failed, user block limit reached.dd: Write "testfiler": exceeds disk quota and records 96+0 read record 95+0 write 100614144 bytes (101 MB) has been copied, 0.265027 seconds, 380 MB/sec

    There is more than the disk quota, check the file size:

    [barlow@update ~]$ ll total usage 98256 -rw-rw-r-- 1 barlow barlow 100614144 June 11 10:47 testfil Er

    At this point, the disk quota configuration ends.

  • Copyright © Windows knowledge All Rights Reserved