linux查看目录磁盘限额,CentOS Linux磁盘限额设置

操作系统版本:

[root@localhost samba]# uname -a

Linux localhost.localdomain 2.6.9-78.EL #1 Thu Jul 24 23:46:01 EDT 2008 i686 athlon i386 GNU/Linux

1、检查系统是否安装quota包:

[root@localhost samba]# rpm -qa |grep quota

quota-3.12-7.el4

我的系统安装好了。

2、设置需要做用户/组磁盘限额的文件系统

编辑/etc/fstab文件,对用户进行限制,添加usrquota,对组进行限制,添加grpquota。如下:

[root@localhost samba]# cat /etc/fstab

# This file is edited by fstab-sync - see 'man fstab-sync' for details

LABEL=/                 /                       ext3    defaults        1 1

LABEL=/boot             /boot                   ext3    defaults        1 2

none                    /dev/pts                devpts  gid=5,mode=620  0 0

none                    /dev/shm                tmpfs   defaults        0 0

none                    /proc                   proc    defaults        0 0

none                    /sys                    sysfs   defaults        0 0

LABEL=/usr              /usr                    ext3    defaults,usrquota,grpquota      1 2

LABEL=/var              /var                    ext3    defaults        1 2

LABEL=SWAP-sda6         swap                    swap    defaults        0 0

我在系统分区的时候没有分home分区,就在usr分区做一下试验。

3,重启操作系统,重新挂载文件系统。

4,为启用磁盘限额的文件系统创建限额文件

[root@localhost dev]# quotacheck -gumv /usr

quotacheck: Scanning /dev/sd5 [/usr] done

quotacheck: Cannot stat old user quota file: No such file or directory

quotacheck: Cannot stat old group quota file: No such file or directory

quotacheck: Cannot stat old user quota file: No such file or directory

quotacheck: Cannot stat old group quota file: No such file or directory

quotacheck: Checked 3210 directories and 8310 files

quotacheck: Old file not found.

quotacheck: Old file not found.

-g参数:扫描磁盘空间时,计算每个组标识符(GID)所占用的目录和文件数目;

-u参数:扫描磁盘空间时,计算每个用户标识符(UID)所占用的目录和文件数目;

-v参数:标识命令执行过程。

-m参数:强制执行命令。

此时会在/usr文件系统根目录下自动生成两个文件:aquota.user和aquota.group

[root@localhost dev]# ls -l /usr/aquota.*

-rw------- 1 root root 8192 Aug 17 22:18 /usr/aquota.group

-rw------- 1 root root 8192 Aug 17 22:18 /usr/aquota.user

5,开启磁盘限额

[root@localhost dev]# quotaon -augv

/dev/sd5 [/usr]: group quotas turned on

/dev/sd5 [/usr]: user quotas turned on

-a参数:开启在/ect/fstab文件里,有加入quota设置的分区的空间限制;

-g参数:开启群组的磁盘空间限制;

-u参数:开启用户的磁盘空间限制;

-v参数:显示指令指令执行过程.

6,编辑用户/组的磁盘限额大小(本文以zhang用户为例,组配置过程类似,本文不列出)

[root@localhost dev]#edquota -u zhang

回车后会调用vi编辑,如下:

Disk quotas for user zhang (uid 500):

Filesystem                   blocks       soft       hard     inodes     soft     hard

/dev/sda5                    371532     500000     800000         40       20       40

说明:

Filessystem:表示当前启用磁盘限额的文件系统名称;

blocks:表示当前用户已使用块数量大小;

soft:表示软限制(非强制性限制)磁盘空间大小,单位为KBytes;

hard:表示硬限制(强制性限制)磁盘空间大小,单位为KBytes;

inodes:表示当前用户已使用文件个数;

soft:表示软限制(非强制性限制)文件个数;

hard:表示硬限制(强制性限制)文件个数。

“0”表示没有不限制,把想要设置的数值填入对应项保存退出。

7,查看某个用户的磁盘限额情况

[root@localhost dev]# quota -u zhang

Disk quotas for user zhang (uid 500):

Filesystem  blocks   quota   limit   grace   files   quota   limit   grace

/dev/sda5  371532  500000  800000              40*     20      40

说明:查看某个组的磁盘限额情况使用-g参数

8,查看某个文件系统的磁盘限额(包括用户和组限额)

[root@localhost dev]#repquota -ugv /usr

*** Report for user quotas on device /dev/sda5

Block grace time: 7days; Inode grace time: 7days

Block limits                File limits

User            used    soft    hard  grace    used  soft  hard  grace

----------------------------------------------------------------------

root      --  871068       0       0          30366     0     0

rpm       --    2464       0       0             89     0     0

zhang     -+  371532  500000  800000             40    20    40  6days

zbhdpx    --      16  300000  500000              4   100   120

Statistics:

Total blocks: 7

Data blocks: 1

Entries: 4

Used average: 4.000000

*** Report for group quotas on device /dev/sda5

Block grace time: 7days; Inode grace time: 7days

Block limits                File limits

Group           used    soft    hard  grace    used  soft  hard  grace

----------------------------------------------------------------------

root      --  869892       0       0          30354     0     0

tty       --      24       0       0              2     0     0

mail      --     100       0       0              2     0     0

uucp      --     168       0       0              1     0     0

lock      --      16       0       0              1     0     0

nobody    --      68       0       0              1     0     0

users     --  371548       0       0             44     0     0

rpm       --    2464       0       0             89     0     0

utmp      --      12       0       0              1     0     0

slocate   --      48       0       0              3     0     0

smmsp     --     740       0       0              1     0     0

Statistics:

Total blocks: 6

Data blocks: 1

Entries: 11

Used average: 11.000000

9,编辑宽限时间

[root@localhost dev]#edquota -t

[root@localhost dev]#edquota -t

Grace period before enforcing soft limits for users:

Time units may be: days, hours, minutes, or seconds

Filesystem             Block grace period     Inode grace period

/dev/sda5                     7days                  7days

系统缺省是7天,可改成你实际需要的值保存后退出即可。

特别要说明的是,当实际使用的空间未超过软(soft)限制,宽限(grace)时间是不会出现在quota -u username输出中的。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值