磁盘配额 [root@rhel ~]# rpm -qa | grep quota quota-3.17-18.el6.i686 [root@rhel ~]# rpm -ql quota | grep sbin /sbin/quotacheck /sbin/quotaoff /sbin/quotaon /usr/sbin/convertquota /usr/sbin/edquota /usr/sbin/quota_nld /usr/sbin/quotastats /usr/sbin/repquota /usr/sbin/rpc.rquotad /usr/sbin/setquota /usr/sbin/warnquota [root@localhost ~]# mkfs -t ext4, /dev/mail_store/mail 此处格式化分区很重要,注格式化的分区系统和挂在点的文件系统要一致。 (如果分区已经挂载,修改了/etc/fstab文件以后,可以执行 mount -o remount /mailbox 进行重新挂载。 若不修改fstab文件,在挂载命令行中也可以手动添加磁盘配额支持,例如: mount -o remount,usrquota,grpquota /dev/sdb1 /mailbox) [root@rhel ~]# mount -o remount,usrquota,grpquota /dev/mail_store/mail /mailbox/ [root@rhel ~]# mount /dev/sda3 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_ubject_r:tmpfs_t:s0") /dev/sda1 on /boot type ext4 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev) /dev/sr0 on /media/RHEL_6.4 i386 Disc 1 type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500) /dev/mapper/mail_store-mail on /mailbox type ext3 (rw,usrquota,grpquota) [root@rhel ~]# chmod 777 /mailbox/ [root@rhel ~]# vi /etc/fstab [root@rhel ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Fri Jun 7 00:57:58 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 # UUID=3eb0c7ea-31b0-460f-961a-414739c61207 / ext4 defaults 1 1 UUID=d6cdff6e-b69d-45f0-82a6-6d2062007bb1 /boot ext4 defaults 1 2 UUID=bf3e0ead-dd2f-4ecd-875d-c22270fe60b0 swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 /dev/mapper/mail_store-mail /mailbox ext3 defaults,usrquota,grpquota 0 0 (出现上面的错误,提示不能创建/mailbox/aquota.user /mailbox/aquota.group 这2个文件,没有这个文件,没有权限操作。在home目录也没有发现这2个文件。 原因找到了,需要关闭selinux,然后就可以执行了。关闭selinux的命令是#setenforce 0 ) [root@rhel ~]# quotacheck –augcv quotacheck: Your kernel probably supports journaled quota but you are not using it. Consider switching to journaled quota to avoid running quotacheck after an unclean shutdown. quotacheck: Scanning /dev/mapper/mail_store-mail [/mailbox] done quotacheck: Cannot stat old user quota file: \u6ca1\u6709\u90a3\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55 quotacheck: Cannot stat old group quota file: \u6ca1\u6709\u90a3\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55 quotacheck: Cannot stat old user quota file: \u6ca1\u6709\u90a3\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55 quotacheck: Cannot stat old group quota file: \u6ca1\u6709\u90a3\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55 quotacheck: Checked 3 directories and 2 files quotacheck: Old file not found. quotacheck: Old file not found. [root@rhel ~]# ls -l /mailbox/aquota.* -rw-------. 1 root root 6144 6\u6708 7 04:51 /mailbox/aquota.group -rw-------. 1 root root 6144 6\u6708 7 04:51 /mailbox/aquota.user [root@rhel ~]# edquota -u zhangsan Disk quotas for user zhangsan (uid 501): Filesystem blocks soft hard inodes soft hard /dev/mapper/mail_store-mail 0 80000 100000 0 40 50 [root@rhel ~]# edquota -g zhangsan [root@rhel ~]# edquota -t [root@rhel ~]# quotaon -ugv /mailbox/ /dev/mapper/mail_store-mail [/mailbox]: group quotas turned on /dev/mapper/mail_store-mail [/mailbox]: user quotas turned on [root@rhel ~]# quota -u zhangsan Disk quotas for user zhangsan (uid 500): none [root@rhel ~]# su - zhangsan [zhangsan@rhel ~]$ su - \u5bc6\u7801\uff1a [root@rhel ~]# quota -u zhangsan Disk quotas for user zhangsan (uid 500): Filesystem blocks quota limit grace files quota limit grace /dev/mapper/mail_store-mail 3012 80000 100000 49* 40 50 7days [root@rhel ~]# quota -g zhangsan Disk quotas for group zhangsan (gid 500): none [root@rhel ~]#
|