linux ftp 配额 quota,Linux_quota磁盘配额详解

大家可能都知道,当我们在163或者QQ上开通邮箱只有,我们都会获得一定的空间用于存储邮件和资料,还有一些FTP网站,你可以上传自己的文件在上面,以及现在许多的网络硬盘等,这些服务都对用户的硬盘使用量有一定限额,这个就是磁盘配额,为每一个用户分配不同的空间,在Linux里面就是使用quota来实现磁盘配额的。quota在大多数的Linux系统中的配置方法是一样的。

在Linux做quota这个和我装系统时候的分区有很大关系,比如你想在/home下作,最好就把/home作为一个独立分区,因为quota是对整个分区下所有的目录生效的。

Linux磁盘配额配置:

系统平台:RedHat 9.0

[root@xuqiang /]# rpm -qa | grep

quota 查看是否安装此套件。

quota-3.09-1

1, 编辑fstab,使其支持quota

我们做quota的时候一般是针对某一个分区的,那么该quota分区下所有的目录都要收quota影响的哦,所有我们要修改分区参数,。

这里我们在/home下作quota,

编辑/etc/fstab,添加usrquota和grpquota使此分区支持quota,

[root@xuqiang /]# vi /etc/fstab

LABEL=/ / ext3 defaults 1 1

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

LABEL=/home /home ext3 defaults,usrquota,grpquota

1

2

2,重新启动系统或者直接重新加载分区,使用一下命令:

[root@xuqiang /]# mount -o remount /home 重新加载做quota的分区

3,生产用户和组的配额文件

[root@xuqiang /]# quotacheck -avug

quotacheck: Scanning /dev/sda3 [/home] done

quotacheck: Checked 14 directories and 33 files

quotacheck: Old file not found.

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

-a 扫描所有在/etc/mtab内含quota支持的文件系统,注意修改fstab,重新加载系统会自动一修改mtab

文件,

-a 建立aquota.user

-g 建立群组的目录使用情况文件,aquota.group

-v 显示扫描过程,

-M 强制扫描,当以上参数出现错误的时候,可以用。

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

查看配额分区产生的文件

[root@xuqiang /]# ll /home/

总用量 52

-rw------- 1

root root 7168 9月 18 16:59 aquota.group

-rw------- 1 root root 7168 9月 18 16:59 aquota.user

3,启动磁盘配额

[root@xuqiang /]# quotaon -avug

/dev/sda3 [/home]: group quotas turned on

/dev/sda3 [/home]: user quotas turned on

3,添加用户

[root@xuqiang /]# useradd test01

[root@xuqiang /]# useradd test02

[root@xuqiang /]# passwd test01

Changing password for user test01.

New password:

BAD PASSWORD: it's WAY too short

Retype new password:

passwd: all authentication tokens updated successfully.

[root@xuqiang /]# passwd test02

Changing password for user test02.

New password:

BAD PASSWORD: it's WAY too short

Retype new password:

passwd: all authentication tokens updated successfully.

[root@xuqiang /]# ls /home/

aquota.group test01

aquota.user test02

5,为用户设定磁盘配额

[root@xuqiang /]# edquota [ -u username] [-g groupname]

[root@xuqiang /]# edquota –t 修改宽限时间

[root@xuqiang /]# edquota –p 复制范本,将某个设定好的用户的quota复制给另外一个用户,

为test01做限额:

[root@xuqiang /]# edquota -u test01

Disk quotas for user test01 (uid 520):

Filesystem

blocks soft hard inodes soft hard

/dev/sda3 44 10000 15000 11 0 0

/dev/sda3 所在分区

test01占据该分区的大小

soft 设置警告大小,到这么多的是系统警告用户

hard 当警告之后还可以使用多少的空间 ,

inodes 对I节点做限制,这个不好控制,建议不做,后面的也是和inode有关的,默认不管,

设置宽限时间,过了这个没有清除到软限制之下的,其他空间将不能使用,

[root@xuqiang /]# 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/sda3 1days 7days

[root@xuqiang /]# edquota -p test01 test02 将这个限额同样给test02用户,

查询用户的限额情况:

[root@xuqiang /]# quota -vu test01 test02

Disk quotas for user test01 (uid 520):

Filesystem blocks quota limit grace files quota limit grace

/dev/sda3 44 10000 15000 11 0 0

Disk quotas for user test02 (uid 521):

Filesystem blocks quota limit grace files quota limit grace

/dev/sda3 124 10000 15000 30 0 0

[root@xuqiang /]# repquota –a 显示更详细的,

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

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

Block

limits File limits

User used soft hard grace used soft hard grace

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

root -- 76

0 0 12 0 0

h01 -- 60 0 0 15 0 0

test01 -- 44 10000 15000 11 0 0

test02 -- 124 10000 15000 30 0 0

#522 -- 56

0 0 14 0 0

测试:

[root@xuqiang /]# su - test01 使用test01用户登录,

[test01@hongtu test01]$ cp -Rv

/etc/ . 拷贝一个比较大的文件来试试

cp: 正在写入‘./etc/named.conf’: 超出磁盘限额

cp: 无法创建目录‘./etc/vsftpd’: 超出磁盘限额

‘/etc/vsftpd.user_list’ ->

‘./etc/vsftpd.user_list’

cp: 正在写入‘./etc/vsftpd.user_list’: 超出磁盘限额

‘/etc/vsftpd.ftpusers’ ->

‘./etc/vsftpd.ftpusers’

cp: 正在写入‘./etc/vsftpd.ftpusers’: 超出磁盘限额

‘/etc/gshadow-’ -> ‘./etc/gshadow-’

cp: 正在写入‘./etc/gshadow-’: 超出磁盘限额

OK,。C盘配额配置完成哦。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值