Debian GNU/Linux (etch) on a Lenovo (IBM) Thinkpad T60 with Xen HVM support

This document describes how to install Debian GNU/Linux "Etch" (testing) on a Lenovo (IBM) Thinkpad T60. These instructions aim at a Dual-boot installation that preserves both the factory installed Windows XP operating system and the special Lenovo "ThinkVantage" repair button functionality.

My T60 has a T7200 dual-core CPU that provides hardware support for virtualization. As an added bonus, this document also describes how to make use of this virtualization support with Xen 3.0.3 and run a second Debian GNU/Linux installation on a hardware virtual machine. (That is, not using the older paravirtualization technique for older CPUs.)

Tim Fraser Last updated: 13 January 2006

Although I provided this information in the hope that it will be useful, I provide it WITHOUT ANY WARRANTY; follow these instructions at your own risk.

(1) Machine specs

(2) What worked, what did not

Things that worked automatically after the initial install:
Things I haven't tried yet:

(3) Thanks

This howto combines information from several other authors along with my own experience.

Many thanks to these earlier authors who essentially did all the hard work for me!

(4) Dual-boot installation

Saving the factory-installed Windows stuff

The T60 came with Windows XP Professional pre-installed. It also came with an extra bootable partition containing various Lenovo repair, restore and rescue programs. You can boot this partition by pressing a blue "ThinkVantage" button on the machine after turning it on. I wanted to save both XP and the rescue partition and keep the ThinkVantage button working. According to Stephan Bellon's page, I would need to take the unusual steps of keeping the existing NT Master Boot Record (MBR) and using the NT loader to multiboot XP and Linux in order to accomplish this preservation. Although this approach complicates the installation, that's what I did.

  1. Boot XP and create the ThinkVantage recovery DVD/CDs so if something goes wrong, you can always restore the T60 to its factory settings. Burn the DVDs/CDs by going to Start->All Programs->ThinkVantage->Create Recovery Media.
  2. Make a bootable GParted CD from the ISO available at The Gnome Partition Editor website. GParted is a bootable CD that allows you to change and resize NTFS partitions.
  3. Use GParted to shrink your XP NTFS partition. My XP partition was originally about 90GB. I shrank it to 30GB leaving about 60GB of free unpartitioned space. I did not touch the 5GB ThinkVantage rescue partition.

Initial Debian GNU/Linux install

I initially tried installing Debian stable (Sarge), but its kernel was too old to support my T60's Ethernet NIC. So I installed release candidate 1 of Debian testing (Etch) instead.

  1. Make a bootable Debian testing (Etch) netboot CD for x86 machines from the latest ISO available from the Debian website.
  2. Boot and run the install procedure.
  3. Allow the installer to automatically generate new partitions in the unused hard disk space you created with GParted. I chose to have only a swap and a root partition. When you begin partitioning, the XP partition will be the partition with the "bootable" flag. Mark your new Linux partition as the bootable partition. We will make the XP partition the bootable one again in a later step, but we need the Linux partition to be bootable for now. At this point, my partition table looked like this:
    Disk /dev/sda: 120.0 GB, 120034123776 bytes
    255 heads, 63 sectors/track, 14593 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1               1        5222    41945683+   7  HPFS/NTFS
    /dev/sda2           13999       14593     4777920   12  Compaq diagnostics
    Partition 2 does not end on cylinder boundary.
    /dev/sda3   *        5223       13638    67601520   83  Linux
    /dev/sda4           13639       13998     2891700    5  Extended
    /dev/sda5           13639       13998     2891668+  82  Linux swap / Solaris
    Partition table entries are not in disk order
  4. Do not write the grub bootloader to the hard disk's Master Boot Record (MBR). Instead, write it to the beginning of your new Linux partition. By writing it to your Linux partition, you will preserve the factory-supplied XP MBR---a key step to preserving the ThinkVantage button functionality.
  5. If you want X11 be sure to select "desktop system" when given the chance. Also select the maximum resolution for your LCD in the X11 configuration menu. In my case this was 1400x1050 with 24bpp.

Getting dual boot to work

