1.为主机增加80G SCSI 接口硬盘
磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
2.划分三个各20G的主分区
[root@localhost ~]# fdisk /dev/sdd
磁盘 /dev/sdd:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xa5229b47
设备 Boot Start End Blocks Id System
/dev/sdd1 2048 41945087 20971520 83 Linux
/dev/sdd2 41945088 83888127 20971520 83 Linux
/dev/sdd3 83888128 125831167 20971520 83 Linux
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.
[root@localhost ~]# pvscan
PV /dev/sda2 VG centos lvm2 [<39.00 GiB / 4.00 MiB free]
PV /dev/sdd1 lvm2 [20.00 GiB]
PV /dev/sdd3 lvm2 [20.00 GiB]
PV /dev/sdd2 lvm2 [20.00 GiB]
Total: 4 [<99.00 GiB] / in use: 1 [<39.00 GiB] / in no VG: 3 [60.00 GiB]
4.使用两个物理卷创建卷组,名字为myvg,查看卷组大小
[root@localhost ~]# vgcreate myvg /dev/sdd[12]
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 PE 10238
Alloc PE / Size 0 / 0
Free PE / Size 10238 / 39.99 GiB
VG UUID TrFb0p-6NXe-sdI1-FJbp-ZuIx-UzKu-pDgGVp
5.创建逻辑卷mylv,大小为30G
[root@localhost ~]# lvcreate -L 30G -n mylv myvg
Logical volume "mylv" created.
6.将逻辑卷格式化成xfs文件系统,并挂载到/data目录上,创建文件测试
[root@localhost ~]# mkfs.xfs /dev/myvg/mylv
[root@localhost ~]# mkdir /data
[root@localhost ~]# mount /dev/myvg/mylv /data/
mount: /dev/mapper/myvg-mylv 已经挂载或 /data 忙
/dev/mapper/myvg-mylv 已经挂载到 /data 上
[root@localhost ~]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root xfs 37G 9.1G 28G 25% /
devtmpfs devtmpfs 897M 0 897M 0% /dev
tmpfs tmpfs 912M 0 912M 0% /dev/shm
tmpfs tmpfs 912M 9.0M 903M 1% /run
tmpfs tmpfs 912M 0 912M 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 179M 836M 18% /boot
tmpfs tmpfs 183M 12K 183M 1% /run/user/42
tmpfs tmpfs 183M 0 183M 0% /run/user/0
/dev/mapper/myvg-mylv xfs 30G 33M 30G 1% /data
7.增大逻辑卷到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 myvg/mylv successfully resized.
[root@localhost ~]# xfs_growfs /dev/myvg/mylv
[root@localhost ~]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root xfs 37G 9.1G 28G 25% /
devtmpfs devtmpfs 897M 0 897M 0% /dev
tmpfs tmpfs 912M 0 912M 0% /dev/shm
tmpfs tmpfs 912M 9.0M 903M 1% /run
tmpfs tmpfs 912M 0 912M 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 179M 836M 18% /boot
tmpfs tmpfs 183M 12K 183M 1% /run/user/42
tmpfs tmpfs 183M 0 183M 0% /run/user/0
/dev/mapper/myvg-mylv xfs 35G 33M 35G 1% /data
[root@localhost ~]# lvdisplay myvg mylv
--- Logical volume ---
LV Path /dev/myvg/mylv
LV Name mylv
VG Name myvg
LV UUID ApE11F-xwIR-sibN-cozj-Vfll-xhBc-e9s4to
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2019-08-01 20:24:50 +0800
LV Status available
# open 1
LV Size 35.00 GiB
Current LE 8960
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
Volume group "mylv" not found
Cannot process volume group mylv
8.编辑/etc/fstab文件挂载逻辑卷,并支持磁盘配额选项
[root@localhost ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sat Jul 27 13:57:15 2019
▽ Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=5b23a4cd-a55b-48cb-8ba6-564a284d1543 /boot xfs default
s 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
/dev/myvg/mylv /data xfs defaults,usrquota,grpquota 0 2
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/fstab" 12L, 514C 已写入