:: Re: [Dng] How to bust into a broken…
Pàgina inicial
Delete this message
Reply to this message
Autor: Peter Maloney
Data:  
A: dng
Assumpte: Re: [Dng] How to bust into a broken Qemu VM?
On 05/16/2015 01:49 PM, Brad Campbell wrote:
> On 16/05/15 15:37, Peter Maloney wrote:
>> On 05/16/2015 02:00 AM, Adam Borowski wrote:
>>> On Fri, May 15, 2015 at 07:37:57PM -0400, Steve Litt wrote:
>>>> When you accidentally bork a Qemu VM such that it won't boot to a
>>>> virtual terminal, how do you bust back in. I doubt System Rescue CD
>>>> would help, unless you can boot from the "cdrom" but somehow also
>>>> access the existing "hard disk" borked VM image.
>>> Well... you use the exact same arguments as you used for installing the
>>> system in the first place. That is, give qemu both the hard disk
>>> image and
>>> the CD. Then -boot d to boot from the first attached CD.
>>>
>> Or you can have more fun and mount it on the host...
>>
>>
>> losetup /dev/loop0 disk1.img
>
> With the caveat that only works for RAW format images though.
>
>
> Brad

You can use nmbd or some other qemu thing instead of losetup to use
qcow2 and other images though. (at the cost of performance)

Here is the nmbd method:
    modprobe nbd


    qemu-nbd -b 127.0.0.1 devuan_disk1.qcow2
        (let it chill or nohup / bg it / whatever)
    lsof -Pni | grep nbd
        figure out which port it listens on (in my case 10809)
    nbd-client localhost 10809 /dev/nbd0


    kpartx -av /dev/nbd0
    ...


This method is also useful for combining with CoW so you can have a rw
image plus a ro image that you can use together, eg. to do some
experiment that might destroy your original otherwise.
    qemu-img create -b basedisk.qcow2 -f qcow2 rwdisk.qcow2