Tuesday 21 April 2009

Building an Ubuntu Live CD from Scratch

( This document was written in connection with the one day Live Cd workshop held at college of Engineering Attingal. )

1. Introduction

This document describes how to build a minimal live CD based on ubuntu 8.10.. The most recent version of this document can be found at http://brainstorms.in.

2. System Requirements

  1. A Host System with ubuntu 8.10 installed. ( Other versions will also work)
  2. Plenty of Disk space.
  3. A steady Internet connection or access to ubuntu repositories.
  4. Root access on the host system.

3 Exploring an existing ubuntu CD.

In order to understand the working of a live CD, let us look at an existing ubuntu CD

If you have the CD with you , put it into your CD drive. If you have an image , mount it on the loop device.

# mount -o loop ubuntu-8.10-desktop-i386.iso /cdrom

The directory structure of a typical ubuntu CD look as below.

autorun.inf dists isolinux pics preseed ubuntu wubi.exe

casper install md5sum.txt pool README.diskdefines umenu.exe

The exe files and autorun.inf are for installing under MS Windows. Some of the other files are self explanatory. Our main focus will be on isolinux and casper directories..

The isolinux directory contains files needed to boot from the live CD, Infact, isolinux belongs to a set of bootloaders written by Peter. H Anwin. The home page is here. As I mentioned isolinux , is the bootloader.. If you look at isolinux subdirectory, you will find several files. Some of them will be as shown below.

isolinux.bin isolinuc binary

isolinux.cfg Configuration File

boot.cat boot catlogue

bootlogo Logo

There are several other files. They are mainly for providing language support. ( Please feel free to look at some of them). The isolinux.cfg includes several other configuration files corresponding to differnt boot options. We will write a simple isolinux.cfg later.

The casper directory contains the following.

filesystem.manifest filesystem.squashfs vmlinuz

filesystem.manifest-desktop initrd.gz

vmlinuz and initrd.gz are the kernel and ram image from which isolinux will boot the system.

The filesystem.squashfs contains a compressed image of the filesystem. When we boot the live CD, this image will be uncompressed and moounted as the root filesystem.. All remastering programs and custom distros try to rebuild this image.. Filesystem,manifest and filesystem.manifest-desktop are text files which contain a list of packages inside the squashfs image.

The squashfs image can be loop mounted like an iso image.

# mount -o loop filesystem.squashfs /mnt /tmp

4 Preparing the host system.

Ensure that the Ubuntu 8.10 is installed on the host system. Log to the host system and update the system using apt. (I am assuming that you have direct access to Internet..)

a) Install necessary packages

apt-get install syslinux squashfs-tools mkisofs sbm

b) Prepare a working directory

Open a terminal on the host system, Become root.

$sudo su

#

Create a temporary work directory.

# mkdir work

Inside work create the following.

# mkdir work/filesys

#mkdir work/image

#mkdir work/image/casper

#mkdir work/image/isolinux

#mkdir work/image/install

We will be building the iso image from the image directory. We will populate the image directory one by one and finally build a CD image. The filesys directory is a temporary area where we will build the root filesystem of the Live CD.

Here you Go! http://brainstorms.in/

No comments: