系統(tǒng)之家 - 系統(tǒng)光盤下載網(wǎng)站!

當(dāng)前位置:系統(tǒng)之家 > 系統(tǒng)教程 > CentOS 6修改磁盤配額限制

CentOS 6如何修改磁盤配額限制

時(shí)間:2015-02-10 17:54:22 作者:qipeng 來源:系統(tǒng)之家 1. 掃描二維碼隨時(shí)看資訊 2. 請(qǐng)使用手機(jī)瀏覽器訪問: https://m.xitongzhijia.net/xtjc/20150210/37985.html 手機(jī)查看 評(píng)論

  為了避免用戶過度的使用磁盤空間,管理員會(huì)對(duì)磁盤空間進(jìn)行配額限制,以免影響系統(tǒng)運(yùn)行,但在有些時(shí)候,因?yàn)榇疟P配額限制設(shè)置的不合理,導(dǎo)致磁盤空間不夠用,這時(shí)就需要對(duì)磁盤配額進(jìn)行修改,下面小編就給大家介紹下CentOS 6如何修改磁盤配額限制。

 CentOS 6如何修改磁盤配額限制

  CentOS建五個(gè)用戶,均需要進(jìn)行磁盤配額限制,每個(gè)用戶的配額為 10MB (hard) 以及 8MB (soft)

  環(huán)境

 。踨oot@localhost ~]# uname -a

  Linux localhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

 。踨oot@localhost ~]# nl /etc/issue

  1 CentOS release 6.5 (Final)

  2 Kernel \r on an \m

  1、建5用戶vbirdN

  [root@linuxidc ~]# vi au.sh

  #!/bin/bash

  groupadd vbirdgroup

  for username in vbird1 vbird2 vbird3 vbird4 vbird5

  do

  useradd -G vbirdgroup $username

  echo “password” | passwd --stdin $username

  done

 。踨oot@linuxidc ~]# sh au.sh

  Changing password for user vbird1.

  passwd: all authentication tokens updated successfully.

  Changing password for user vbird2.

  passwd: all authentication tokens updated successfully.

  Changing password for user vbird3.

  passwd: all authentication tokens updated successfully.

  Changing password for user vbird4.

  passwd: all authentication tokens updated successfully.

  Changing password for user vbird5.

  passwd: all authentication tokens updated successfully.

  2、掃一眼家目錄

 。踨oot@linuxidc ~]# ll /home/

  total 28

  drwx------。 4 vbird1 vbird1 4096 Dec 1 15:57 vbird1

  drwx------。 4 vbird2 vbird2 4096 Dec 1 15:57 vbird2

  drwx------。 4 vbird3 vbird3 4096 Dec 1 15:57 vbird3

  drwx------。 4 vbird4 vbird4 4096 Dec 1 15:57 vbird4

  drwx------。 4 vbird5 vbird5 4096 Dec 1 15:57 vbird5

  drwx------。 4 zxw zxw 4096 Sep 18 18:03 zxw

  瞅一下vb1的組和id

 。踨oot@linuxidc ~]# id vbird1

  uid=503(vbird1) gid=504(vbird1) groups=504(vbird1),503(vbirdgroup)

  3、給剛建的這幾個(gè)準(zhǔn)備一個(gè)用于這幾個(gè)用戶都能訪問的目錄/home/vbirdgroup

 。踨oot@linuxidc ~]# mkdir /home/vbirdgroup

 。踨oot@linuxidc ~]# chgrp vbirdgroup /home/vbirdgroup/

 。踨oot@linuxidc ~]# chmod 2770 /home/vbirdgroup/

 。踨oot@linuxidc ~]# ll -d /home/linuxidc/

  drwx---rwx. 5 linuxidc linuxidc 4096 Sep 18 14:13 /home/linuxidc/

  設(shè)置第四位,它位于三位權(quán)限序列的前面,第四位數(shù)字取值是4,2,1,代表意思如下:

  4,執(zhí)行時(shí)設(shè)置用戶ID,用于授權(quán)給基于文件屬主的進(jìn)程,而不是給創(chuàng)建此進(jìn)程的用戶。

  2,執(zhí)行時(shí)設(shè)置用戶組ID,用于授權(quán)給基于文件所在組的進(jìn)程,而不是基于創(chuàng)建此進(jìn)程的用戶。

  1,設(shè)置粘著位。

  4、現(xiàn)在 磁盤配額概要

  在/home下進(jìn)行quota,需要如下:

  文件系統(tǒng)的支持

  quota 數(shù)據(jù)文件建置

  quota 啟動(dòng)

  建立用戶 quota 信息

  5、將 /home 獨(dú)立一個(gè)分區(qū),因?yàn)?quota 僅支持 filesystem 而不支持單一目錄

  /home上增加usrquota,grpquota

  [root@localhost ~]# nl /etc/fstab

  1 #

  2 # /etc/fstab

  3 # Created by anaconda on Tue Dec 2 18:52:50 2014

  4 #

  5 # Accessible filesystems, by reference, are maintained under ‘/dev/disk’

  6 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

  7 #

  8 UUID=93cd7207-78c4-4a95-be1b-7451772c21ad / ext4 defaults 1 1

  9 UUID=9a982f8d-d590-49f2-9cf1-e07a5b8238dd /boot ext4 defaults 1 2

  10 UUID=c8939b59-9a73-45fa-bd5a-f016a5aa631e /home ext4 defaults,usrquota,grpquota 1 2

  11 UUID=1f3d9eaf-e140-47ab-ae99-fcf1516d2070 swap swap defaults 0 0

  12 tmpfs /dev/shm tmpfs defaults 0 0

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

  14 sysfs /sys sysfs defaults 0 0

  15 proc /proc proc defaults 0 0

  6、卸載、加載/home,并查看/home項(xiàng)

 。踨oot@localhost ~]# umount /home/; mount -a

  [root@localhost ~]# mount | grep home

  /dev/sda3 on /home type ext4 (rw,usrquota,grpquota)

  7、quotacheck生成配額文件,結(jié)果如下

  [root@localhost ~]# qutoacheck -avug

  -bash: qutoacheck: command not found

 。踨oot@localhost ~]#

  8、查找、安裝 quota

 。踨oot@localhost ~]# find / -name qutoacheck

  [root@localhost ~]#

 。踨oot@localhost ~]# rpm -qa | grep quota

  quota-3.17-20.el6.x86_64

  安裝

  [root@localhost ~]# yum -y install quota-3.17-20.el6.x86_64

  Loaded plugins: fastestmirror, refresh-packagekit, security

  Loading mirror speeds from cached hostfile

  * base: centos.ustc.edu.cn

  * extras: centos.ustc.edu.cn

  * updates: centos.ustc.edu.cn

  base | 3.7 kB 00:00

  base/primary_db | 4.6 MB 00:29

  extras | 3.4 kB 00:00

  extras/primary_db | 29 kB 00:00

  updates | 3.4 kB 00:00

  updates/primary_db | 910 kB 00:05

  Setting up Install Process

  Nothing to do

 。踨oot@localhost ~]#

  9、開啟限制,生成用戶和組限制文件

  [root@localhost ~]# quotacheck -avug

  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/sda3 [/home] done

  quotacheck: Cannot stat old user quota file /home/aquota.user: No such file or directory. Usage will not be substracted.

  quotacheck: Cannot stat old group quota file /home/aquota.group: No such file or directory. Usage will not be substracted.

  quotacheck: Cannot stat old user quota file /home/aquota.user: No such file or directory. Usage will not be substracted.

  quotacheck: Cannot stat old group quota file /home/aquota.group: No such file or directory. Usage will not be substracted.

  quotacheck: Checked 33 directories and 18 files

  quotacheck: Old file not found.

  quotacheck: Old file not found.

 。踨oot@localhost ~]# quotaon -avug

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

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

  10、增加配額限制

 。踨oot@localhost ~]# edquota -u vbird1

  Disk quotas for user vbird1 (uid 501):

  Filesystem blocks soft hard inodes soft hard

  /dev/sda3 32 8000 10000 8 0 0

  單位是KB

 。踨oot@localhost ~]# edquota -u vbird2

  。。。

  [root@localhost ~]# edquota -p vbird1 vbird2 vbird3 vbird4 vbird5

  11、查看配額

 。踨oot@localhost ~]# repquota -au

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

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

  Block limits File limits

  User used soft hard grace used soft hard grace

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

  root -- 24 0 0 3 0 0

  zxw -- 32 0 0 8 0 0

  vbird1 -- 32 8000 10000 8 0 0

  vbird2 -- 32 8000 10000 8 0 0

  vbird3 -- 32 8000 10000 8 0 0

  vbird4 -- 32 8000 10000 8 0 0

  vbird5 -- 32 8000 10000 8 0 0

  12、開始測(cè)試

 。踲bird1@localhost ~]$ ll -h

  total 7.6M

  -rw-rw-r--。 1 vbird1 vbird1 1.7M Dec 2 14:01 cont.txt

  -rw-r--r--。 1 root root 49K Dec 2 13:59 install.log

  -rw-rw-r--。 1 vbird1 vbird1 5.8M Dec 2 14:02 v.txt

 。踲bird1@localhost ~]$

  vb1寫文件到達(dá)到軟限制

 。踲bird1@localhost ~]$ nl cont.txt 》》 v.txt

  sda3: warning, user block quota exceeded.

  達(dá)到軟限制,警告

 。踲bird1@localhost ~]$ ll -h

  total 9.5M

  -rw-rw-r--。 1 vbird1 vbird1 1.7M Dec 2 14:01 cont.txt

  -rw-r--r--。 1 root root 49K Dec 2 13:59 install.log

  -rw-rw-r--。 1 vbird1 vbird1 7.7M Dec 2 14:02 v.txt

  vb1寫文件到達(dá)到硬限制

 。踲bird1@localhost ~]$ nl cont.txt 》》 v.txt

  sda3: write failed, user block limit reached.

  nl: write error: Disk quota exceeded

  達(dá)到硬限制,報(bào)錯(cuò)

 。踲bird1@localhost ~]$

  [vbird1@localhost ~]$ ll -h

  total 9.8M

  -rw-rw-r--。 1 vbird1 vbird1 1.7M Dec 2 14:01 cont.txt

  -rw-r--r--。 1 root root 49K Dec 2 13:59 install.log

  -rw-rw-r--。 1 vbird1 vbird1 8.1M Dec 2 14:03 v.txt

  vb1再寫就不讓寫了

 。踲bird1@localhost ~]$ nl cont.txt 》》 v.txt

  nl: write error: Disk quota exceeded

 。踲bird1@localhost ~]$ ll -h

  total 9.8M

  -rw-rw-r--。 1 vbird1 vbird1 1.7M Dec 2 14:01 cont.txt

  -rw-r--r--。 1 root root 49K Dec 2 13:59 install.log

  -rw-rw-r--。 1 vbird1 vbird1 8.1M Dec 2 14:03 v.txt

  上面就是CentOS 6修改磁盤配額限制的方法介紹了,本文主要介紹的是CentOS增加磁盤配額限制方面的修改,如果你需要減少磁盤配額限制不可使用本文方法進(jìn)行修改。

標(biāo)簽 磁盤 CentOS

發(fā)表評(píng)論

0

沒有更多評(píng)論了

評(píng)論就這些咯,讓大家也知道你的獨(dú)特見解

立即評(píng)論

以上留言僅代表用戶個(gè)人觀點(diǎn),不代表系統(tǒng)之家立場(chǎng)

其他版本軟件

熱門教程

人氣教程排行

Linux系統(tǒng)推薦

官方交流群 軟件收錄