Saturday, September 8, 2012

Running the old OS as a VM

I use the following scritp to run the "virtual" old OS:
qemu-kvm -cpu kvm64 -m 1024 -k it -usbdevice tablet virtual-poldon-0001.qcow2
The script is very raw and it was easy to make an equivalent configuration under libvirt.

Mounting the images is a little trickyer as I used LVM on the old installation, so we have to:

  1. connect a virtual block device to the qcow2 disk
  2. scan the volume groups
  3. mount them
This is done by the following script:

modprobe nbd max_part=63
qemu-nbd -c /dev/nbd0 /media/SAMSUNG-Tera/poldon/writable-poldon-0001.qcow2 
vgchange -ay
mkdir /media/poldon
mkdir /media/poldon_btrfs
mount -o rw /dev/vg_poldon/lv_root  /media/poldon
mount -o rw /dev/vg_poldon/lv_btrfs /media/poldon_btrfs
Umounting is done with this:

umount /media/poldon 
umount /media/poldon_btrfs
rmdir /media/poldon 
rmdir /media/poldon_btrfs
qemu-nbd -d /dev/nbd0 
killall qemu-nbd
sleep 5
killall -9 qemu-nbd

No comments:

Post a Comment