[root@wanghaihan ~]# echo "13:/mnt/xfs" > /etc/projects
[root@wanghaihan ~]# echo "xfsquota:13" > /etc/projid
[root@wanghaihan ~]# cat /etc/projects
13:/mnt/xfs
[root@wanghaihan ~]# cat /etc/projid
xfsquota:13
[root@wanghaihan ~]# xfs_quota -x -c "limit -p bsoft=280M bhard=300M xfsquota" /mnt/xfs/
[root@wanghaihan ~]# xfs_quota -x -c "report -pbih" /mnt/xfs/
Project quota on /mnt/xfs (/dev/nvme0n1p1)
Blocks Inodes
Project ID Used Soft Hard Warn/Grace Used Soft Hard Warn/Grace
---------- --------------------------------- ---------------------------------
#0 0 0 0 00 [------] 2 0 0 00 [------]
xfsquota 0 280M 300M 00 [------] 1 0 0 00 [------]
[root@wanghaihan ~]# cd /mnt/xfs/
[root@wanghaihan xfs]# dd if=/dev/zero of=root1 bs=1M count=200 ---创建文件验证
200+0 records in
200+0 records out
209715200 bytes (210 MB) copied, 0.209259 s, 1.0 GB/s
[root@wanghaihan xfs]# dd if=/dev/zero of=root2 bs=1M count=200
dd: error writing ‘root2’: No space left on device
101+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 0.172867 s, 607 MB/s
[root@wanghaihan xfs]# xfs_quota -x -c "report -pbih" /mnt/xfs/ ---超过软配额后出现天数警告,超出后软配额以外的文件删除
Project quota on /mnt/xfs (/dev/nvme0n1p1)
Blocks Inodes
Project ID Used Soft Hard Warn/Grace Used Soft Hard Warn/Grace
---------- --------------------------------- ---------------------------------
#0 0 0 0 00 [------] 2 0 0 00 [------]
xfsquota 300M 280M 300M 00 [7 days] 3 0 0 00 [------]
[root@wanghaihan xfs]# xfs_quota -x -c "disable -up" /mnt/xfs/ ---关闭配额限制
[root@wanghaihan xfs]# dd if=/dev/zero of=root3 bs=1M count=200
dd: error writing ‘root3’: No space left on device
72+0 records in
71+0 records out
74448896 bytes (74 MB) copied, 0.10888 s, 684 MB/s
[root@wanghaihan xfs]# ls -lh
total 471M
-rw-r--r--. 1 root root 200M Apr 13 11:35 root1
-rw-r--r--. 1 root root 200M Apr 13 11:41 root2
-rw-r--r--. 1 root root 71M Apr 13 11:41 root3
[root@wanghaihan xfs]# xfs_quota -x -c "report -pbih" /mnt/xfs/ ---查看后发现配额被关闭
Project quota on /mnt/xfs (/dev/nvme0n1p1)
Blocks Inodes
Project ID Used Soft Hard Warn/Grace Used Soft Hard Warn/Grace
---------- --------------------------------- ---------------------------------
#0 0 0 0 00 [------] 2 0 0 00 [------]
xfsquota 471M 280M 300M 00 [-none-] 4 0 0 00 [------]
[root@wanghaihan xfs]# xfs_quota -x -c "state" /mnt/xfs/ ---查看详细信息
User quota state on /mnt/xfs (/dev/nvme0n1p1)
Accounting: ON
Enforcement: OFF
Inode: #67 (1 blocks, 1 extents)
Group quota state on /mnt/xfs (/dev/nvme0n1p1)
Accounting: OFF
Enforcement: OFF
Inode: #68 (1 blocks, 1 extents)
Project quota state on /mnt/xfs (/dev/nvme0n1p1)
Accounting: ON
Enforcement: OFF
Inode: #68 (1 blocks, 1 extents)
Blocks grace time: [7 days]
Inodes grace time: [7 days]
Realtime Blocks grace time: [7 days]
[root@wanghaihan xfs]#
[root@wanghaihan ~]# umount /mnt/xfs ---关闭文件系统
[root@wanghaihan ~]# mount -a ---重启文件系统
[root@wanghaihan ~]# xfs_quota -x -c "report -pbih" /mnt/xfs/
Project quota on /mnt/xfs (/dev/nvme0n1p1)
Blocks Inodes
Project ID Used Soft Hard Warn/Grace Used Soft Hard Warn/Grace
---------- --------------------------------- ---------------------------------
#0 0 0 0 00 [------] 2 0 0 00 [------]
xfsquota 400M 280M 300M 00 [-none-] 3 0 0 00 [------]
[root@wanghaihan ~]# xfs_quota -x -c "enable -up" /mnt/xfs/ ---重新打开磁盘配额
XFS_QUOTAON: File exists
[root@wanghaihan ~]# rm -rf /mnt/xfs/root2
[root@wanghaihan ~]# xfs_quota -x -c "report -pbih" /mnt/xfs/
Project quota on /mnt/xfs (/dev/nvme0n1p1)
Blocks Inodes
Project ID Used Soft Hard Warn/Grace Used Soft Hard Warn/Grace
---------- --------------------------------- ---------------------------------
#0 0 0 0 00 [------] 2 0 0 00 [------]
xfsquota 200M 280M 300M 00 [------] 2 0 0 00 [------]
[root@wanghaihan ~]# dd if=/dev/zero of=root2 bs=1M count=200
200+0 records in
200+0 records out
209715200 bytes (210 MB) copied, 0.143534 s, 1.5 GB/s
[root@wanghaihan ~]# xfs_quota -x -c "report -pbih" /mnt/xfs/
Project quota on /mnt/xfs (/dev/nvme0n1p1)
Blocks Inodes
Project ID Used Soft Hard Warn/Grace Used Soft Hard Warn/Grace
---------- --------------------------------- ---------------------------------
#0 0 0 0 00 [------] 2 0 0 00 [------]
xfsquota 200M 280M 300M 00 [------] 2 0 0 00 [------]
[root@wanghaihan ~]# dd if=/dev/zero of=root3 bs=1M count=200
200+0 records in
200+0 records out
209715200 bytes (210 MB) copied, 0.136811 s, 1.5 GB/s
[root@wanghaihan ~]# xfs_quota -x -c "report -pbih" /mnt/xfs/
Project quota on /mnt/xfs (/dev/nvme0n1p1)
Blocks Inodes
Project ID Used Soft Hard Warn/Grace Used Soft Hard Warn/Grace
---------- --------------------------------- ---------------------------------
#0 0 0 0 00 [------] 2 0 0 00 [------]
xfsquota 200M 280M 300M 00 [------] 2 0 0 00 [------]
6、永久删除配额限制
661 xfs_quota -x -c "off -up" /mnt/xfs/ ---开启关闭配额功能
662 xfs_quota -x -c "remove -p" /mnt/xfs/ ---移除配额配置
[root@wanghaihan ~]# xfs_quota -x -c "state" /mnt/xfs/ --查询配额信息查询不到
[root@wanghaihan ~]# xfs_quota -x -c "report -pbih" /mnt/xfs/
[root@wanghaihan ~]# umount /mnt/xfs
[root@wanghaihan ~]# vim /etc/fstab ---关闭文件系统后,将配置文件的配额选项删除
[root@wanghaihan ~]# mount -a
[root@wanghaihan ~]# mount | grep nvme0n1p1 ---配额相关词条已经消失
/dev/nvme0n1p1 on /mnt/xfs type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
二、创建逻辑卷
1、查看分区信息
[root@wanghaihan ~]# df -Th | grep -v tmp
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/rhel-root xfs 27G 15G 13G 55% /
/dev/sr0 iso9660 4.3G 4.3G 0 100% /mnt/cdrom
/dev/sda1 xfs 1014M 239M 776M 24% /boot
/dev/nvme0n1p1 xfs 497M 226M 272M 46% /mnt/xfs
[root@wanghaihan ~]# swapon -s
Filename Type Size Used Priority
/dev/dm-1 partition 2097148 0 -2
[root@wanghaihan ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 30G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 29G 0 part
├─rhel-root 253:0 0 27G 0 lvm / ---系统自动生成的逻辑分区
└─rhel-swap 253:1 0 2G 0 lvm [SWAP] ---系统自动生成的逻辑分区
sr0 11:0 1 4.2G 0 rom /mnt/cdrom
nvme0n1 259:0 0 5G 0 disk
└─nvme0n1p1 259:1 0 500M 0 part /mnt/xfs
2、创建逻辑分区
[root@wanghaihan ~]# fdisk /dev/nvme0n1
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.
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): e ---将剩余的空间全部创建成扩展分区
Partition number (2-4, default 2): 3
First sector (1026048-10485759, default 1026048):
Using default value 1026048
Last sector, +sectors or +size{K,M,G} (1026048-10485759, default 10485759):
Using default value 10485759
Partition 3 of type Extended and of size 4.5 GiB is set
Command (m for help): p
Disk /dev/nvme0n1: 5368 MB, 5368709120 bytes, 10485760 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: 0x7135cfb9
Device Boot Start End Blocks Id System
/dev/nvme0n1p1 2048 1026047 512000 83 Linux
/dev/nvme0n1p3 1026048 10485759 4729856 5 Extended
Command (m for help): n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l ---创建逻辑分区
Adding logical partition 5
First sector (1028096-10485759, default 1028096):
Using default value 1028096
Last sector, +sectors or +size{K,M,G} (1028096-10485759, default 10485759): +800M
Partition 5 of type Linux and of size 800 MiB is set
Command (m for help): p
Disk /dev/nvme0n1: 5368 MB, 5368709120 bytes, 10485760 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: 0x7135cfb9
Device Boot Start End Blocks Id System
/dev/nvme0n1p1 2048 1026047 512000 83 Linux
/dev/nvme0n1p3 1026048 10485759 4729856 5 Extended
/dev/nvme0n1p5 1028096 2666495 819200 83 Linux
Command (m for help): t
Partition number (1,3,5, default 5):
Hex code (type L to list all codes): 8e ---装换成8e逻辑卷,83类型会崩溃
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p
Disk /dev/nvme0n1: 5368 MB, 5368709120 bytes, 10485760 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: 0x7135cfb9
Device Boot Start End Blocks Id System
/dev/nvme0n1p1 2048 1026047 512000 83 Linux
/dev/nvme0n1p3 1026048 10485759 4729856 5 Extended
/dev/nvme0n1p5 1028096 2666495 819200 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@wanghaihan ~]# partprobe /dev/nvme0n1 ---更新分区信息
[root@wanghaihan ~]# cat /proc/partitions
major minor #blocks name
8 0 31457280 sda
8 1 1048576 sda1
8 2 30407680 sda2
11 0 4444160 sr0
253 0 28303360 dm-0
253 1 2097152 dm-1
259 0 5242880 nvme0n1
259 1 512000 nvme0n1p1
259 2 0 nvme0n1p3
259 3 819200 nvme0n1p5 ---分区创建成功
[root@wanghaihan ~]# fdisk /dev/nvme0n1 ---创建新的逻辑分区
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.
Command (m for help): n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 6
First sector (2668544-10485759, default 2668544):
Using default value 2668544
Last sector, +sectors or +size{K,M,G} (2668544-10485759, default 10485759): +800M
Partition 6 of type Linux and of size 800 MiB is set
Command (m for help): t
Partition number (1,3,5,6, default 6): 6
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.