Ubuntu system gives disk quota (Quota)
Requirements: disk quota for U disk, different usage capacity for different users
Step 1: install the quota command
Sudo apt-get install quota
Step 2: partition the USB disk. All the capacity is divided into one partition.
Sudo fdisk / dev/sdb
N-> p-> Enter- > w
Step 3: format the partition (ext3)
Sudo mkfs.ext3 / dev/sdb1
If you are required to enter information, just Enter (enter)
Step 4: Mount the partition / dev/sdb1
Sudo mkdir / mnt/quotadir
Sudo mount / dev/sdb1 / mnt/quotadir/
Mount | grep sdb1
Step 5: quota permissions for this directory
Sudo mount-o remount,usrquota,grpquota / mnt/quotadir/
Mount | grep sdb1
Step 6: create a quota record file and scan it with quotacheck.
Sudo quotacheck-avug
Step 7: turn the quota service on and off
Open: sudo quotaon-vug / mnt/quotadir/
Close: sudo quotaoff-vug / mnt/quotadir/
Step 8: create two users in the same group, and then set a space quota for these two users.
Sudo groupadd quotagroup
Cat / etc/group | grep quotagroup
Sudo useradd-g quotagroup quotauser1
Sudo useradd-g quotagroup quotauser2
Cat / etc/passwd | grep quota
Step 9: assign quotas to specified users or groups
Assign 250m quota to quotauser1, which cannot exceed 300M:sudo edquota-u quotauser1
Assign 250m quota to quotauser2, which cannot exceed 300M:sudo edquota-u quotauser2
In the same way, the second user wrote it himself.
Assign 500m quota to quotagroup group, which cannot exceed 600M:sudo edquota-g quotagroup
Set a grace period of 14 days: sudo edquota-t
Step 10: show the quota phenomenon of users or groups
Show user quota: sudo quota-uvs quotauser1 quotauser2
Show group quotas: sudo quota-gvs quotagroup
Step 11: display quota information for the file system
Display user: sudo repquota-auvs
Show group: sudo repquota-agvs
Step 12: test whether it is effective
Switch user: sudo su quotauser1
Create a large file: dd if=/dev/zero of=bigfile bs=1M count=270
Switch back to primary user view: sudo repquota-auvs
When writing again, an error will be reported, and only the capacity of the upper limit value can be written.
Over and out.