Linux 基础 之 配额

只针对与设备不针对与用户

一)当文件的属性是xfs的时候,系统自动完成加载;

二)当文件的属性是ext4的时候,需要手动去加载:
                  1.quotacheck -u /dev/vdb1  
                  2.quotaon -u /dev/vdb1
 

注意事项:
[student@localhost ~]$ dd      if=         /dev/zero     of=         /mnt/studentfile          bs=1M                   count=10
                            (截取命令) (input file) (无限0字节设备) (outof file) (从无线0设备复制到以上文件内) (大小,这里是一块内存) (个数,这里是10个)

[root@localhost ~]# edquota -u student
        Disk quotas for user student (uid 1000):
         Filesystem                   blocks       soft       hard     inodes     soft     hard
         /dev/vdb1                     19456               20480           1         0        0
                      (用户在/dev的内存大小事实) (限额,有警告) (最大限额) (存在的文件个数) (文件个数的限额,有警告) (文件个数最大上限)
                         
[root@localhost ~]# vim /etc/fstab                           ##实现开机激动加载配额                             
       /dev/vdb1   /mnt  xfs   defaults,usrquota       0 0
                                   (开机自动读取文件)

步骤:
1.建立一个id
2.格式化
3.挂载
4.设置配额参数
5.编辑开机自动挂载
6.给/mnt 777 权限
7.切换到student用户
8.dd截取

如果在设置配额参数20480,在dd,count=21,会报错;count=19,就不会。因为21超出20M。

server操作如下:
[kiosk@foundation29 Desktop]$ ssh [email protected]
[email protected]'s password:
Last login: Fri May  4 21:32:55 2018
[root@localhost ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x02c45323.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +1000M
Partition 1 of type Linux and of size 1000 MiB is set

Command (m for help): p

Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x02c45323

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048     2050047     1024000   83  Linux

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# partprobe

[root@localhost ~]# mkfs.xfs /dev/vdb1
meta-data=/dev/vdb1              isize=256    agcount=4, agsize=64000 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=256000, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=853, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

[root@localhost ~]# mount -o usrquota /dev/vdb1 /mnt/


[root@localhost ~]# edquota -u student            

(这张图上再完成一次配额之后所截图,所以会出现事实内存大小)

[root@localhost ~]# chmod 777 /mnt/

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


[root@localhost ~]# su - student
Last login: Fri May  4 21:38:47 EDT 2018 on pts/1
[student@localhost ~]$ dd if=/dev/zero of=/mnt/studentfile bs=1M count=21
dd: error writing ‘/mnt/studentfile’: Disk quota exceeded
21+0 records in
20+0 records out

20971520 bytes (21 MB) copied, 0.0103019 s, 2.0 GB/s

当count=21的时候就会超出设定的hard=20480的最大额度,所以会出现报错。
[student@localhost ~]$ dd if=/dev/zero of=/mnt/studentfile bs=1M count=19
19+0 records in
19+0 records out
19922944 bytes (20 MB) copied, 0.0120877 s, 1.6 GB/s

当count=20/19的时候就不会。

猜你喜欢

转载自blog.csdn.net/janenancy/article/details/80226877
今日推荐