Showing posts with label virtualization. Show all posts
Showing posts with label virtualization. Show all posts

Saturday, August 9, 2008

How to mount a kvm and qemu disk image file

It is an easy task to mount a kvm/qemu disk image. The magic is the offset=32256 parameter. However this magic only works on raw format disk image. If the image is in qcow or qcow2 format, you need to convert it to raw format.

# mount a raw qemu disk image 'disk.img' to /mnt
sudo mount -o loop,offset=32256 disk.img /mnt
This is an example of converting a qcow image to a raw image. Only do it if the image format is not raw.

# convert image format
qemu-img convert -f qcow disk.img -O raw disk.raw
If you are unsure about the image format, you may type this command to figure it out.

#use qemu-img info  to get the virtual disk format information

qemu-img info disk.img

image: disk.img
file format: raw
virtual size: 1.0G (1073741824 bytes)
disk size: 866M

Friday, August 8, 2008

How to Enable USB devices in VMware server

In my memory, VMware workstation grabs USB devices automatically, and it works every time as long as the USB device is not claimed by the Linux host kernel driver. I have just installed VMware server tonight and I was trying to attache my USB stick to VMware client, however VM->Removeable Devices->USB Devices shows Empty; it has detected nothing! And then I spent 3 hours in googling the answer.

The following is how I solved this problem on Ubuntu 8.04 Hardy Heron:

1. edit /etc/fstab and add this line


# USB for vmware
none /proc/bus/usb usbfs devgid=46,devmode=664 0 0
2. edit /etc/init.d/mountdevsubfs.sh and uncomment these 4 lines

#
# Magic to make /proc/bus/usb work
#
mkdir -p /dev/bus/usb/.usbfs
domount usbfs "" /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
ln -s .usbfs/devices /dev/bus/usb/devices
mount --rbind /dev/bus/usb /proc/bus/usb

3. reboot

4.
You need to do this step when your guest is turned off. In the VMware server window click "Edit virtual machine settings" -> Click "Add" in the lower left -> Select usb controller -> click finish.

5. Start your guest and click VM -> Removable devices -> USB devices -> Select the USB device which you want to access in your guest

This works for me and should work with all modern Linux distributions with a tiny bit of change.

Install VMware on Ubuntu 8.04 Hardy Heron

Since Automatix is no longer active, I can't install VMware on my Ubuntu laptop by just a few clicks anymore. I am really sad about the discontinue of such a nice piece of software. This is how I installed VMware Server 1.06 manually. It may also work with VMware Workstation and VMware Player.

1. Prepare the environment

sudo apt-get install build-essential linux-headers-`uname -r` xinetd ia32-libs
2. Download VMware
3. Decompress the downloaded tar.gz file

cd /usr/src
sudo tar xzf /tmp/VMware-server-1.0.6-91891.tar.gz

cd vmware-server-distrib
sudo ./vmware-install.pl

4. Enter the serial number during installation.

5. Copy the lib files

sudo cp /lib/libgcc_s.so.1 /usr/lib/vmware/lib/libgcc_s.so.1
sudo cp /usr/lib/libpng12.so.0 /usr/lib/vmware/lib/libpng12.so.0

6. 64-bit system only (You don't need this step if you are doing it on an i386 computer)

sudo ln -s /usr/lib32 /usr/l32
sudo sed -i -e 's:usr/lib/:usr/l32/:g' /usr/lib32/gtk-2.0/2.10.0/loader-files.d/libgtk2.0-0.loaders
sudo sed -i -e 's:usr/lib/:usr/l32/:g' /usr/lib32/libgdk_pixbuf-2.0.so.0.1200.9
Now Vmware is ready. Enjoy!!