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
 

Keeping your old installation files at hand

So long Fedora, welcome Mint. I Managed to dump my entire hard drive to a file with dd so I can start my "old" installation in a kvm virtual machine: I also made a qcow2 delta disk of the base image that I can mount with nbd so I can browse my files easily.

The dump was done with dd directly to a file on a USB Hard drive, it took several hours, but the procedure is as simple as this:
dd if=/dev/hda of=/media/SAMSUNG-tera bs=1048576
I always specify the block-size in dd since the default is too low and has much overhead.

 This "dump" is, qemu-wise, a virtual disk image of tipe "raw", and as such is usable to run a VM. But I don't want this image to change since I still want to be able to restore it if I change my mind about the reinstallation, so I set it to read-only and I created two delta-disks over the raw file that I can access r/w to power the vm on and to browse the files with qemu-img:

qemu-img create -f qcow2 -o backing_file=poldon-180812-base.img,backing_fmt=raw writable-poldon-0001.qcow2
I run the VM from the qcow2's so I can keep the dump as it was at the beginning and eventually dump it back to my HD, while I can make all the modifications I want to the qcows to adapt the OS to the virtual hardware.
 
After testing Fedora 17 in some virtual machines I finally decided to wipe Fedora and go to linux mint... I still prefer RPM based distro over dpkg, but I just couldn't cope anymore with the amount of beta and alpha stuff that gets in Fedora. I need some reliability to keep working with linux! Fedora has kernel 3.4, grub 2 beta, btrfs... all cool thinks but maybe I need to apply some caution now.

Friday, January 13, 2012

VMware Perl SDK - tip 0

If you get an error like
Error: Server version unavailable at 'https://10.7.112.166/sdk/vimService.wsd


export PERL_LWP_SSL_VERIFY_HOSTNAME=0


see http://communities.vmware.com/thread/240659?tstart=0

Tuesday, December 27, 2011

java applications SLOW in Windows XP guest in VMware Workstation

 I just found by reading this why java applications were so SLOW in my virtual machines. Something changed in an XP patch so that Java >1.5 have trouble when using 3d acceleration for 2d graphics.
Setting the environment variable

   J2D_D3D=false

is a workaround for the issue.

Tuesday, August 30, 2011

swappines of linux kernel

I'm a bit annoyed by the recent tendency of my linux to swap out a lot of memory from my apps while a lot of memory is used only as cache.

Since I have 4Gb ram and the only really memconsuming application I use is VMware workstation, I did an experiment and swapoff for 2 days: ok, some apps like chrome or firefox will die on start with 2 VM's running, but overall the system is far more responsive without swapin/swapout on my slow sata disk!

I googled for a way to tune swap behaviour on linux and find vm.swappiness.

Swappiness can be read at /proc/sys/vm/swappiness, and mine was set to 60 out of a range between 0 and 100. From what I understand, low swappiness will cause cache to loose the memory reclamation battle, while high swappiness will cause unused pages to loose, then

  low swappines = less cache, less swap
  hi swappiness = more cache, more swap

My swappiness was set to 60.

Experimentally, I will set a swappiness of 10 for a while, swapon() and see what happens.

sudo sysctl -w vm.swappiness=10