Article directory
1.LVM
1.1 Overview of LVM
Logical Volume Manager, logical volume management
● Ability to keep existing data unchangedDynamically adjust disk capacity,therebyImprove the flexibility of disk management.
● The /boot partition is used to store boot files, cannot be created based on LVM
1.2 LVM mechanism
PV (Physical Volume, physical volume)
The physical volume is the basic storage device of the LVM mechanism, usually corresponding toA normal partition or the entire hard drive. When creating a physical volume, a reserved block will be created at the head of the partition or hard disk to record the attributes of LVM and divide the storage space intoThe default size of the elementary unit (PE) is 4MB, thus forming a physical volume.
VG (Volume Group, volume group)
Depend onOne or more physical volumes form a whole, which is called a volume group, in which physical volumes can be dynamically added or removed.
LV (Logical Volume, logical volume)
fromA piece of space separated from the volume group to form a logical volume. Use tools such as mkfs to create file systems on logical volumes.
类比理解:
The relationship between PV, VG, and LV can be vividly understood as the process of making a lion’s head—PV is the minced meat, VG is to knead all the minced meat into a pile, and LV is to dig out a part of the minced meat and knead it into a lion's head.
1.3 LVM management commands
主要命令
create physical volume:pvcreate devicename1 [devicename2...] (partition or disk)
create volume group:==vgcreate volume group namephysical volume name 1 physical volume name 2
create logical volume:lvcreate -L Capacity -n logical volume namevolume group name
Expand volume group:vgextend -L +size/dev/volume group name
Expand Logical Volume:lvextend -L+size/dev/volume group name/logical volume name
1.4 LVM Application Examples
创建并扩展逻辑卷,操作步骤如下:
(1) Turn off the host, add two new hard drives, and restart the host;
( 2) Use the fdisk tool to divide the disk devices /dev/sdb and /dev/sdc into primary partitions sdb1 and sdc1, and change the ID number of the partition type to "8e";
#(1)关闭主机,添加两块新硬盘,重启主机;
#(2)先使用fdisk工具将磁盘设备/dev/sdb、/dev/sdc划分出主分区sdb1、sdc1,并且把分区类型的ID标记号改为"8e";
[root@clr ~]# fdisk -l
磁盘 /dev/sda:64.4 GB, 64424509440 字节,125829120 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x00099d02
设备 Boot Start End Blocks Id System
/dev/sda1 * 2099200 79771647 38836224 83 Linux
/dev/sda2 117698560 125829119 4065280 5 Extended
/dev/sda5 117700608 125829119 4064256 82 Linux swap / Solaris
磁盘 /dev/sdc:21.5 GB, 21474836480 字节,41943040 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x251883e3
设备 Boot Start End Blocks Id System
/dev/sdc1 2048 41943039 20970496 8e Linux LVM
磁盘 /dev/sdb:21.5 GB, 21474836480 字节,41943040 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x437698f8
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 41943039 20970496 8e Linux LVM
磁盘 /dev/sdd:21.5 GB, 21474836480 字节,41943040 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
(3) Create a physical volume;
#(3)创建物理卷;
[root@clr ~]# pvcreate /dev/sdb1 /dev/sdc1
Physical volume "/dev/sdb1" successfully created.
Physical volume "/dev/sdc1" successfully created.
[root@clr ~]# pvscan #物理卷由分区/dev/sdc1和/dev/sdb1构成
PV /dev/sdc1 lvm2 [<20.00 GiB]
PV /dev/sdb1 lvm2 [<20.00 GiB]
Total: 2 [<40.00 GiB] / in use: 0 [0 ] / in no VG: 2 [<40.00 GiB]
[root@clr ~]# pvdisplay
"/dev/sdc1" is a new physical volume of "<20.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdc1
VG Name
PV Size <20.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID NIy9TN-UbPC-ZYI7-3jCY-cB87-vKLe-ENLLbW
"/dev/sdb1" is a new physical volume of "<20.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size <20.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID zbRmNW-EBiW-27Hw-oy7u-4cMV-ppcl-1c1coJ
(4) Create a volume group named abc;
#(4)创建卷组,卷组名为abc;
[root@clr ~]# vgcreate abc /dev/sd[bc]1 #在物理卷【/dev/sdb1 /dev/sdc1】基础上创建卷组abc
Volume group "abc" successfully created
[root@clr ~]# vgdisplay #已成功创建卷组abc
--- Volume group ---
VG Name abc
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 39.99 GiB
PE Size 4.00 MiB
Total PE 10238
Alloc PE / Size 0 / 0
Free PE / Size 10238 / 39.99 GiB
VG UUID mhQNss-7WFn-Ulle-wCXg-ys9L-l8rc-0KMKCh
(5) Create a logical volume, the logical volume name is abc01, the capacity is 30GB, and the generated file path is /dev/abc/abc01;
#(5)创建逻辑卷,逻辑卷名为abc01,容量为30GB,生成的文件路径为/dev/abc/abc01;
[root@clr ~]# lvcreate -L 30G -n abc01 abc #在卷组abc基础上创建逻辑卷abc01
Logical volume "abc01" created.
[root@clr ~]# lvdisplay
--- Logical volume ---
LV Path /dev/abc/abc01
LV Name abc01
VG Name abc
LV UUID wVbHFD-6DYh-CaCR-Mffi-DG3V-q4D0-ltOI5d
LV Write Access read/write
LV Creation host, time clr, 2023-04-04 19:36:27 +0800
LV Status available
# open 0
LV Size 30.00 GiB
Current LE 7680
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
(6) Format the logical volume, create an XFS file system, and mount it to the /data directory;
#(6)对逻辑卷进行格式化,创建XFS文件系统,并挂载到/data目录下;
[root@clr ~]# mkfs -t xfs /dev/abc/abc01 #将新创建的逻辑卷/dev/abc/abc01格式化为xfs类型
meta-data=/dev/abc/abc01 isize=512 agcount=4, agsize=1966080 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=7864320, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=3840, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@clr ~]# mkdir /data
[root@clr ~]# mount /dev/abc/abc01 /data #将xfs文件系统挂载到/data目录下
[root@clr ~]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs tmpfs 2.0G 13M 2.0G 1% /run
tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda1 xfs 38G 5.4G 32G 15% /
tmpfs tmpfs 394M 12K 394M 1% /run/user/42
tmpfs tmpfs 394M 0 394M 0% /run/user/0
/dev/mapper/abc-abc01 xfs 30G 33M 30G 1% /data #新挂载的xfs文件系统
(7) Logical volume re-expansion
#(7)逻辑卷再扩容
[root@clr ~]# lsblk #列出系统中所有可用块设备信息
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 60G 0 disk
├─sda1 8:1 0 37G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 3.9G 0 part [SWAP]
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 20G 0 part
└─abc-abc01 253:0 0 30G 0 lvm /data
sdc 8:32 0 20G 0 disk
└─sdc1 8:33 0 20G 0 part
└─abc-abc01 253:0 0 30G 0 lvm /data
sdd 8:48 0 20G 0 disk #可扩容设备(先将该硬盘设备分区,然后再扩容)
sr0 11:0 1 4.4G 0 rom
[root@clr ~]# fdisk /dev/sdd
使用磁盘标识符 0xfa54badd 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-41943039,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{
K,M,G} (2048-41943039,默认为 41943039):
将使用默认值 41943039
分区 1 已设置为 Linux 类型,大小设为 20 GiB
命令(输入 m 获取帮助):t #修改该分区的文件类型为Linux LVM
已选择分区 1
Hex 代码(输入 L 列出所有代码):8e
已将分区“Linux”的类型更改为“Linux LVM”
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@clr ~]# fdisk /dev/sdd -l
磁盘 /dev/sdd:21.5 GB, 21474836480 字节,41943040 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xfa54badd
设备 Boot Start End Blocks Id System
/dev/sdd1 2048 41943039 20970496 8e Linux LVM
[root@clr ~]# pvcreate /dev/sdd1 #为分区/dev/sdd1创建物理卷
Physical volume "/dev/sdd1" successfully created.
[root@clr ~]# vgextend abc /dev/sdd1 #将/dev/sdd1作为卷组abc的扩展卷组
Volume group "abc" successfully extended
[root@clr ~]# vgdisplay
--- Volume group ---
VG Name abc
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size <59.99 GiB
PE Size 4.00 MiB
Total PE 15357
Alloc PE / Size 7680 / 30.00 GiB
Free PE / Size 7677 / <29.99 GiB
VG UUID mhQNss-7WFn-Ulle-wCXg-ys9L-l8rc-0KMKCh
[root@clr ~]# lvextend -L +20G /dev/abc/abc01 #将逻辑卷/dev/abc/abc01再扩容20G
Size of logical volume abc/abc01 changed from 30.00 GiB (7680 extents) to 50.00 GiB (12800 extents).
Logical volume abc/abc01 successfully resized.
[root@clr ~]# lvdisplay /dev/abc/abc01 #查看指定逻辑卷/dev/abc/abc01的扩容情况
--- Logical volume ---
LV Path /dev/abc/abc01
LV Name abc01
VG Name abc
LV UUID wVbHFD-6DYh-CaCR-Mffi-DG3V-q4D0-ltOI5d
LV Write Access read/write
LV Creation host, time clr, 2023-04-04 19:36:27 +0800
LV Status available
# open 1
LV Size 50.00 GiB #逻辑卷已扩容
Current LE 12800
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
[root@clr ~]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs tmpfs 2.0G 13M 2.0G 1% /run
tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda1 xfs 38G 5.4G 32G 15% /
tmpfs tmpfs 394M 12K 394M 1% /run/user/42
tmpfs tmpfs 394M 0 394M 0% /run/user/0
/dev/mapper/abc-abc01 xfs 30G #(此处显示并未扩容成功) 33M 30G 1% /data
[root@clr ~]# xfs_growfs /dev/abc/abc01 #刷新XFS文件系统容量
meta-data=/dev/mapper/abc-abc01 isize=512 agcount=4, agsize=1966080 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=7864320, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=3840, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 7864320 to 13107200
[root@clr ~]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs tmpfs 2.0G 13M 2.0G 1% /run
tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda1 xfs 38G 5.4G 32G 15% /
tmpfs tmpfs 394M 12K 394M 1% /run/user/42
tmpfs tmpfs 394M 0 394M 0% /run/user/0
/dev/mapper/abc-abc01 xfs 50G #(再次查看已经扩容成功) 33M 50G 1% /data
[root@clr ~]# lsblk #查看系统中所有可用块设备信息
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 60G 0 disk
├─sda1 8:1 0 37G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 3.9G 0 part [SWAP]
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 20G 0 part
└─abc-abc01 253:0 0 50G 0 lvm /data
sdc 8:32 0 20G 0 disk
└─sdc1 8:33 0 20G 0 part
└─abc-abc01 253:0 0 50G 0 lvm /data
sdd 8:48 0 20G 0 disk
└─sdd1 8:49 0 20G 0 part
└─abc-abc01 253:0 0 50G 0 lvm /data #此分区作为abc-abc01逻辑卷的扩展分区
sr0 11:0 1 4.4G 0 rom
2. Disk quota
2.1 Overview of Disk Quotas
Conditions for implementing disk quotas
● needsLinux kernel support
● installxfsprogsandquotapackage
Features of Linux Disk Quotas
● Scope of action:againstspecified file system(partition)
●restricted object: user account, group account
●restriction type:Disk capacity, number of files
●limit method:soft limit, hard limit
补充:
[root@clr ~]# lsof [fuser] #These two commands can be used to check whether the process is used;
`
2.2 Disk quota management
Verify Disk Quota Capabilities
● switch toSet up partitions for quotas(mount directory)
● createspecified number of files: Use touch command, or cp command
● createspecified capacityfile: use the dd command, or the cp command
View quota usage
xfs_quota -x -c 'report option' 'mount point'
● Report common options
-a, -i, -b, -u, -g
2.3 Enable disk quota support
启用文件系统的配额支持
Add usrquota, grpquota mount parameters
2.4 Application example of disk quota
设置磁盘配额并验证是否超限,步骤如下所示:
(1) Check whether the xfsprogs and xfs_quota software packages have been delivered;
#(1)检查是否己交装xfsprogs和xfs_quota软件包;
[root@clr ~]# rpm -q xfsprogs quota #检查指定软件xfsprogs和xfs_quota是否已安装
xfsprogs-4.5.0-22.el7.x86_64
quota-4.01-19.el7.x86_64
(2) Mount the file system in a way that supports the quota function;
#(2)以支持配额功能的方式挂载文件系统;
[root@clr ~]# umount /data/ #卸载原先没有添加配额参数的挂载
[root@clr ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 13M 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda1 38G 5.4G 32G 15% /
tmpfs 394M 12K 394M 1% /run/user/42
tmpfs 394M 0 394M 0% /run/user/0
**[root@clr ~]# mount -o usrquota,grpquota /dev/abc/abc01 /data #添加挂载参数"usrquota,grpquota"用于增加对用户、组配额功能的支持
[root@clr ~]# vim /etc/fstab #永久添加挂载参数,增加对用户和组配额功能的支持(与**只使用一句即可)
[root@clr ~]# umount /data/ #卸载挂载目录
(3) Edit quota settings for user and group accounts;
#(3)编辑用户和组账号的配额设置;
[root@clr ~]# useradd zhangsan #创建用户zhangsan
[root@clr ~]# echo '123' | passwd --stdin zhangsan
更改用户 zhangsan 的密码 。
passwd:所有的身份验证令牌已经成功更新。
[root@clr ~]# xfs_quota -x -c 'limit -u bsoft=80M bhard=100M isoft=8 ihard=10 zhangsan' /data/ #设置对zhangsan用户的配额要求
[root@clr ~]# xfs_quota -c 'quota -uv zhangsan' /data/ #查看zhangsan用户的磁盘容量限制
Disk quotas for User zhangsan (1001)
Filesystem Blocks Quota Limit Warn/Time Mounted on
/dev/mapper/abc-abc01
0 81920 102400 00 [--------] /data
[root@clr ~]# xfs_quota -c 'quota -uv -i zhangsan' /data/ #查看zhangsan用户的文件数限制
Disk quotas for User zhangsan (1001)
Filesystem Files Quota Limit Warn/Time Mounted on
/dev/mapper/abc-abc01
0 8 10 00 [--------] /data
(4) Verify the disk quota function;
#(4)验证磁盘配额功能;
[root@clr ~]# mkdir data
[root@clr ~]# chmod 777 data
[root@clr ~]# ll
总用量 8
-rw-------. 1 root root 1832 3月 23 00:54 anaconda-ks.cfg
drwxrwxrwx. 2 root root 6 4月 4 22:43 data
-rw-r--r--. 1 root root 1880 3月 23 01:05 initial-setup-ks.cfg
drwxr-xr-x. 2 root root 6 3月 23 01:07 公共
drwxr-xr-x. 2 root root 6 3月 23 01:07 模板
drwxr-xr-x. 2 root root 6 3月 23 01:07 视频
drwxr-xr-x. 2 root root 6 3月 23 01:07 图片
drwxr-xr-x. 2 root root 6 3月 23 01:07 文档
drwxr-xr-x. 2 root root 6 3月 23 01:07 下载
drwxr-xr-x. 2 root root 6 3月 23 01:07 音乐
drwxr-xr-x. 2 root root 6 3月 23 01:07 桌面
[root@clr ~]# su - zhangsan
[zhangsan@clr ~]$ cd /data/
[zhangsan@clr /data]$ dd if=/dev/zero of=./test1.txt bs=10M count=9 #指定文件输入输出设备,并指定拷贝块的大小90M
记录了9+0 的读入
记录了9+0 的写出
94371840字节(94 MB)已复制,0.253119 秒,373 MB/秒
[zhangsan@clr /data]$ ll -h
总用量 90M
-rw-rw-r--. 1 zhangsan zhangsan 90M 4月 4 22:50 test1.txt
[zhangsan@clr /data]$ exit
登出
(5) Check the quota usage;
#(5)查看配额使用情况
[root@clr ~]# xfs_quota -c 'quota -uv -i zhangsan' /data/ #root用户下查看zhangsan用户对/data目录的磁盘文件数限制
Disk quotas for User zhangsan (1001)
Filesystem Files Quota Limit Warn/Time Mounted on
/dev/mapper/abc-abc01
1 8 10 00 [--------] /data
[root@clr ~]# xfs_quota -c 'quota -uv zhangsan' /data/ #root用户下查看zhangsan用户对/data目录的配额容量限制
Disk quotas for User zhangsan (1001)
Filesystem Blocks Quota Limit Warn/Time Mounted on
/dev/mapper/abc-abc01
92160 81920 102400 00 [6 days] /data
[root@clr ~]# su - zhangsan #再次切换到zhangsan用户
上一次登录:二 4月 4 22:45:37 CST 2023pts/0 上
[zhangsan@clr ~]$ cd /data
[zhangsan@clr /data]$ ls
test1.txt
[zhangsan@clr /data]$ rm -rf test1.txt #zhangsan用户删除test1.txt文件
[zhangsan@clr /data]$ dd if=/dev/zero of=./test1.txt bs=10M count=12 #指定文件输入输出设备,并指定拷贝块的大小120M
dd: 写入"./test1.txt" 出错: 超出磁盘限额
记录了11+0 的读入
记录了10+0 的写出
104857600字节(105 MB)已复制,0.0814671 秒,1.3 GB/秒
[zhangsan@clr /data]$ ll -h
总用量 100M #100M是zhangsan用户允许使用磁盘配额的硬限制容量大小
-rw-rw-r--. 1 zhangsan zhangsan 100M 4月 4 22:53 test1.txt
[zhangsan@clr /data]$ ll
总用量 102400
-rw-rw-r--. 1 zhangsan zhangsan 104857600 4月 5 11:26 test1.txt
[zhangsan@clr /data]$ rm -rf test1.txt #删除test1.txt文件
[zhangsan@clr /data]$ ll
总用量 0
[zhangsan@clr /data]$ touch file{
1..10}
[zhangsan@clr /data]$ ll
总用量 0
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file1
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file10
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file2
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file3
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file4
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file5
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file6
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file7
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file8
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file9
[zhangsan@clr /data]$ touch file11
touch: 无法创建"file11": 超出磁盘限额
[zhangsan@clr /data]$ exit
exit
[root@clr ~]# xfs_quota -x -c 'report -a' #root用户下查看所有用户的磁盘容量配额限制以及使用情况
User quota on /data (/dev/mapper/abc-abc01)
Blocks
User ID Used Soft Hard Warn/Grace
---------- --------------------------------------------------
root 0 0 0 00 [--------]
zhangsan 0 81920 102400 00 [--------]
Group quota on /data (/dev/mapper/abc-abc01)
Blocks
Group ID Used Soft Hard Warn/Grace
---------- --------------------------------------------------
root 0 0 0 00 [--------]
zhangsan 0 0 0 00 [--------]
[root@clr ~]# xfs_quota -x -c 'report -abih' #root用户下以人性化方式,查看所有用户的磁盘容量和文件数限制以及配额使用情况
User quota on /data (/dev/mapper/abc-abc01)
Blocks Inodes
User ID Used Soft Hard Warn/Grace Used Soft Hard Warn/Grace
---------- --------------------------------- ---------------------------------
root 0 0 0 00 [------] 3 0 0 00 [------]
zhangsan 0 80M 100M 00 [------] 10 8 10 00 [6 days]
Group quota on /data (/dev/mapper/abc-abc01)
Blocks Inodes
Group ID Used Soft Hard Warn/Grace Used Soft Hard Warn/Grace
---------- --------------------------------- ---------------------------------
root 0 0 0 00 [------] 3 0 0 00 [------]
zhangsan 0 0 0 00 [------] 10 0 0 00 [------]
[root@clr ~]# su zhangsan
[zhangsan@clr /root]$ cd /data/
[zhangsan@clr /data]$ echo aaaaa > file1 #将aaaaa写入file1文件
[zhangsan@clr /data]$ ll
总用量 4
-rw-rw-r--. 1 zhangsan zhangsan 6 4月 5 11:32 file1
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file10
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file2
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file3
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file4
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file5
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file6
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file7
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file8
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file9
[zhangsan@clr /data]$ dd if=/dev/zero of=./file2 bs=10M count=8 #将80M的容量从零设备写入到当前目录下的file2文件
记录了8+0 的读入
记录了8+0 的写出
83886080字节(84 MB)已复制,0.0866985 秒,968 MB/秒
[zhangsan@clr /data]$ ll -h
总用量 81M
-rw-rw-r--. 1 zhangsan zhangsan 6 4月 5 11:32 file1
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file10
-rw-rw-r--. 1 zhangsan zhangsan 80M 4月 5 11:34 file2
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file3
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file4
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file5
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file6
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file7
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file8
-rw-rw-r--. 1 zhangsan zhangsan 0 4月 5 11:28 file9
[zhangsan@clr /data]$ exit
exit
[root@clr ~]# xfs_quota -x -c 'report -abih' #root用户下以人性化方式,查看所有用户的磁盘容量和文件数限制以及配额使用情况
User quota on /data (/dev/mapper/abc-abc01)
Blocks Inodes
User ID Used Soft Hard Warn/Grace Used Soft Hard Warn/Grace
---------- --------------------------------- ---------------------------------
root 0 0 0 00 [------] 3 0 0 00 [------]
zhangsan 80.0M (zhangsan用户新写入file2文件的容量大小) 80M 100M 00 [7 days] 10 8 10 00 [6 days]
Group quota on /data (/dev/mapper/abc-abc01)
Blocks Inodes
Group ID Used Soft Hard Warn/Grace Used Soft Hard Warn/Grace
---------- --------------------------------- ---------------------------------
root 0 0 0 00 [------] 3 0 0 00 [------]
zhangsan 80.0M 0 0 00 [------] 10 0 0 00 [------]