虛擬機img出錯無法啓動?mount it in host OS and do the recovery.

For the project I am doing now, I need to run all the test in the virtual machine (Qemu). After a few month of work, I think that it's a time to do the test in a totally new img (kernel) and verify our guessing before. So I created a new img file and install the Ubuntu 10.04 (32bit) on it. 

Then the problem came. After compiling a new kernel (with defconfig) and installing it to the system, the kernel went into panic once reboot. What's worse, I could not even go to the part when I can choose which kernel to use. :(


The suggestion I got from others is to mount the img file in the host OS and modify the /boot/grub/grub.cfg file to change the default kernel. Here is how to mount the img file:

  1. mkdir ~/img # the folder that stores the fs

  2. fdisk -u -l ***.img # get the info for the img

  3. sudo mount -o loop, offset=1048576 ***.img ~/img # the offset is the start address of the linux fs in the img, we can get this offset from the result of previous step.

  4. Now, we can check all the files in the img 

  5. sudo umount ~/img

Done!!!


Reference:

http://my.oschina.net/toyandong/blog/65002

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章