Monthly Archives: September 2009

Running Windows XP in Debian using QEMU

I’m using Debian for my work.  Recently, I need to use a tool that will only run on a Windows XP.  To setup a Windows XP using QEMU is the solution:

  1. Install and build the required packages.
    # aptitude install qemuctl qemu-launcher
    # aptitude install kqemu-common kqemu-source
    # m-a prepare
    # m-a auto-install kqemu
    # modprobe kqemu
    # echo kqemu >> /etc/modules
  2. Run the qemu-launcher.
  3. Check the “Use CD-ROM” checkbox and put your Windows XP installer CD into your CD-ROM drive.
  4. For the “Boot disk” drop-down-list, select “CD-ROM”.
  5. Create the “Hard disk 0” by clicking the “New” button.
  6. Change the “RAM (MB)” to what you want.  I’m using “512”.
  7. Now, your virtual machine has one harddisk, boots from your CD-ROM and has 512 MB RAM.
  8. Click the “Launch” button to start your virtual machine.  Usual Windows XP installation follows.

The installation process took a long time to complete (much longer than a usual XP installation), but it runs as fast as (if not faster than) a usual XP installation.

* I experience 2 crashes during the installations.  Maybe I was just unlucky.

** You can also use an ISO image as your Windows XP installer CD.  Just replace the “CD-ROM” setting from “/dev/cdrom” to “/some/directory/to/your/XP.iso”.

*** To enable widescreen support, select the “Standard VGA card with VESA Bochs extensions” under “Video card” section, in the “Hardware” tab.

**** ctrl+alt+f to go into fullscreen mode.  ctrl+alt+f again to switch back to window mode.


Debian lenny on TwinHead M95

After more than 3 years of heavy use, my Acer Aspire 5540 has retired.  I just got a TwinHead M95.  The following is what I did to install Debian on it.  By the way, I’m now writing this blog using the M95 and Debian.

  1. Boot with Debian r5.0 DVD (disc 1) and follow the installation to the end.
  2. After the default installation:
    1. Wrong screen resolution and no 3D rendering.
    2. No way to adjust screen brightness.  The hotkeys (Fn + F6/7) are not working.
    3. No Wireless network.
  3. To get the correct screen resolution and 3D rendering.
    1. aptitude install binutils make gcc glibc
    2. Download nvidia linux driver from
    3. Shutdown GDM
      # /etc/init.d/gdm stop

      1. Invoke the nvidia linux driver installation:
        # ./

        1. Restart GDM
          # /etc/init.d/gdm restart

          1. For detail explanation, see
        2. To adjust the screen brightness.
          1. The screen brightness can be adjusted by using the “nvidia-settings”. It is installed automatically when you install the nvidia driver.
          2. The screen brightness will always go back to the default after the X is restarted or after lock/unlock the screen. By starting the “nvidia-s
            ettings”, the screen brightness will go back to what you have set in the “nvidia-settings”.
          3. Haven’t found a way to enable Fn + F6/7 for controling the screen brightness.
        3. To enable wireless network.
          1. Add lenny-backports into the /etc/apt/source.list
            # echo “deb lenny-backports main contrib non-free” >> /etc/apt/source.list

            1. Get the list of backports packages.
              # aptitude update

              1. Install backports keyring to avoid warnings.
                # aptitude -t lenny-backports install debian-backports-keyring

                1. Install the new kernel and firmware that can make use of the wireless chipset.
                  # aptitude -t lenny-backports install linux-image-2.6.30-bpo.1-$(uname -r | sed ‘s,.*-,,g’) firmware-ralink

                  1. Configure your network interface. My “/etc/network/interfaces” has the following entries:
                      • auto ra0
                      • iface ra0 inet dhcp
                      • wpa-key-mgmt WPA-PSK
                      • wpa-pairwise CCMP TKIP
                      • wpa-group CCMP TKIP
                      • wpa-ssid <Your access point name>
                      • wpa-psk <Your access point key>
                      1. Reboot your laptop. Choose to boot into the new kernel you just installed (the first one in the list).
                      2. Bring up your wireless interface.
                        # ifup ra0

                          Make sure your wireless LED is on (Press Fn + F1 on your keyboard). If the LED is not on, you may get a kernel failure, like I did.

                        1. For details, see
                      3. END

                      Credit Card Check Digit

                      A Credit Card number usually consist of 3 parts:

                      • Issuer ID (left most 6 digits)
                      • Account Number (9 digits)
                      • Check Digit (right most 1 digit)

                      All valid credit cards fulfill a validation check called “Luhn Check”.  The algorithm of Luhn Check is simple:

                      1. Double each odd position digit of the credit card number.
                      2. If the resulting number is 2 digits, add the two digits.
                      3. Replace all odd position digit with the newly calculated digit.
                      4. Add up all 16 digits and divide by 10.
                      5. If the total can be perfectly divided by 10, it satisfy the “Luhn Check”.


                      1. Sample credit card number (Visa):  4111 1111 1111 1111
                      2. Double the odd position digits:  8121 2121 2121 2121
                      3. Add up all 16 digits: 8+1+2+1+2+1+2+1+2+1+2+1+2+1+2+1= 30
                      4. 30 can be perfectly divided by 10, so the credit card number fulfills the “Luhn Check”.

                      Example 2:

                      1. Sample credit card number (Master Card):  5500 0000 0000 0004
                      2. Double the odd position digits (the first digit is 10=>1+0=>1):  1500 0000 0000 0004
                      3. Add up all 16 digits: 1+5+0+0+0+0+0+0+0+0+0+0+0+0+0+4= 10
                      4. 10 can be perfectly divided by 10, so the credit card number fulfills the “Luhn Check”.

                      For a more detail explanation, see