卷组(Volume Group)简称VG,它是一个或者多个物理卷的组合。卷组将多个物理卷组合在一起,形成一个可管理的单元,它类似于非LVM系统中的物理硬盘。
具体原因是:公司业务其中一台centos服务器的操作系统启动不了,需要恢复其中的数据,将硬盘挂载到能正常启动的服务器上面,但是出现VG重名的问题,挂载不了的情况,具体解决思路如下
1.使用pvs/lvs/vgs查看具体的LVM情况
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 centos lvm2 a-- 556.66g 4.00m
/dev/sdc1 centos lvm2 a-- 279.39g 0
/dev/sdd2 centos lvm2 a-- 278.39g 4.00m
[root@localhost ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home centos -wi-a----- 491.09g
home centos -wi------- 495.97g
root centos -wi-ao---- 50.00g
root centos -wi------- 50.00g
swap centos -wi-ao---- 15.56g
swap centos -wi------- 11.81g
[root@localhost ~]# vgs -v
Cache: Duplicate VG name centos: Prefer existing gEVmfo-SGj8-B3Ij-9O3U-jd3a-TftX-OMVfY6 vs new WTOf0a-fVj9-lNK2-AJOU-Q4nA-xuVk-H9AYi4
Cache: Duplicate VG name centos: Prefer existing gEVmfo-SGj8-B3Ij-9O3U-jd3a-TftX-OMVfY6 vs new WTOf0a-fVj9-lNK2-AJOU-Q4nA-xuVk-H9AYi4
Cache: Duplicate VG name centos: Prefer existing WTOf0a-fVj9-lNK2-AJOU-Q4nA-xuVk-H9AYi4 vs new gEVmfo-SGj8-B3Ij-9O3U-jd3a-TftX-OMVfY6
Archiving volume group "centos" metadata (seqno 4).
Archiving volume group "centos" metadata (seqno 4).
Creating volume group backup "/etc/lvm/backup/centos" (seqno 4).
VG Attr Ext #PV #LV #SN VSize VFree VG UUID VProfile
centos wz--n- 4.00m 1 3 0 556.66g 4.00m WTOf0a-fVj9-lNK2-AJOU-Q4nA-xuVk-H9AYi4
centos wz--n- 4.00m 2 3 0 <557.79g 4.00m gEVmfo-SGj8-B3Ij-9O3U-jd3a-TftX-OMVfY6
以上发现现有系统的LVM和挂载的硬盘(故障系统)的LVM的VG名称重复,有多个root、home的LV
2.通过vg的uuid改名
如果通过VG名称进行变更,会提示报错,需要通过UUID进行改名,其中uuid是通过上面的vgs -v查看
[root@localhost ~]# vgrename gEVmfo-SGj8-B3Ij-9O3U-jd3a-TftX-OMVfY6 centos01
Processing VG centos because of matching UUID gEVmfo-SGj8-B3Ij-9O3U-jd3a-TftX-OMVfY6
Volume group "gEVmfo-SGj8-B3Ij-9O3U-jd3a-TftX-OMVfY6" successfully renamed to "centos01"
3.查看lv状态,发现有几个是inactive
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 3 0 wz--n- 556.66g 4.00m
centos01 2 3 0 wz--n- <557.79g 4.00m
[root@localhost ~]# lvscan
ACTIVE '/dev/centos/swap' [15.56 GiB] inherit
ACTIVE '/dev/centos/home' [491.09 GiB] inherit
ACTIVE '/dev/centos/root' [50.00 GiB] inherit
inactive '/dev/centos01/swap' [11.81 GiB] inherit
inactive '/dev/centos01/home' [495.97 GiB] inherit
inactive '/dev/centos01/root' [50.00 GiB] inherit
4.修改vg的属性
[root@localhost ~]# vgchange -ay /dev/centos01
3 logical volume(s) in volume group "centos01" now active
[root@localhost ~]# lvscan
ACTIVE '/dev/centos/swap' [15.56 GiB] inherit
ACTIVE '/dev/centos/home' [491.09 GiB] inherit
ACTIVE '/dev/centos/root' [50.00 GiB] inherit
ACTIVE '/dev/centos01/swap' [11.81 GiB] inherit
ACTIVE '/dev/centos01/home' [495.97 GiB] inherit
ACTIVE '/dev/centos01/root' [50.00 GiB] inherit
5.挂载目录
[root@localhost ~]# cd /
[root@localhost /]# mkdir centos01-root
[root@localhost /]# mkdir centos01-home
[root@localhost /]# mount /dev/centos01/root /centos01-root/
[root@localhost /]# mount /dev/centos01/home /centos01-home/
[root@localhost /]# cd centos01-root
[root@localhost centos01-root]# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin sk srv sys tmp usr var
通过以上操作,即可恢复文件。