这里介绍一下LVM的磁盘命令
查看唯一标识UUID情况(特别注意在数据恢复时需要注意 uuid不能重复) 很多机房管理员创建机器时 使用统一备份镜像恢复, 导致全部机器的PV VG LV uuid都是相同的; 当一台机器系统有问题, 取下硬盘到其他机器恢复数据时, 会导致VG LV交叉错乱的问题; 遇到这样问题时, 重新使用一个原始系统做系统, 检查uuid;
blkid检查文件系统 PV VG LV 的uuid
[root@localhost mysql]# blkid
/dev/vda1: UUID="1f7e5221-e081-4359-aff6-8516106d02f5" TYPE="xfs"
/dev/vda2: UUID="GkxwPy-lQh7-69Mg-brUL-x8X8-hGM3-NGZBTd" TYPE="LVM2_member"
/dev/mapper/centos-root: UUID="1180d697-6f79-4e40-bc45-e1cb4553479a" TYPE="xfs"
/dev/mapper/centos-swap: UUID="d37f59d4-e312-4912-888a-6a4175cc6b13" TYPE="swap"
/dev/mapper/centos-home: UUID="9782bc5f-4ded-4b27-bf2a-a2e805a476cf" TYPE="xfs"
/dev/vdb1: UUID="7ab51d98-da4b-4eaa-8fd6-7d6bd6d548ee" TYPE="ext4"
/dev/vdb2: UUID="N0WKWq-0ZtQ-LpJx-g3ex-dlSb-y2iO-9e4WvG" TYPE="LVM2_member"
/dev/mapper/VolGroup-lv_root: UUID="6235f1df-430f-408a-9d1b-8846928a4615" TYPE="ext4"
/dev/mapper/VolGroup-lv_home: UUID="88340f4d-1eac-4e5b-83af-2e35e026bf8a" TYPE="ext4"
/dev/mapper/VolGroup-lv_swap: UUID="db3e8e10-a82f-465e-b760-e39efba9a00c" TYPE="swap"
查看逻辑卷挂载情况 lsblk
[root@localhost mysql]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sr0 11:0 1 1024M 0 rom
vda 252:0 0 80G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 79G 0 part
├─centos-root 253:0 0 50G 0 lvm /
├─centos-swap 253:1 0 3.9G 0 lvm [SWAP]
└─centos-home 253:2 0 25.1G 0 lvm /home
vdb 252:16 0 500G 0 disk
├─vdb1 252:17 0 500M 0 part
└─vdb2 252:18 0 499.5G 0 part
├─VolGroup-lv_root 253:3 0 50G 0 lvm /usr/local/vdb2-root
├─VolGroup-lv_home 253:4 0 441.8G 0 lvm
└─VolGroup-lv_swap 253:5 0 7.8G 0 lvm
查看物理卷PV情况
[root@localhost mysql]# pvs
PV VG Fmt Attr PSize PFree
/dev/vda2 centos lvm2 a-- <79.00g 4.00m
/dev/vdb2 VolGroup lvm2 a-- <499.51g 0
[root@localhost mysql]# pvdisplay
--- Physical volume ---
PV Name /dev/vda2
VG Name centos
PV Size <79.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 20223
Free PE 1
Allocated PE 20222
PV UUID GkxwPy-lQh7-69Mg-brUL-x8X8-hGM3-NGZBTd
--- Physical volume ---
PV Name /dev/vdb2
VG Name VolGroup
PV Size 499.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 127874
Free PE 0
Allocated PE 127874
PV UUID N0WKWq-0ZtQ-LpJx-g3ex-dlSb-y2iO-9e4WvG
查看卷组VG情况
[root@localhost mysql]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup 1 3 0 wz--n- <499.51g 0
centos 1 3 0 wz--n- <79.00g 4.00m
[root@localhost mysql]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size <79.00 GiB
PE Size 4.00 MiB
Total PE 20223
Alloc PE / Size 20222 / 78.99 GiB
Free PE / Size 1 / 4.00 MiB
VG UUID NmSenq-M4L9-H61O-zFGz-xVD0-dUxx-Q7OFEK
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size <499.51 GiB
PE Size 4.00 MiB
Total PE 127874
Alloc PE / Size 127874 / <499.51 GiB
Free PE / Size 0 / 0
VG UUID XjrCxW-HLgD-fr8s-Y2QK-RZVz-Uun6-1PR0tC
查看逻辑卷LV情况
[root@localhost mysql]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_home VolGroup -wi-a----- <441.76g
lv_root VolGroup -wi-ao---- 50.00g
lv_swap VolGroup -wi-a----- 7.75g
home centos -wi-ao---- <25.12g
root centos -wi-ao---- 50.00g
swap centos -wi-ao---- <3.88g
[root@localhost mysql]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID axx6Dv-pEoD-I9je-Z8Zy-grd8-uUSX-rrAE7e
LV Write Access read/write
LV Creation host, time localhost, 2021-02-23 12:38:35 +0800
LV Status available
# open 2
LV Size <3.88 GiB
Current LE 992
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
剩余的就不展示了
LV挂载 mount PV PATH
[root@centos7 ~]# mount /dev/mapper/newcentos-root /mnt
LV挂载卸载 umount PV PATH
[root@centos7 ~]#umount /dev/mapper/newcentos-root /
查看逻辑卷挂载情况 lsblk
[root@localhost mysql]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sr0 11:0 1 1024M 0 rom
vda 252:0 0 80G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 79G 0 part
├─centos-root 253:0 0 50G 0 lvm /
├─centos-swap 253:1 0 3.9G 0 lvm [SWAP]
└─centos-home 253:2 0 25.1G 0 lvm /home
vdb 252:16 0 500G 0 disk
├─vdb1 252:17 0 500M 0 part
└─vdb2 252:18 0 499.5G 0 part
├─VolGroup-lv_root 253:3 0 50G 0 lvm /usr/local/vdb2-root
├─VolGroup-lv_home 253:4 0 441.8G 0 lvm
└─VolGroup-lv_swap 253:5 0 7.8G 0 lvm
|