ADIOS Project

-- Live Linux ADIOS CD home


Howto build live CD or DVD.

The ADIOS Development Kit will help you build your own Linux bootable CD or DVD.   The ADIOS Makefile can be found on the ISO image in the directory adk.

Presented here is a short tutorial for those who want to create their own boot CD or DVD based on ADIOS and Fedora Core 6

1. Install Fedora Core 6

Boot the system with FC6 install disc. Follow the online instructions. During installation select custom layout in relation to hard disc, as we want an extra partition for creating the image for your new boot ISO image.

Create at least one extra 10 Gb partition (to be used for building the boot CD or DVD). Create a mount point for this new partition say /mnt/newcd1 (choose a name suitable for you purpose, in the Makefile is called /mnt/devel)

Note: This tutorial will assume your /boot directory is on device /dev/hda5 and that Fedora Core / (root) is on /dev/hda6 and that your newcd1 image will be on /dev/hda7.   Let say your swap partition is on /dev/hda8 as well.  Your system will be different so edit this file to reflect your system so that you don't accidently wipe out the wrong partition.

The CD image does not support SELinux unless you setup double mounting.  You should disable SE Linux unless you really need to have it.  (Double mounting involves the creation of an EXT3 loopback filesystem within the squashfs loopback filesystem)

If you already have FC6 installed then either use fdisk or install gparted (gparted is part of the Fedora Extras and can be download using a web broswer or by using yum) or similar software to repartition your disc and create a 10 Gb partition for your new image.

Unless you have choosen to install all of the packages you should now check that you have software to read and write to your CD or DVD. So after you have FC6 up and running you should check that you have installed the following RPMs.

  mkisofs, dvd+rw-tools, cdrecord and cdrdao

Note: mkisofs builds the the ISO image, cdrecord writes the ISO to CD, growisofs writes the ISO to DVD and cdrdao is used to blank CDRW discs.

Enter the following to see if cdrdao is installed.

  rpm -qa | grep cdrdao

If not then mount the RPMs and either use the package manager or enter

  rpm -iv /media/cdrom/Fedora/RPMS/cdrdao...whatever the version.rpm

Note: if you want to build new kernels you will need to install the kernel sources and appropriate compilers and development packages also.  You don't need to do this unless you need extra kernel drivers or patches.

I will refer to the parent machine on /dev/hda6 as the FC6 machine and the Fedora Core 6 image you want on a CD on /dev/hda7 as the New CD image or DVD image if the ISO is large.

The master filesystem FC6 is now on partition 6 and the new CD filesystem is now on partition 7.  What ADIOS does is to split the Linux filesystem up into a set of diretcories for the new CD filesystem.  In summary:

/var contains all of the read-write files
/opt contains optional groups of files (such as web documents)
/usr is basically unmodified, except read-write files are moved to /var
/adios conatins all other files /bin, /sbin,/lib, /boot etc
/adk contains the adios development kit files, Makefile,
and files here are outside of the new CD filesystem
/adk/iso contains all of the files on the ISO image

2. Transfer ADIOS to your system

Place the ADIOS CD in the CD/DVD drive and mount the ADIOS CD by double clicking on the drive. This will mount the CD at /media/ADIOS-7.2.

Check that your mount point for your 10 Gb partition (newcd1) is mounted at /mnt/newcd1. If not mount it, for example the 10 Gb partition is at /dev/hda7 then enter:

  mount /dev/hda7 /mnt/newcd1

