1 . The host increases 80G SCSI interface hard disk
2 . Dividing each of three 20G primary partition
[root@localhost ~]# fdisk /dev/sdf
Welcome to the fdisk (util-Linux 2.23.2) .
Change will stay in memory until you decide to write the changes to disk.
Please think twice before using the write command.
Device does not contain a recognized partition table
Use disk identifier 0xdd4cecd7 create a new DOS disk label.
Command ( input m to get help ) : n-
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4 , default 1) :
Starting sector (2048-167772159 defaults to 2048) :
We will use the default value 2048
Last sector , + a sector or size + {K, M, G} (2048-167772159 , default 167 772 159) : + 20G
Partition 1 is set to Linux type, size to 20 GiB
3 . Converting the three primary partitions of the physical volume ( the pvcreate ), physical volume scanning system
[root@localhost ~]# pvcreate /dev/sdf[1,2,3]
Physical volume "/dev/sdf1" successfully created
Physical volume "/dev/sdf2" successfully created
Physical volume "/dev/sdf3" successfully created
[root@localhost ~]# pvscan
PV /dev/sdd1 VG zhu lvm2 [5.00 GiB / 0 free]
PV /dev/sdd2 VG zhu lvm2 [5.00 GiB / 0 free]
PV /dev/sdd3 VG zhu lvm2 [5.00 GiB / 1012.00 MiB free]
PV /dev/sdd4 VG zhu lvm2 [2.00 GiB / 2.00 GiB free]
PV /dev/sde1 VG cun lvm2 [5.00 GiB / 0 free]
PV /dev/sde2 VG cun lvm2 [5.00 GiB / 0 free]
PV /dev/sde3 VG cun lvm2 [5.00 GiB / 2.99 GiB free]
PV /dev/sda2 VG centos lvm2 [39.51 GiB / 44.00 MiB free]
PV /dev/sdf1 lvm2 [20.00 GiB]
PV /dev/sdf3 lvm2 [20.00 GiB]
PV /dev/sdf2 lvm2 [20.00 GiB]
Total: 11 [131.48 GiB] / in use: 8 [71.48 GiB] / in no VG: 3 [60.00 GiB]
4 . Two physical volumes to create a volume group, the name for myvg , view the volume group size
[root@localhost ~]# vgcreate myvg /dev/sdf[1,2]
Volume group "myvg" successfully created
[root@localhost ~]# vgdisplay /dev/myvg
--- Volume group ---
VG Name myvg
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 IN 10238
Alloc PE / Size 0 / 0
Free PE / Size 10238 / 39.99 GiB
VG UUID 2Hntlm-Jrmi-j3YR-mcfQ-oyBa-3RTM-Noy1ZF
5 . Create a logical volume mylv , size 30G
[root@localhost ~]# lvcreate -L 30G -n mylv myvg
Logical volume "mylv" created.
6 . The logical format to xfs file system, and mount it to / data on the directory, create a file test
[root@localhost ~]# mkfs.xfs /dev/myvg/mylv
meta-data = / dev / myvg / mylv help = 256 agcount = 4, agsize = 1966080 blks
= sectsz=512 attr=2, projid32bit=1
Crc = 0 = 0 = finobt
data = bsize=4096 blocks=7864320, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
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@localhost ~]# mkdir /data
[root@localhost ~]# mount /dev/myvg/mylv /dat
7 . Logical Volume increased to 35G
[root@localhost ~]# lvextend -L +5G /dev/myvg/mylv
Size of logical volume myvg/mylv changed from 30.00 GiB (7680 extents) to 35.00 GiB (8960 extents).
Logical volume mylv successfully resized
8. Edit / etc / fstab file to mount logical volumes, disk quotas and support options
[root@localhost ~]# vim /etc/fstab
/dev/myvg/mylv /data xfs auto,usrquota,grpquota 0 0
9 . Create a disk quota, crushlinux user / data directory under the file size of the soft limit is 80M , the hard limit for the 100M ,
crushlinux user / data directory soft limit the number of files to 80 th, a hard limit of 100 th.
[root@localhost ~]# quotacheck -avug
quotacheck: Skipping /dev/mapper/myvg-mylv [/data]
quotacheck: Cannot find filesystem to check or filesystem not mounted with quota option.
[root@localhost ~]# quotaon /data
quotaon: Enforcing group quota already on /dev/mapper/myvg-mylv
quotaon: Enforcing user quota already on /dev/mapper/myvg-mylv
[root@localhost ~]# edquota -u crushlinux
Disk quotas for user crushlinux (uid 8889):
Filesystem blocks soft hard inodes soft hard
/ Dev / folders / myvg-mylv 0 81920 102400 0 80 100
[root@localhost ~]# quota -uvs crushlinux
Disk quotas for user crushlinux (uid 8889):
Filesystem space quota limit grace files quota limit grace
/ Dev / folders / myvg-mylv
0K 81920K 100M 0 80 100
10 . Use touch dd command / data test directory
[root@localhost ~]# su crushlinux
[crushlinux@localhost root]$ touch /data/a{1..102}
touch: Unable to create "/ data / a101": out of disk quota
touch: Unable to create "/ data / a102": out of disk quota
[crushlinux@localhost data]$ dd if=/dev/zero of=/data/bigfile bs=1M count=105
dd: write "/ data / bigfile" Error : out of disk quota
Record 91 + 0 read
Record the 90 + 0 written
94371840 bytes (94 MB) have been copied, 0.0578038 seconds, 1.6 GB / sec
11 . View usage quotas: a user's perspective
[root@localhost ~]# quota -uvs crushlinux
Disk quotas for user crushlinux (uid 8889):
Filesystem space quota limit grace files quota limit grace
/ Dev / folders / myvg-mylv
0K 81920K 100M 100* 80 100 6days
12 . View usage quotas: file system perspective
[root@localhost ~]# repquota -auvs
*** Report for user quotas on device /dev/mapper/myvg-mylv
Block grace time: 7days; Inode grace time: 7days
Space limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 4K 0K 0K 3 0 0
crushlinux -+ 0K 81920K 100M 100 80 100 6days
*** Status for user quotas on device /dev/mapper/myvg-mylv
Accounting: ON; Enforcement: ON
Inode: #131 (3 blocks, 3 extents)