Saturday, September 8, 2012

Running the old OS as a VM

I use the following scritp to run the "virtual" old OS:
#!/bin/bash
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:

#!/bin/bash
modprobe nbd max_part=63
qemu-nbd -c /dev/nbd0 /media/SAMSUNG-Tera/poldon/writable-poldon-0001.qcow2 
vgscan
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:

#!/bin/bash
umount /media/poldon 
umount /media/poldon_btrfs
rmdir /media/poldon 
rmdir /media/poldon_btrfs
sync
qemu-nbd -d /dev/nbd0 
killall qemu-nbd
sleep 5
killall -9 qemu-nbd
 

No comments:

Post a Comment