1.为主机增加80G SCSI 接口硬盘
2.划分三个各20G的主分区
3.将三个主分区转换为物理卷(pvcreate),扫描系统中的物理卷
[root@localhost ~]# pvcreate /dev/sdd[123]
Physical volume "/dev/sdd1" successfully created
Physical volume "/dev/sdd2" successfully created
Physical volume "/dev/sdd3" successfully created
Physical volume "/dev/sdd1" successfully created
Physical volume "/dev/sdd2" successfully created
Physical volume "/dev/sdd3" successfully created
[root@localhost ~]# pvscan
PV /dev/sda2 VG centos lvm2 [39.51 GiB / 44.00 MiB free]
PV /dev/sdd2 lvm2 [20.00 GiB]
PV /dev/sdd3 lvm2 [20.00 GiB]
PV /dev/sdd1 lvm2 [20.00 GiB]
PV /dev/sda2 VG centos lvm2 [39.51 GiB / 44.00 MiB free]
PV /dev/sdd2 lvm2 [20.00 GiB]
PV /dev/sdd3 lvm2 [20.00 GiB]
PV /dev/sdd1 lvm2 [20.00 GiB]
4.使用两个物理卷创建卷组,名字为myvg,查看卷组大小
[root@localhost ~]# vgcreate myvg /dev/sdd[12]
Volume group "myvg" successfully created
[root@localhost ~]# vgdisplay myvg
Volume group "myvg" successfully created
[root@localhost ~]# vgdisplay myvg
5.创建逻辑卷mylv,大小为30G
[root@localhost ~]# lvcreate -L +30G -n mylv myvg
Logical volume "mylv" created.
Logical volume "mylv" created.
6.将逻辑卷格式化成xfs文件系统,并挂载到/data目录上,创建文件测试
[root@localhost ~]# mkfs -t xfs /dev/myvg/mylv
[root@localhost ~]#mkdir /data
[root@localhost ~]# cd /data
[root@localhost data]# touch test.txt
[root@localhost ~]# echo "123" > /data/test.txt
[root@localhost ~]# mount /dev/myvg/mylv /data
[root@localhost ~]# cat /data/test.txt
123
123
7.增大逻辑卷到35G
[root@localhost ~]# pvcreate /dev/sdd3
[root@localhost ~]# vgextend myvg /dev/sdd3
[root@localhost ~]# vgdisplay myvg
[root@localhost ~]# lvextend -L +5G /dev/myvg/mylv
[root@localhost ~]# lvdisplay /dev/myvg/mylv
[root@localhost ~]# df -Th
[root@localhost ~]# xfs_growfs /dev/myvg/mylv
[root@localhost ~]# df -Th
8.编辑/etc/fstab文件挂载逻辑卷,并支持磁盘配额选项
[root@localhost ~]# vim /etc/fstab
/dev/myvg/mylv /data xfs defaults,usrquota,grpquota 0 0
9.创建磁盘配额,crushlinux用户在/data目录下文件大小软限制为80M,硬限制为100M,
crushlinux用户在/data目录下文件数量软限制为80个,硬限制为100个。
crushlinux用户在/data目录下文件数量软限制为80个,硬限制为100个。
[root@localhost ~]# mkdir /data1
[root@localhost ~]# mkfs.ext4 /dev/sdd3
[root@localhost ~]# mount /dev/sdd3 /data1
[root@localhost ~]# mount -o remount,usrquota,grpquota /data1
[root@localhost ~]# mount | grep /data1
[root@localhost ~]# vim /etc/fstab
[root@localhost ~]# vim /etc/fstab
/dev/sdd3 /data1 ext4 defaults,usrquota,grpquota 0 0
[root@localhost ~]#quotacheck -avug
[root@localhost ~]#ll /data1/a*
-rw-------. 1 root root 6144 8月 2 20:40 /data1/aquota.group
-rw-------. 1 root root 6144 8月 2 20:40 /data1/aquota.user
-rw-------. 1 root root 6144 8月 2 20:40 /data1/aquota.group
-rw-------. 1 root root 6144 8月 2 20:40 /data1/aquota.user
[root@localhost ~]# quotaon -auvg
/dev/sdd3 [/data1]: group quotas turned on
/dev/sdd3 [/data1]: user quotas turned on
/dev/sdd3 [/data1]: group quotas turned on
/dev/sdd3 [/data1]: user quotas turned on
[root@localhost ~]# useradd crushlinux
[root@localhost ~]# edquota -u crushlinux
[root@localhost ~]# edquota -u crushlinux
/dev/sdd3 0 8000 10000 0 80 100
[root@localhost ~]# chmod -R 777 /data1
[root@localhost ~]# ll /data1
10.使用touch dd 命令在/data目录下测试
[root@localhost ~]# su crushlinux
[crushlinux@localhost root]$ dd if=/dev/zero of=/data1/ceshi bs=1M count=90
sdd3: warning, user block quota exceeded.
sdd3: write failed, user block limit reached.
dd: 写入"/data1/ceshi" 出错: 超出磁盘限额
记录了10+0 的读入
记录了9+0 的写出
10240000字节(10 MB)已复制,0.0379932 秒,270 MB/秒
sdd3: warning, user block quota exceeded.
sdd3: write failed, user block limit reached.
dd: 写入"/data1/ceshi" 出错: 超出磁盘限额
记录了10+0 的读入
记录了9+0 的写出
10240000字节(10 MB)已复制,0.0379932 秒,270 MB/秒
[crushlinux@localhost root]$ touch /data1/{1..85}.txt
sdd3: warning, user file quota exceeded.
sdd3: warning, user file quota exceeded.
11.查看配额的使用情况:用户角度
[root@localhost ~]# quota -uvs crushlinux
Disk quotas for user crushlinux (uid 8893):
Filesystem space quota limit grace files quota limit grace
/dev/sdd3 10000K* 8000K 10000K 6days 86* 80 100 6days
Disk quotas for user crushlinux (uid 8893):
Filesystem space quota limit grace files quota limit grace
/dev/sdd3 10000K* 8000K 10000K 6days 86* 80 100 6days
12.查看配额的使用情况:文件系统角度
[root@localhost ~]# repquota -auvs
*** Report for user quotas on device /dev/sdd3
Block grace time: 7days; Inode grace time: 7days
Space limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 20K 0K 0K 2 0 0
crushlinux ++ 10000K 8000K 10000K 6days 86 80 100 6days
*** Report for user quotas on device /dev/sdd3
Block grace time: 7days; Inode grace time: 7days
Space limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 20K 0K 0K 2 0 0
crushlinux ++ 10000K 8000K 10000K 6days 86 80 100 6days
Statistics:
Total blocks: 7
Data blocks: 1
Entries: 2
Used average: 2.000000
Total blocks: 7
Data blocks: 1
Entries: 2
Used average: 2.000000
[crushlinux@localhost root]$ dd if=/dev/zero of=/data1/ceshi bs=1M count=90
sdd3: warning, user block quota exceeded.
sdd3: write failed, user block limit reached.
dd: 写入"/data1/ceshi" 出错: 超出磁盘限额
记录了10+0 的读入
记录了9+0 的写出
10240000字节(10 MB)已复制,0.0379932 秒,270 MB/秒