Cuota de disco del ejercicio 16.1 de Linux

Cuota de disco del ejercicio 16.1 de Linux

Bienvenido a escanear el código QR para seguir la cuenta pública de WeChat, Ambition y Home, para obtener más contenido relacionado.

● Preparación preliminar: hay usuario1 usuario, partición / dev / sdb1 y el sistema de archivos de la partición es ext4, cree un nuevo directorio / mnt / mountpoint1

[root@localhost ~]# useradd user1
[root@localhost ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。

Device does not contain a recognized partition table
使用磁盘标识符 0xb4c67292 创建新的 DOS 磁盘标签。

命令(输入 m 获取帮助):n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
分区号 (1-4,默认 1):1
起始 扇区 (2048-41943039,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-41943039,默认为 41943039):
将使用默认值 41943039
分区 1 已设置为 Linux 类型,大小设为 20 GiB

命令(输入 m 获取帮助):
命令(输入 m 获取帮助):w				//保存重要
The partition table has been altered!

Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@localhost ~]# mkdir /mnt/mountpoint1
[root@localhost ~]# mkfs -t ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242624 blocks
262131 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2153775104
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000
Allocating group tables: 完成                            
正在写入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

● Inicie vi para editar el archivo / etc / fstab. Monte la partición / dev / sdb1 en el archivo / etc / fstab en / mnt / mountpoint1 y agregue cuotas de disco para usuarios y grupos. Reinicie el sistema.

[root@localhost ~]# vi /etc/fstab
/dev/sdb1	/mnt/mountpoint1 ext4 defaults,usrquota,grpquota 0 0
##查询是否挂载
[root@localhost aoian]# mount | grep sdb
/dev/sdb1 on /mnt/mountpoint1 type ext4 (rw,relatime,seclabel,quota,usrquota,grpquota,data=ordered)

● Utilice el comando quotacheck para crear archivos aquota.user y aquota.group.

[root@localhost aoian]# quotacheck -ug /dev/sdb1
[root@localhost aoian]# cd /mnt/mountpoint1
[root@localhost mountpoint1]# ls
aquota.group  aquota.user  lost+found

● Utilice el comando edquota -u user1 para configurar la función de cuota de disco para el usuario user1. Establezca el blando de los bloques en 5000 y el duro en 10000. Guarde y salga después de editar.

[root@localhost aoian]# edquota –u user1
Disk quotas for user user1 ( uid 1001) :
Filesystem 	 blocks 	soft 	hard 	inodes 	soft 	hard 
/dev/sdb1        0  	5000    10000      0      0		  0

● Utilice el comando quotaon para habilitar la función de cuota.

[root@localhost aoian]# quotaon -ug /mnt/mountpoint

● Verifique la cuota y el uso del disco.

[root@localhost aoian]# df -h /dev/sdb1
# -h 作用显示单位便于查看

● Intente copiar archivos cuyos tamaños excedan el límite flexible y el límite estricto de la cuota de disco en el directorio de inicio del usuario para comprobar si la función de cuota de disco funciona.

[root@RHEL7-1 ~] # chmod 777 /mnt/mountpoint1
root@RHEL7- 1 ~] # su user1
[ user1@RHEL7- 1 root]$ dd if=/dev/zero of=/mnt/mountpoint1/file1 bs=6000 count=1
sdb1: warning,user block quota exceeded.
记录了1+0的读入
记录了1+0的写出
6000000字节(6.0 MB)已复制,0. 0240897秒,249 MB/秒
[user1@RHEL7-1 root]$ dd if=/dev/zero of=/mnt/mountpoint1/file2 bs=6000 count=1
sdb1: write failed, user block limit reached.
dd: 写入"/mnt/mountpoint1/file2" 出错:超出磁盘限额
记录了1+0的读入
记录了0+0的写出
4239360字节(4.2 MB)已复制,0. 015877秒,267 MB/秒

● Intente establecer el límite flexible de 2 archivos y el límite estricto de 4 archivos usted mismo, y compruebe si la función de cuota de disco funciona.

[root@RHEL7-1 ~]# su user1
[user1@RHEL7-1 root] $ cd /mnt/ mountpoint1
[user1@RHEL7-1 mountpoint1]$ touch file1
[user1@RHEL7-1 mountpoint1] $ touch file2
[user1@RHEL7-1 mountpoint1]$ touch file3
sdb1: warning, user file quota exceeded.
[user1@RHEL7-1 mountpoint1] $ touch file4
[user1@RHEL7-1 mountpoint1] $ touch file5
sdb1: write failed,user file limit reached.
touch:无法创建"file5":超出磁盘限额

Supongo que te gusta

Origin blog.csdn.net/m0_46653702/article/details/110638345
Recomendado
Clasificación