At this point we need to configure the NT boot loader to dual boot XP or Linux, and then fix the partition table so that the NT boot loader is run on boot.

  1. After the initial install completes, reboot. Because the Linux partition is the one marked bootable in the partition table, Linux will boot. Make sure your network is up. Install an SSH client. Copy the grub boot record you wrote to the beginning of your Linux partition to a file and then copy that file to some other machine.
    # /sbin/ifconfig eth0 | head -n2
    eth0      Link encap:Ethernet  HWaddr 00:15:58:7D:B5:3B  
              inet addr:  Bcast:  Mask:
    # apt-get install ssh
    # mount | grep ^/dev
    /dev/sda3 on / type ext3 (rw,errors=remount-ro)
    # dd if=/dev/sda3 of=bootgrub.bin bs=512 count=1
    # scp bootgrub.bin user@somewhere.else:
  2. Reboot using your GParted CD. Put the "bootable" flag back on the XP partition.
  3. Reboot. The T60 should boot into XP. In my case, it offered to boot into "safe mode", but I declined and chose to boot normally.
  4. Install Cygwin on XP. Be sure to install OpenSSH and vi.
  5. In a Cygwin shell, cd to /cygdrive/c ("C:").
  6. Use scp to copy bootgrub.bin into C:\bootgrub.bin.
  7. Make a backup of boot.ini with cp boot.ini boot.ini-orig just in case.
  8. Use chmod u+w boot.ini to make boot.ini writable.
  9. Use vi to add C:\bootgrub.bin="Debian GNU/Linux" to the bottom of the boot.init file. After editing, my boot.ini file looked like this:
    [boot loader]
    [operating systems]
    multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional"
    /noexecute=optin /fastdetect
    c:\bootgrub.bin="Debian GNU/Linux"
  10. Use chmod u-w boot.ini to make boot.ini read-only again.
  11. Reboot. The NT loader should run on reboot and offer to boot either XP or Debian GNU/Linux. Also, your ThinkVantage button should still work. FYI, if you change your Grub configuration from Linux (perhaps to add a new kernel to the list of kernels bootable from Grub), you do not have to transfer a new copy of bootgrub.bin to XP.
If you don't want to run Xen, you can stop here.

(5) Installing Xen

Setting up Domain0

I was able to use the binary Xen packages provided by Debian to create virtual machines using paravirtualization. However, paravirtualization was not enough: I wanted to take advantage of my CPU's hardware virtualization support and do true virtualization. The Debian binary packages for Xen did not seem to include the vital vmloader component required for true virtualization ("HVM" as Xen calls it), so I had to build Xen from source instead. Fortunately, this was not too hard. The tricky part is to make sure you have all the required tools and libraries installed before you build Xen because if Xen fails to find something it needs, it does not complain, it just leaves out features.

I have named my first Debian installation "entourage" and I will name the second virtual Debian installation "victim". I'm going to use the Simple DirectMedia Layer (SDL) library to enable Xen to bring up a little X window containing the console of my virtual machines.

  1. Boot into the first Debian installation ("Entourage"). Replace your glibc with a Xen-friendly version so that you don't have to worry about Xen's Thread Local Storage compatibility issues. Also install the Debian packages needed for building Xen with SDL support. The Xen build instructions refer to a "dev86" package. On Debian, this package is split into separate "bin86" and "bcc" packages, so you won't see the "dev86" name.
    # apt-get install libc6-xen
    # apt-get install gcc make binutils
    # apt-get install bin86 bcc
    # apt-get install zlib1g-dev libcurl3-dev libncurses5-dev python-dev x11proto-core-dev python-dev
    # apt-get install libsdl1.2debian-all
    # apt-get install libsdl1.3-dev
  2. Follow the "Installing from Source" instructions in the Xen documentation to obtain and build Xen from source.
  3. The Xen kernel needs to load a module containing a low-level SCSI SATA driver in order to mount its root partition from the T60's hard disk. Consequently, you must create an initial RAMdisk containing all the kernel's modules. Initrd images created in the usual Debian mkinitrd manner won't work with the Xen kernel. Instead, you must use mkinitramfs.
    # apt-get install initramfs-tools
    # mkinitramfs -o /boot/initrd.img-
  4. Add an entry for Xen into your grub menu.list file. Mine looks like this:
    # Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST
    # BEGIN Added by Tim for Xen
    title           Xen 3.0.3 / XenLinux 2.6.16
    root            (hd0,2)
    kernel          /boot/xen.gz dom0_mem=1572864
    module          /boot/vmlinuz- root=/dev/sda3 ro console=tty0
    module          /boot/initrd.img-
    # END Added by Tim for Xen
  5. Reboot into the Xen kernel. If all goes well, you should see (XEN) dmesgs on your console followed by the Xen Linux kernel's messages. The Xen network bridge scripts should also run during boot. After boot, you should see a xenbr network bridge in your ifconfig output.
    $ /sbin/ifconfig | grep xen
    xenbr0    Link encap:Ethernet  HWaddr 36:38:2D:E1:2F:32

