LVM卷的搭建
1.物理盘加入pv,也可以是分区加入pv
[root@localhost ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
2. 创建vg ,将加入pv的磁盘加入到vg
[root@localhost ~]# vgcreate vg0 /dev/sdb
Volume group "vg0" successfully created
3. 创建lv,
[root@localhost ~]# lvcreate -L 49G -n lv0 vg0
Logical volume "lv0" created.
4. 格式化卷
[root@localhost ~]# mkfs.xfs /dev/vg0/lv0
meta-data=/dev/vg0/lv0 isize=512 agcount=4, agsize=3211264 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=0 inobtcount=0
data = bsize=4096 blocks=12845056, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=6272, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
5. 挂载分区
查看uuid
[root@localhost ~]# blkid
/dev/sdb: UUID="ULd1WI-NMcQ-i730-6fN2-sVtn-jFx0-08sYXQ" TYPE="LVM2_member"
/dev/sr0: BLOCK_SIZE="2048" UUID="2022-03-30-08-44-34-00" LABEL="openEuler-22.03-LTS-x86_64" TYPE="iso9660" PTUUID="22bdc5ef" PTTYPE="dos"
/dev/mapper/vg0-lv0: UUID="8e7dee62-ddc5-4683-92a0-3ce6115a046d" BLOCK_SIZE="512" TYPE="xfs"
/dev/sda2: UUID="24c9fb91-060e-479b-a80b-fbf98253deda" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="8a9062cd-02"
/dev/sda1: UUID="33281a3c-56fa-4294-9619-71dd5af4c981" BLOCK_SIZE="1024" TYPE="ext4" PARTUUID="8a9062cd-01"
编辑fstab
vim /etc/fstab
UUID=24c9fb91-060e-479b-a80b-fbf98253deda / xfs defaults 0 0
UUID=33281a3c-56fa-4294-9619-71dd5af4c981 /boot ext4 defaults 1 2
UUID=8e7dee62-ddc5-4683-92a0-3ce6115a046d /t1 xfs defaults 0 0
查看挂载分区
[root@localhost ~]# mount -a
[root@localhost ~]# df -lh
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 7.6G 0 7.6G 0% /dev
tmpfs 7.6G 12K 7.6G 1% /dev/shm
tmpfs 3.1G 18M 3.1G 1% /run
tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup
/dev/sda2 200G 9.2G 191G 5% /
tmpfs 7.6G 0 7.6G 0% /tmp
/dev/sda1 459M 86M 344M 20% /boot
overlay 200G 9.2G 191G 5% /var/lib/docker/overlay2/205d8836d958808ad56ebd7d8c386c690fc3941cb0dec0d158b2912473b869d6/merged
overlay 200G 9.2G 191G 5% /var/lib/docker/overlay2/695806dc7f5f54f6759ebd9f7ec58abd3615284c838260db3e2015044a97c317/merged
/dev/mapper/vg0-lv0 49G 382M 49G 1% /t1
lvm 扩容
1. 新磁盘加pv
[root@localhost ~]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created.
2. vg添加磁盘
[root@localhost ~]# vgextend vg0 /dev/sdc
Volume group "vg0" successfully extended
3. lv扩容
[root@localhost ~]# lvextend -L +20G /dev/vg0/lv0
Size of logical volume vg0/lv0 changed from 49.00 GiB (12544 extents) to 69.00 GiB (17664 extents).
Logical volume vg0/lv0 successfully resized.
4. 文件系统拉伸
ext4 用一下命令拉伸
resize2fs/dev/vg0//lv0
xfs 使用如下命令拉伸
xfs_growfs /dev/vg0/lv0
meta-data=/dev/mapper/vg0-lv0 isize=512 agcount=4, agsize=3211264 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=0 inobtcount=0
data = bsize=4096 blocks=12845056, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=6272, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 12845056 to 18087936
[root@localhost ~]# df -lh
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 7.6G 0 7.6G 0% /dev
tmpfs 7.6G 12K 7.6G 1% /dev/shm
tmpfs 3.1G 18M 3.1G 1% /run
tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup
/dev/sda2 200G 9.2G 191G 5% /
tmpfs 7.6G 0 7.6G 0% /tmp
/dev/sda1 459M 86M 344M 20% /boot
overlay 200G 9.2G 191G 5% /var/lib/docker/overlay2/205d8836d958808ad56ebd7d8c386c690fc3941cb0dec0d158b2912473b869d6/merged
overlay 200G 9.2G 191G 5% /var/lib/docker/overlay2/695806dc7f5f54f6759ebd9f7ec58abd3615284c838260db3e2015044a97c317/merged
/dev/mapper/vg0-lv0 69G 525M 69G 1% /t1