挂载已有数据的LVM磁盘
客户的centos虚拟机无法进入系统,但里面的数据很重要,所以新建一个centos虚拟机来挂载故障虚拟机的lvm磁盘
1.新建虚拟机后先开机进系统,用vgdisplay命令查看并记下VG UUID后再挂载旧磁盘
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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2023-09-11 VROPS报磁盘空间不足的处理