Cabrillo College

The purpose of this lab is to be able to boot from your USB pendrive into your root file system from lab 1. Starting with an installed version of Linux that has grub installed, you will use the stage1 and stage2 grub bootloaders and the linux kernel to create a bootable operating system
This lab will involve five steps:
  1. Creating a boot directory on our root filesystem, copying the kernel, and creating an initial ramdisk in that directory.
  2. Creating a grub directory with the stage1 and stage2 boot loaders, the configuration file, a splash screen, and the kernel.
  3. Configuring the grub.conf file to boot into your root file system or your hard disk's root file system.
  4. Installing the stage1 boot loader to the MBR of the pendrive.
  5. Using your pendrive to boot into your personal root file system.

Use Fedora 8 or Fedora 9 for this lab. Make sure the file system on your USB pen drive created in Lab 1 is ext3.

Step One

Create a directory for the kernel and initial RAM disk.
  1. Log on as root.
  2. Insert your pendrive, with its root filesystem, into a USB port.
  3. Mount the file system to a directory of your choosing.
    Hint: mount /dev/sd? /mnt
  4. Change directory to your root filesystem.
  5. Make a directory called boot
  6. Copy the current kernel from your hard disk to your boot directory:
    cp /boot/vmlinuz-2.??? boot
    Note: be sure that /boot is mounted.
  7. Copy the /etc/fstab file to /mnt/etc
    Edit this file to change the root file system to your pendrive, and remove the swap entries.
  8. Create an initrd ramdisk for your root file system on your pendrive:
    mkinitrd --fstab=/mnt/etc/fstab --with-usb /mnt/boot/initrd.img $(uname -r)

Step Two

Change directory into your new boot directory.
  1. Make a directory called grub
  2. Copy the stage1 and stage2 files from the /usr/share/grub/i386-redhat directory into the grub directory you just made.
  3. Copy the grub configuration file, grub.conf and the splash screen file, splash.xpm.gz, from the /boot/grub directory on your hard disk to your grub directory.
  4. You should now have four files in your grub directory.

Step Three

Edit the grub.conf file.
  1. Edit the grub.conf file to indicate where the boot loader will reside. That location is the first partition of the pendrive. This is denoted as: (hd0,0) to the grub boot loader.
    root (hd0,0)
  2. On the kernel line, indicate that the root file system will be /usb with:
    root=LABEL=/usb
  3. Also add init=/bin/bash on the kernel line to indicate the initial program for the kernel to run. Make sure the pathname to the kernel includes the directory /boot.
  4. Change the initrd line to use /boot/initrd.img
  5. Give the title of your Personal Linux a unique name.
  6. Save these changes to the file.
  7. Unmount the pendrive file system.
    Note: don't forget to cd off the file system before you try to unmount it.

Step Four

Install the stage1 loader
  1. As root, run the grub command and wait for the prompt:
    grub >
  2. Type the following three commands in succession:
    • root (hd1,0)
    • setup (hd1)
    • quit

Step Five

Use your Pendrive to boot into your Root file system.
  1. This you will have to do in the classroom on Wednesday.

To turn in

Create a myfs file from a recursive long listing of your grub boot disk and append to it the contents of your grub.conf file and an xxd dump of the pendrive's MBR. Turn in this myfs file to the cis191 account on the machine, opus.cabrillo.edu using the following command:
scp myfs cis191@opus.cabrillo.edu:lab2.logname
Note: logname is your last name - all lowercase.
(The password for the cis191 account is "Cabri11o" with ones instead of els.)

Grading Rubric

10 points -
presence of the kernel, and the grub directory containing the grub.conf file, the splash screen and stage1 and stage2 boot loaders.
10 points -
correctly installed stage1 boot loader in the MBR.
10 points -
a correctly configured grub.conf file