全部博文(16)
分类: LINUX
2009-05-03 19:56:43
Device Boot Start End Blocks Id System
/dev/sdb1 1 25 200781 83 Linux
2,挂载,加上配额选项
[root@mylab ~]# mount -o usrquota /dev/sdb1 /tmp/
3,查看/tmp下的内容
[root@mylab ~]# ll /tmp/
total 12
drwx------ 2 root root 12288 May 1 21:14 lost+found
4,用quotacheck生成配额文件
[root@mylab ~]# quotacheck /tmp
[root@mylab ~]# ll /tmp/
total 18
-rw------- 1 root root 6144 May 1 22:54 aquota.user
drwx------ 2 root root 12288 May 1 21:14 lost+found
5,查看挂在分区属性
[root@mylab ~]# mount
/dev/sda3 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sdb1 on /tmp type ext3 (rw,usrquota)
6,用edquota user 来编辑用户的配额文件,将hard改为10,单位为KB
[root@mylab ~]# edquota lab
Disk quotas for user lab (uid 500):
Filesystem blocks soft hard inodes soft hard
/dev/sdb1 0 0 10 0 0 0
7,开启quota
[root@mylab ~]# quotaon /tmp/
8,切换lab用户测试
[root@mylab ~]# su - lab
[lab@mylab ~]$ cd /tmp/
[lab@mylab tmp]$ ls
aquota.user lost+found
9,写一个5KB的空文件,成功
[lab@mylab tmp]$ dd if=/dev/zero of=/tmp/test bs=1024 count=5
5+0 records in
5+0 records out
5120 bytes (5.1 kB) copied, 1e-09 seconds, 5.1 TB/s
10,写一个15KB的文件,提示超出限制
[lab@mylab tmp]$ dd if=/dev/zero of=/tmp/test bs=1024 count=15
sdb1: write failed, user block limit reached.
dd: writing `/tmp/test': Disk quota exceeded
11+0 records in
10+0 records out
10240 bytes (10 kB) copied, 0.00121862 seconds, 8.4 MB/s
11,写出的最大为限额大小
[lab@mylab tmp]$ ll
total 29
-rw------- 1 root root 7168 May 1 23:22 aquota.user
drwx------ 2 root root 12288 May 1 21:14 lost+found
-rw-rw-r-- 1 lab lab 10240 May 1 23:22 test
12,以下为关闭quota测试,没有限制了
[lab@mylab tmp]$ exit
logout
[root@mylab ~]# quotaoff /tmp/
[root@mylab ~]# su - lab
[lab@mylab ~]$ dd if=/dev/zero of=/tmp/test bs=1024 count=15
15+0 records in
15+0 records out
15360 bytes (15 kB) copied, 0.00175783 seconds, 8.7 MB/s
[lab@mylab ~]$ ll /tmp/
total 35
-rw------- 1 root root 7168 May 1 23:24 aquota.user
drwx------ 2 root root 12288 May 1 21:14 lost+found
-rw-rw-r-- 1 lab lab 15360 May 1 23:24 test