Now create the following directories and copy all the files from the ADIOS-7.2 CD to the bootcd folder

  mkdir -p /mnt/newcd1/adk/bootcd
  cp -af /media/ADIOS-7.2/*   /mnt/newcd1/adk/bootcd

You can now unmount the ADIOS-7.2 CD by typing

  umount /media/ADIOS-7.2

Or you can right click on the desktop icon and select eject.

Note: the bootcd folder is used by the ADIOS development kit Makefile to create a new ISO image that is stored in the adk folder before it is written to a CD or DVD.

3. Update Kernel to support squashfs

Sometimes the ADIOS kernel uses a newer version of the squashfs software than the Fedora Core image.  This means that you will have to either upgrade your existing kernel or use the ADIOS kernel.  To use the ADIOS kernel perform the following.

First boot your system from the ADIOS-7.2 CD.

If you have installed FC6 in a normal way then you should have /boot stored in one partition (say /dev/hda5) and the rest of the filesystem "/" in another partition (say /dev/hda6). Thus for this document I have assumed the following:

# /boot is on /dev/hda5 (mounted at /mnt/disc/hda5)
# / (your FC6) is on /dev/hda6 (mounted at /mnt/disc/hda6)

You system will be different, please make appropriate changes where required.

Now remount the filesystems read-write:

  mount -o remount,rw /mnt/disc/hda5
  mount -o remount,rw /mnt/disc/hda6

Next copy the kernel and initial ram disk from ADIOS ISO to the your FC6 disk

  cp -af /adios/boot/*2.6.18.2* /mnt/disc/hda5

Note: if /boot is part of "/" (root) filesystem then copy to the boot directory to your FC6 partition.

Now copy the ADIOS kernel modules to your FC6 disk

  cp -af /var/etc/modules/2.6.18.2-adios /mnt/disc/hda6/lib/modules
  cp -af /adios/lib/modules/2.6.18.2-adios/kernel /mnt/disc/hda6/lib/modules/2.6.18.2-adios
  cp -af /adios/lib/modules/2.6.18.2-adios/build /mnt/disc/hda6/lib/modules/2.6.18.2-adios
  cp -af /adios/lib/modules/2.6.18.2-adios/misc /mnt/disc/hda6/lib/modules/2.6.18.2-adios
  cp -af /adios/lib/modules/2.6.18.2-adios/source /mnt/disc/hda6/lib/modules/2.6.18.2-adios
 
Note: On the ISO image the files in directory /var/etc/modules are read-write files, whereas the kernel modules in /adios/lib/modules/<version>/kernel are read-only, the source is only a link

Now copy the mksquashfs executable to the /sbin

  cp -f /sbin/mksquashfs /mnt/disc/hda6/sbin

Alternatively download the latest squashfs software from the Internet find the squashfs-tools folder and make the latest version on mksquashfs, then copy to /sbin on your FC6 system.

Next add the following to GRUB boot loader file /mnt/disc/hda5/grub/grub.conf an entry for you FC6 to start using the ADIOS kernel. 

title FC6 with ADIOS kernel (2.6.18.2-adios)
    root (hd0, 5)
    kernel /vmlinuz-2.6.18.2-adios ro root=/dev/hda6 rhgb quiet
    initrd /initrd-2.6.18.2-adios.img

Note: The entry "root (hd0, 0)" points to your /boot partition, change this to reflect your partition configuration.

4. Modify the GRUB to boot live CD

Also add an entry to boot the live CD so that you can modify and test the image before burning a CD.

Note: root entry is "1" less that partition number.

Modify grub.conf and add the following

 title NewCD1 with ADIOS kernel (2.6.18.2-adios)
    root (hd0, 6)
    kernel /boot/vmlinuz-2.6.18.2-adios ro root=/dev/hda7 rhgb quiet
    initrd /boot/initrd-2.6.18.2-adios.img

Reboot your system from your hard disk and select the FC6 with ADIOS kernel.

5. Setup /mnt/newcd1 directory

Assuming you are running from disk and using a kernel that support squashfs.  First you may have to load the squashfs module

  modprobe squashfs

Now create directories called loop, adios, usr, www, initrd, initrd2

  mkdir /mnt/loop /mnt/adios /mnt/usr /mnt/www /mnt/initrd /mnt/initrd2

Now create folders adios, proc, dev, usr, opt, srv, sys, net, media, misc, mnt, selinux directories in the newcd1 plus any optional folders say for www and uml.

  cd /mnt/newcd1
  mkdir adios proc dev usr opt srv sys net media misc mnt selinux
  mkdir opt/www opt/uml

Now using the squashfs module you can unpack the adios.sqfs file and place the contents in the /mnt/newcd1/adios folder. The file type is squashfs and the filesystem is mounted via a loop (since it is really a device).  Now copy the files from the /mnt/adios folder to /mnt/newcd1/adios.   Next you can unmount the /mnt/adios folder

  mount -o loop -t squashfs /mnt/newcd1/adk/bootcd/adios.sqfs  /mnt/adios
  mount -o loop /mnt/adios/adios.loop  /mnt/loop
  cp -af  /mnt/loop/*  /mnt/newcd1/adios
  umount /mnt/loop
  umount /mnt/adios

Note: adios.sqfs is double mounted to enable User Mode Linux virtual machines to work.

Now using the squashfs module you need to unpack the usr.sqfs file and place it in the /mnt/usr folder.  Next copy the files from the /mnt/usr folder to /mnt/newcd1/usr folder and then unmount the /mnt/usr folder.

  mount -o loop -t squashfs /mnt/newcd1/adk/bootcd/usr.sqfs  /mnt/usr
  cp -af /mnt/usr/*  /mnt/newcd1/usr
  umount /mnt/usr

Now create the following link files in /mnt/newcd1

  cd /mnt/newcd1
  ln -s adios/bin
  ln -s adios/sbin
  ln -s adios/lib
  ln -s adios/boot
  ln -s adios/ro
  ln -s adios/var
  ln -s var/etc
  ln -s var/home
  ln -s var/root
  ln -s var/tmp

Note: The CD was made on /dev/sda5 your development device will most likely be different.

In this example we have assumed that the /mnt/newcd1 is on device /dev/hda7, so modify  /mnt/newcd1/etc/fstab to reflect this.  Also check that the swap device is commented out or is set to your swap device in this example /dev/hda8.

IMPORTANT - double check your fstab file in your newly created partition.  The first line of /mnt/newcd1/etc/fstab should now look something like the following if /dev/hda7 is your newcd1 development disk.

  /dev/hda7             /             ext3  defaults   1 1

Also you need to remove hardware and X11 configuration files

  rm -f /mnt/newcd1/etc/sysconfig/hwconf
  rm -f /mnt/newcd1/etc/blkid/blkid.conf
  rm -f /mnt/newcd1/etc/X11/xorg.conf

Optional:  For those of you wanting a web server on the bootable ISO, you can also unpack the www.sqfs file and place it in the /opt/www folder.  Now copy the files from the /mnt/www folder to /mnt/newcd1/opt/www and unmount the /mnt/www folder.

  mount -o loop -t squashfs /mnt/newcd1/adk/bootcd/opt/www.sqfs  /mnt/www
  mkdir -o /mnt/newcd1/opt/www
  cp -af /mnt/www/* /mnt/newcd1/opt/www
  umount /mnt/www

If you need User Mode Linux then unpack the uml.sqfs to /opt/uml files. You now have the files in /mnt/newcd1 to rebuild the boot CD.  For convience you might want to access your ISO web pages from your FC6 machines web server you could add the following.

  cd /opt;  ln -s /mnt/devel/opt/www
  cd /var;  mv www www-orig; ln -s /mnt/devel/var/www

6. Setup the MAKEFILE

First link the Makefile from the bootcd/adk folder back into the adk folder on the new CD partition with the following commands.

  cd /mnt/newcd1/adk
  ln -s bootcd/adk/Makefile

Now edit the Makefile so that all occurances  /mnt/devel are changed to /mnt/newcd1.  This should only be on one line hopefully.  Also change device information to reflect your own device numbers.   In this example hda7 is where newcd1 lives and remember GRUB programmers count from zero not one.

  VERSION = 1.0
  DATE = 1-January-2007
  AUTHORS = "Your name goes here"

  DEVELDEV = /dev/hda7
  DEVELGRUB = (hd0, 6)

  DEVEL = /mnt/newcd1


Also modify the Makefile for your CD drive edit the Makefile so that CDWRITER points to your CD, take output from following.

  cdrecord -scanbus   or    cdrdao scanbus 

Lets assume you see ATA:1,0,0 now modify the CD/DVD and speed values.

  CDWRITER = ATA:1,0,0
  CDBURNSPEED = 8

7. Create live ISO file

To test that all works so far, from within /mnt/newcd1/adk directory, type the command

  cd /mnt/devel/adk
  make iso

If you need to blank/erase a RWCD just enter

  make blank

To write the ISO to CD enter

  make burn

To write the ISO to DVD the growisofs command does not require a separate command to blank the DVD first.

  make dvdiso

8. Remove and Add packages

From the FC6 system, the following is an example of removing the package kdegames from the newcd1

  rpm -r /mnt/newcd1 -e kdegames

To add packages

  rpm -r /mnt/newcd1 -iv /media/cdrom/Fedora/RPMS/some_package_some_version.rpm

Alternatively boot directly into the future new CD image, which was labeled NewCD1 with ADIOS kernel and erase and insert packages as needed.  If you are new to RPMs you may find the dependencies tricky, in which case using yum back to RedHat Fedora Core may save you time.

9. Rebuild the live CD

You should also modify the startup files on the ISO image located in the bootcd or bootdvd subdirectory under the adk directory.

  cd /mnt/newcd1/adk/bootcd

Modify the README files and the files in adk/doc directory and the msg files in the isolinux directory.  These files are displayed on startup and reflect what is on the ISO image.

Once you are happy with your new CD image you can create the ISO image.  From the /mnt/newcd1/adk folder type the following commands.

  make adios.sqfs   (or make adios.loop if you require uml)
  make usr.sqfs      (keep total size of all files below 4Gbytes)
  make www.sqfs
  make iso     (or make dvdiso if you are building a DVD)
  make burn

If you managed to get to here then you may be ready to tailor the boot options.
  

10. Modify the Boot Options

Make a mount point /mnt/initrd and mount the initial ram disk, modify the linuxrc file and then rebuild the initird.gz file

  mkdir /mnt/initrd /mnt/initrd2
  cd /mnt/newcd1/adk
  mkdir initrd
  cp bootcd/isolinux/initrd.gz initrd
  cd initrd
  gunzip initrd
  mount -o loop initrd /mnt/initrd

On your FC6 machine add an entry to the end of your /etc/fstab file similar to the last line in your /etc/mtab file. It should look something like this

  /mnt/newcd1 /adk/initrd/initrd  /mnt/initrd   ext2  rw,loop 0 0

Modify the /mnt/initrd/linuxrc file and its menus then to rebuild the initial ram disk using the commands from the Makefile.   To give your CD a distinctively different look and feel change the layout of menus and the associated help stored in initrd/info.  Remember to keep a backup copy of these files just in case your changes result in linuxrc having a boot failure.  (Then you can use the diff command to detect what you did wrong or use the debug silent command on booting the ISO image.)  Then to rebuild the compressed initial ram disk "bootcd/isolinux/initrd.gz" file enter:

  make initrd

All that is left to do is to rebuild the ISO image and burn yet another CD.


Written by Neville Richter, n.richter@cqu.edu.au Copyright GNU General Public Licence 2007.