客户的centos虚拟机无法进入系统,但里面的数据很重要,所以新建一个centos虚拟机来挂载故障虚拟机的lvm磁盘
1.新建虚拟机后先开机进系统,然后再挂载旧磁盘
2.用fdisk -l 查看磁盘情况,能识别到旧磁盘sdb
[root@localhost ~]# fdisk -l
Disk /dev/sda: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000c5f9d
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 1048575999 523238400 8e Linux LVM
Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 8455 MB, 8455716864 bytes, 16515072 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-home: 473.6 GB, 473645973504 bytes, 925089792 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdb: 536.9 GB, 536870912000 bytes, 1048576000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000b090b
Device Boot Start End Blocks Id System
/dev/sdb1 * 2048 2099199 1048576 83 Linux
/dev/sdb2 2099200 1048575999 523238400 8e Linux LVM
3.扫出sdb上的vg卷,发现新系统的VG卷和旧磁盘的VG卷是同名的
[root@localhost ~]# vgscan
Reading volume groups from cache.
Found volume group "centos" using metadata type lvm2
Found volume group "centos" using metadata type lvm2
4.vgdisplay查看vg uuid,因为VG卷名相同,所以只能用VG UUID来更改卷名,随意更改一个vg卷名,以作区分
[root@localhost ~]# 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 0
Max PV 0
Cur PV 1
Act PV 1
VG Size <499.00 GiB
PE Size 4.00 MiB
Total PE 127743
Alloc PE / Size 127742 / 498.99 GiB
Free PE / Size 1 / 4.00 MiB
VG UUID dEgXW8-PsYd-1t6H-JNu5-sgcg-2K3l-EwXMtc
--- 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 <499.00 GiB
PE Size 4.00 MiB
Total PE 127743
Alloc PE / Size 127742 / 498.99 GiB
Free PE / Size 1 / 4.00 MiB
VG UUID YIk6Ds-MsxE-mwek-1x3S-uzdT-lxUo-VFxnGs
[root@localhost ~]# vgrename YIk6Ds-MsxE-mwek-1x3S-uzdT-lxUo-VFxnGs vg01
Processing VG centos because of matching UUID YIk6Ds-MsxE-mwek-1x3S-uzdT-lxUo-VFxnGs
Volume group "YIk6Ds-MsxE-mwek-1x3S-uzdT-lxUo-VFxnGs" successfully renamed to "vg01"
5.扫出未激活的那个lvm,并激活,可以看到我刚才改的卷是新系统的卷,所以我现在需要激活旧磁盘上的卷
[root@localhost ~]# lvscan
inactive '/dev/centos/swap' [<7.88 GiB] inherit
inactive '/dev/centos/home' [<441.12 GiB] inherit
inactive '/dev/centos/root' [50.00 GiB] inherit
ACTIVE '/dev/vg01/swap' [<7.88 GiB] inherit
ACTIVE '/dev/vg01/home' [<441.12 GiB] inherit
ACTIVE '/dev/vg01/root' [50.00 GiB] inherit
[root@localhost ~]# vgchange -ay /dev/centos
3 logical volume(s) in volume group "centos" now active
6.新建一个挂载点并挂载旧磁盘的卷,让软件方copy数据,根据网上的资料,需要挂载的是、/dev/centos/root这个目录,据说挂载home会有问题
[root@localhost ~]# mkdir /mnt/olddisk
[root@localhost ~]# mount /dev/centos/root /mnt/olddisk
标签:sectors,centos,bytes,dev,磁盘,LVM,挂载,512,size From: https://www.cnblogs.com/ippondo/p/18407774