在我的虚拟机崩溃之后

来源:互联网 发布:光环助手同类软件 编辑:程序博客网 时间:2024/04/29 21:51

         因为开发过程中的一个不小心(其实就是makefile写错了,奶奶的),系统整体崩溃了。这个所谓的崩溃,怎么说呢?其实就是整个linux centos的虚拟机进不去,启动不了。最后查出来,整个分区表都被删了,而且连/bin/sh下面的工具都没了。What the fucking day!还好是在周末!于是从昨天下午开始,就开启了我不眠不休的修复过程。

        1、挂载硬盘到其他虚拟机。失败。因为读不出来分区表,挂上去的硬盘也是瞎的。

        2、使用光盘iso文件,本来想进入救援模式重新引导硬盘,最后遇到“you don't have any linux partitions press return to get a shell the system will reboot automatically when you exit from the shell”。然后进入shell。操作命令,执行chroot /mnt/sysimage/ ,报错chroot:cannot run command '/bin/sh' no such file ro directory。然后网上有人说执行:e2label /dev/sda1 。报错e2label :Bad magic number in super-block while trying to open /dev/sda2 Couldn't find valid filesystem superblock. 又妥妥的死胡同了。

ps:如何进入救援模式请参考如下链接:http://www.osyunwei.com/archives/5764.html

        3、实在没辙,只能使用livecd 直接进入linux系统,挂载原始虚拟硬盘。

               进入系统以后,发现采用fdisk -l是可以看到出错的硬盘的。只是mount不可以,会提示“mount:unknown filesystem type 'LVM2_member'”.

               解决办法:

               需要安装 lvm2:  yum install lvm2

               然后按一下步骤:

              (1)、查看物理卷:pvs

                 PV       VG       Fmt   Attr PSize PFree
                 /dev/sda2   VolGroup00 lvm2 a- 279.22G 32.00M


              (2)、查看卷组:vgs

                  VG       #PV #LV #SN Attr VSize VFree
                 VolGroup00 1 4 0 wz--n- 279.22G 32.00M

               (3)、查看逻辑卷:lvdisplay

                 --- Logical volume ---
                 LV Name             /dev/VolGroup00/LogVol03
                 VG Name             VolGroup00
                 LV UUID             YhG8Fu-ZGPk-qt8D-AxgC-DzOU-dg1F-z71feI
                 LV Write Access        read/write
                 LV Status              unenable
                 # open                 1
                 LV Size             245.97 GB
                 Current LE          7871
                 Segments             1
                 Allocation          inherit
                 Read ahead sectors     auto
                 - currently set to     256
                 Block device           253:2

               (4)、如未激活,需要激活逻辑卷:vgchange -ay /dev/VolGroup00

                  LV Status              available

              (5)、挂载逻辑卷:mount   /dev/VolGroup00/LogVol03   /home/lvm

        至此,在/home/lvm下面已经可以看到原来虚拟机中的数据。现在需要的就是拷贝恢复数据!但是虚拟机是废了!不过至少数据还有!


        

0 0
原创粉丝点击