Thursday, August 14, 2008

How to install Anvil on Ubuntu 8.04 Hardy Heron

I just found an interesting Ruby programming framework Anvil. It makes Ruby MVC programming more efficient. Anvil is based on wxruby and works on multiple platforms.

These are the steps to install anvil:
  1. install ruby by sudo aptitude ruby-full rubygems
  2. update the gem by sudo gem update --system
  3. sudo gem install anvil --include-dependencies
And then you may go to Anvil website and follow it to build your first Anvil application.

How to fix /usr/bin/gem:23: uninitialized constant Gem::GemRunner (NameError)

After I ran sudo gem update --system on Ubuntu 8.04 Hardy Heron, gem returns
/usr/bin/gem:23: uninitialized constant Gem::GemRunner (NameError)
when I run it.

The fix is very easy: Just add one line require 'rubygems/gem_runner' to /usr/bin/gem.

Monday, August 11, 2008

bootlace.com produces Error: Invalid partition table. Must specify --floppy explicitly for floppy.

I wrote a script to drive parted to prepare an USB disk bootable. When my script tried to install grub4dos with bootlace.com, it produced this error message:
Error: Invalid partition table. Must specify --floppy explicitly for floppy.

BOOTLACE writes GRLDR BOOT RECORD to MBR or to the boot area of a file system.
Usage: bootlace.com [OPTIONS] DEVICE_OR_FILE
Options: --read-only, --floppy[=N], --boot-prevmbr-first, --boot-prevmbr-last,
--no-backup-mbr, --force-backup-mbr, --mbr-enable-floppy, --mbr-disable-floppy,
--mbr-enable-osbr, --mbr-disable-osbr, --duce, --time-out=T, --hot-key=K,
--preferred-drive=D, --preferred-partition=P, --sectors-per-track=S, --heads=H,
--start-sector=B, --total-sectors=C, --install-partition=I, --lba, --chs,
--fat12, --fat16, --fat32, --vfat, --ntfs, --ext2
DEVICE_OR_FILE: Filename of the device or image. For DOS, a BIOS drive number
(in hex 0xHH or decimal DDD format)can be used to access the drive.
I was wondering what was wrong and it took me several hours in finding the answer on google. However I could not find an answer to this problem.

Then I deleted the partition which was created by my script and created the partition again with gparted. Viola! sudo ./bootlace.com /dev/sdb returned a success message to me. I noted down the start and end sectors of the working partition and compared them with the one which was created by my script. I found the start secter is 63 on the working partition while the bad one which was created by my script is 1. This is the culprit that my script assigned the first track to a primary partition and it is the reason why bootlace complained about it. MBR is always on the first track, and there are 64 sectors per track. I have learned it in a Computer Architechture lesson in University several years ago. I should have recalled it earlier.

The solution: sudo parted --script /dev/sdb mkpart primary ntfs 63s #{size}
The above line is the modified command in my script. The start sector has been modified from 0 to 63, and bootlace.com is happy to install grub4dos for me now.

Saturday, August 9, 2008

mplayer no video with ATI fglrx driver

After I have installed Gmlive, I found mplayer doesn't render any video output. My graphic card is ATI Radeon X1600, and the driver for this graphic card is the default proprietary driver shipped with Ubuntu 8.04 Hardy Heron.

It is the relevant error message of mplayer:
gnome_screensaver_control()It seems there is no Xvideo support for your video card available.
Run 'xvinfo' to verify its Xv support and read DOCS/HTML/en/video.html#xv!
See 'mplayer -vo help' for other (non-xv) video out drivers. Try -vo x11
Error opening/initializing the selected video_out (-vo) device.
The solution is quite simple. Just edit /etc/X11/xorg.conf and add the red-colored line (Option "TexturedVideo" "on") to the Device section.


Section "Device"
Identifier "Configured Video Device"
Driver "fglrx"
Option "PowerState" "1"
Option "OpenGLOverlay" "off"
Option "TexturedVideo" "on"
BusID "PCI:1:0:0"
EndSection


Restart X-Window or reboot, and then mplayer should play any video seamlessly.

How to install gmlive on Ubuntu to watch P2P TV and videos

Gmlive is a software which supports mms, sopcast, nslive P2P TV and stream video. I found this project when I was looking for pplive for linux. pplive is another windows only P2P TV software which a lot of people has recommended to me. I am installing this because of I missed the Beijing 2008 Olympic opening and someone told me that the last scene of igniting the Olympic torch is amazing.

This following is how to install gmlive on Ubuntu 8.04 Hardy Heron:
  1. download gmlive here http://code.google.com/p/gmlive/
  2. install dependencies
    sudo aptitude install intltool libglibmm-2.4-1c2a libglibmm-2.4-dev libxml2 libxml2-dev libgtkmm-2.4-dev libglademm-2.4
  3. compile and install
    tar xf gmlive-0.20.3.tar.bz2
    cd gmlive-0.20.3
    ./configure
    make
    sudo make install
  4. type gmlive and enjoy

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.