From OSLab

Intro: Installing your system

Debugging kernel code requires a dedicated computer, as bugs may result in the system crashing or worse. (such as corrupted or overwritten file systems) Rather than dedicating a physical machine, we will be using the free version of VMWare Server as our test platform in this class.

We will run a stripped-down Linux distribution, CRUX Linux (http://www.crux.nu), on the virtual machine, for two reasons: (a) it takes less disk space, and (b) it boots quickly - this is something we are going to be doing a lot of, either after installing a new kernel, or after crashing.

The following directions walk you through (a) installing VMWare, (b) installing the linux distribution, and (c) compiling and booting a new kernel.


Install VMWare

  1. Get the free version of VMWare Server here
    Register and get a license key. You may also want the following documentation:
    VMware Server Administration Guide pdf
    VMware Server Virtual Machine Guide pdf
  2. Create a new virtual machine
    guest operating system: "other 2.6.x linux kernel"
    networking: "host-only"
    disk: 2GB is more than enough. I use 1.25G in the example below.

note - if you have SElinux enabled (e.g. if you're running CentOS 4.3) you won't be able to install VMWare. Remove the selinux policies first:

  rpm -e selinux-policy-targeted

note for Macintosh users - this has been tested with a trial copy of build 1884 of Parallels for Mac, and with the appropriate substitutions (CD/ROM has to be primary slave to boot, so pass a kernel command line option; use IDE drive instead of SCSI) it seems to work.

Install Linux

  1. Get the installation ISO image
    cmpsci577a.iso.bin (the .bin prefix is to make our webserver serve it as binary - you may need to rename it to cmpsci577a.iso)
  2. Boot the installation CD
    Configure the CD/ROM device to use cmpsci577a.iso, boot, and log in as root. (if you're installing off a physical CD, then configure it to use the real CD/ROM drive)
  3. Partition the disk
    If you used the default configuration, your virtual disk is /dev/sda. (If you configured the virtual disk as an IDE drive, it will be /dev/hda) Use fdisk or cfdisk to partition the disk, creating two partitions:
                               cfdisk 2.12r

                          Disk Drive: /dev/sda
                     Size: 1342177280 bytes, 1342 MB
           Heads: 255   Sectors per Track: 63   Cylinders: 163

  Name        Flags      Part Type  FS Type      [Label]    Size (MB)
---------------------------------------------------------------------
  sda1                    Primary   Linux swap              254.99 
  sda2        Boot        Primary   Linux                   1085.74

     [Bootable]  [ Delete ]  [  Help  ]  [Maximize]  [ Print  ]
     [  Quit  ]  [  Type  ]  [ Units  ]  [ Write  ]
Be sure to (a) set the "Boot" flag on /dev/sda2 so you can boot from it, and (b) set the type of /dev/sda1 to "swap".
  1. create and mount filesystem, swap:
  mkfs.ext3 /dev/sda2
  mount /dev/sda2 /mnt
  mkswap /dev/sda1
  swapon /dev/sda1
  1. Run 'setup'
    It will prompt you for the directory to install into (/mnt), the operation to perform (install), and then ask you to select packages. The default list of packages should be OK - it consists of only the required packages plus GDB.
  2. "chroot" into the new installation
 $ mount --bind /dev /mnt/dev
 $ mount --bind /tmp /mnt/tmp
 $ mount -t proc proc /mnt/proc
 $ mount -t sysfs none /mnt/sys
 $ chroot /mnt /bin/bash
  1. edit /etc/fstab
    It needs to contain the following two lines:
  /dev/sda2  /   ext3    defaults        1 1
  /dev/sda1  swap swap   defaults        0 0
  1. edit /etc/rc.conf
    The hostname doesn't really matter, but you probably want to edit the SERVICES line so it reads:
  SERVICES=(net sshd)
You can add other services, but you probably don't need them.
  1. Edit /etc/rc.d/net and /etc/hosts
    Actually, you don't need to edit them, as by default it should be set up to use DHCP on eth0

Compile and install the kernel

  1. Configure, compile, and install a new kernel
    Note that there are two initial kernel configuration files in the directory /usr/src/linux-2.6.16.6. The easiest way to configure the kernel is to copy one of them to .config and then 'make oldconfig' to set up the configuration. The "small" configuration is recommended - it compiles quickly, and contains all the devices needed for VMWare Server.
 $ cd /usr/src/linux-2.6.15.6
 $ cp linux-2.6.15.6-small.config .config
 $ make oldconfig
 $ make 
 $ make modules_install
 $ cp arch/i386/boot/bzImage /boot/vmlinuz
 $ cp System.map /boot/System.map
  1. Install the boot loader
    Edit /boot/grub/menu.lst if necessary - by default it should boot /boot/vmlinuz with /dev/sda2 as the root partition. Then run grub:
  $ grub
  grub> root (hd0,1)
  grub> setup (hd0)
  grub> quit
NOTE - the standard CRUX instructions describe using LILO, an older linux boot loader, instead of Grub. In my experience this results in a virtual machine that will not boot.

Now you are done - you should be able to disconnect the CD/ROM (menu VM->CD/ROM->disconnect) and reboot into your newly installed virtual machine.

Retrieved from http://oslab.info/index.php/Intro/Install
Page last modified on September 14, 2006, at 01:47 PM EST