(6) Configure and boot the "victim" Debian system in an HVM Guest Domain

  1. Download an ISO image of the Debian GNU/Linux testing ("Etch") net install CD-ROM. I'm putting my images in ~/VMs for convenience.
  2. Create a big sparse file to be the "victim" system's virtual disk. I made mine 10GB in capacity, although at this point the actual on-disk size is much less.
    tfraser@entourage:~/VMs$ dd if=/dev/zero of=virtualDebian.img bs=1M seek=10240 count=1
    1+0 records in
    1+0 records out
    1048576 bytes (1.0 MB) copied, 0.002726 seconds, 385 MB/s
    tfraser@entourage:~/VMs$ ls -l
    total 132168
    -rw-r--r-- 1 tfraser tfraser   134137856 2007-01-13 00:00 debian-testing-i386-netinst.iso
    -rw-r--r-- 1 tfraser tfraser 10738466816 2007-01-14 01:55 virtualDebian.img
    tfraser@entourage:~/VMs$ du -h virtualDebian.img
    1.1M    virtualDebian.img
  3. Modify a copy of the /etc/xen/xmexample.hvm domain configuration file. I named mine /etc/xen/virutalDebian and modified the lines shown below. Note that the virtual hard disk will be backed by the virtualDebian.img file and the virtual CD-ROM drive will be backed by the Debian ISO. Note also that I have set boot = 'd' to make the CD-ROM boot. We'll have to change this after the install is done.
    tfraser@entourage:/etc/xen$ diff xmexample.hvm virtualDebian
    < name = "ExampleHVMDomain"
    > name = "virtualDebian"
    < disk = [ 'file:/var/images/min-el3-i386.img,hda,w', ',hdc:cdrom,r' ]
    > #disk = [ 'file:/var/images/min-el3-i386.img,hda,w', ',hdc:cdrom,r' ]
    > disk = [ 'file:/home/tfraser/VMs/virtualDebian.img,hda,w', 'file:/home/tfraser/VMs/debian-testing-i386-netinst.iso,hdc:cdrom,r' ]
    > boot="d"
    > #boot="c"
    < sdl=0
    > #sdl=0
    > sdl=1
    < vnc=1
    > #vnc=1
    > vnc=0
  4. Boot the virtual machine with the command shown below. This should bring up a new X window showing the console of the virtual machine. The machine should boot from the CD-ROM. Run through the Debian install. I named my virtual Debian system "victim", since I expect to use it as a sort of crash-test dummy. I chose only the minimal "standard system" option with no X11. AFAIK, you should be able to use X11 with HVM. Indeed, you should even be able to boot various Windows OSs.
    entourage:/home/tfraser# /usr/sbin/xm create virtualDebian
  5. When it comes time to remove the Debian install CD-ROM and reboot, reboot the virtual machine and interrupt the boot process by asking the bootloader to show you additional boot options. While the boot is interrupted, use the commands shown below to determine the virtual machine's ID number and shut it down.
    entourage:/home/tfraser# /usr/sbin/xm list
    Name                                      ID Mem(MiB) VCPUs State   Time(s)
    Domain-0                                   0     1535     2 r-----    705.7
    virtualDebian                             14      128     1 -b----     21.7
    entourage:/home/tfraser# /usr/sbin/xm shutdown 14
  6. Modify /etc/xen/virtualDebian so that the boot line reads boot = 'c' instead of boot = 'd'. This change will make the virtual machine boot from the hard disk rather than the CD-ROM.
  7. Use the xm create virtualDebian command to restart the virtual machine and enjoy your virtual Debian system! After I ran apt-get update and apt-get dist-upgrade my virtualDebian disk image was using about 1.1GB of actual disk space:
    tfraser@entourage:~/VMs$ du -h virtualDebian.img
    1.1G    virtualDebian.img

Tim Fraser's homepage at the WPI alumni site

$Id: t60.html,v 1.5 2007/01/13 19:59:43 tim Exp $