如何修復損壞的 VirtualBox 虛擬機器?

如何修復損壞的 VirtualBox 虛擬機器?

我在 Ubuntu 11.10 64 位元主機上執行 Oracle VirtualBox,並配備 Ubuntu Server 12.04 LTS 64 位元客戶機,並附有許多快照。主機重新啟動後(虛擬機器正在運行時),虛擬機器變得「無法存取」。在摸索並製作了許多千兆位元組的備份後,我讓它啟動到找不到啟動媒體螢幕。對於如何將我的資料(包括最新快照中的資料)轉移到新虛擬機器上,或者如果可能的話,修復此問題,您有什麼建議或解決方​​案嗎?我很樂意提供更多資訊。

編輯:我認為我的快照鏈已損壞/損壞。

編輯2:我無法修復它,我剛剛創建了一個新的虛擬機器。

答案1

Baring 能夠返回工作快照。將您的虛擬機器啟動到 Live CD 並查看是否可以存取其硬碟。如果是這樣,最壞的情況是使用新伺服器建立新虛擬機,添加舊虛擬機中的硬碟;然後從硬碟中檢索資料。

答案2

  1. 恢復最新快照
  2. 編輯硬碟資訊並刪除所有無法存取的硬碟
  3. 將您可以找到的所有硬碟新增至虛擬機器(這使得它們可以存取)
  4. 使用恢復 CD 或 Live CD 啟動
  5. 決定如何修復它...通常您需要掛載磁碟、chroot 並安裝 grub

#5 的範例:

  1. 掛載分割區

    mkdir /mnt/fixme
    parted -s /dev/sda print
    (based on output of above, decide which device is your /boot, /, etc., and modify next mount commands accordingly)
    mount /dev/sda2 /mnt/fixme
    mount /dev/sda1 /mnt/fixme/boot
    ... for all your partitions
    
  2. 掛載特殊檔案系統

    mount | grep "on /proc"
    mount | grep "on /dev"
    (based on the above, decide what the "from" and "type" should be; my example below is correct for openSUSE 12.1)
    mount -t proc proc /mnt/fixme/proc
    mount -t devtmpfs devtmpfs /mnt/fixme/dev
    

    例如,在 Ubuntu 上,dev 類型為「none」: mount -t none devtmpfs /mnt/fixme/dev

    您可能還需要安裝 /sys。我忘了。當您收到錯誤訊息時您就會知道。

  3. 啟動 chroot shell(就像啟動到您的硬碟)(附註:如果系統上有另一個磁碟,則此操作會很糟糕,例如您將損壞的磁碟插入到另一個未從其啟動的 Linux 中) CD ,但來自磁碟;它會在mtab 中查找以確定哪個是您的啟動盤,並將這些guid 放入grub 配置中而不是修復的磁碟中,因此您需要使用啟動提示符進行恢復並再次運行grub- install之後)

    chroot /mnt/fixme
    
  4. 安裝grub

    On openSUSE:
        update-bootloader
    On Ubuntu:
        update-grub2
    Alternate, on most systems, but not openSUSE, use both:
        install stage 1 bootloader:
            grub-install
        install guids and stuff in /boot (change cfg file to whatever you find is the correct one [menu.lst on openSUSE, grub.cfg on Ubuntu, etc.]) (if you skip the -o option, it just prints to standard out and doesn't save it in any files)
            find /boot -name "*grub*" -or -name "*.cfg" -or -name "*menu*"
            grub-mkconfig -o /boot/grub/grub.cfg
    

相關內容