Creating a Complete Distribution on CD
We all know about the possibilities for installing Linux on a hard drive. Sometimes, however, this option isn't good enough. Say, for example, you simply want to give someone a Linux CD that he can use without installing anything. Another scenario would be if you work for a school and want to teach your students how to use Linux on a PC, the same PC that will be used later in the day for a Windows 2000 class. In this article, the scenario is an enterprise that wants its customers to complete an evaluation at the end of a course. The goal is to insert a CD in the CD-ROM drive, boot and be redirected to some Web site where the evaluation can be completed.
One might wonder why you should create your own Linux bootable CD when so many solutions are available for downloading on the Net. Before we start, let's look at some of the best bootable Linux CDs.
Minilinux on CD. One of the easiest ways to create your own Linux bootable CD is to take the image of a Minilinux diskette and burn it on a disk. This is a nice solution if you don't like floppy disks, but in truth, this isn't really a complete Linux bootable CD. It's simply a floppy copied to a CD. For this reason we don't choose this solution; it isn't flexible enough.
SuSE Live Evaluation. Starting with SuSE version 7.3, this Linux distributor has created a Live Evaluation CD. This is a complete Linux distribution on a disk; simply insert it in the drive and boot it up to see a complete running Linux. There are, however, some drawbacks, the major one being some files have to be copied to your hard drive before you can use it.
Knoppix. Knoppix is a solution that looks a lot like the SuSE Live Evaluation. It is a nice solution based on Debian Linux, and it includes everything you need. The only drawback is you do need a DHCP server to activate the network card with a fixed IP address.
These all are viable options, but they are too much standardized and leave little room for flexibility. Therefore, you might decide to make your own bootable Linux CD. When you create your own CD, you can customize it and include only the things you need.
A good Linux bootable CD starts with a sound preparation. I took a new 20GB hard drive and installed Red Hat 9.0 on a 4GB partition. After that, I installed Red Hat 7.1 on a 2GB partition, and on the third, 650MB partition, I put a minimal installation of Red Hat 7.1. This 650MB partition has to be the master for the CD; once it is complete you simply burn it to a CD and you're ready. Of course, you can use any distribution you like. I wanted to work with Red Hat 7.1 because I am familiar with it. I installed Red Hat 9.0 as "working space", because I also wanted access to the most recent distribution, just in case.
If you are using a multi-Linux system, you have to make a boot menu to be able to boot them all. In LILO, you can do so by adding the following entries to lilo.conf:
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
message=/boot/message
linear
image=/boot/vmlinuz-2.4.2-2
label=completeRH71
read-only
root=/dev/hda6
image=/hda1/boot/vmlinuz-2.4.18-3
label=RH73
read-only
root=/dev/hda1
image=/hda7/boot/vmlinuz
label=cd-image
read-only
append=?root=/dev/hda7?
Once you complete the installation of the Linux images, it is very easy to modify the configuration of the CD. Try it out to see if it works; if it doesn't, you simply try again. Burn the CD only when you are satisfied with the configuration.
In creating a Linux distribution that can boot from a CD-ROM and doesn't need anything else, you are likely to encounter some challenges. The main problem is the root filesystem is read-only, but some files have to be created and/or modified. This stage concerns files in /dev, in /var and eventually in the user's home directory. The next challenge is to turn off everything you do not need, especially commands that try to create a file somewhere.
Regarding the files in /dev that need to be changed, since kernel 2.2 you can use devfs to access them. This kernel driver creates a virtual filesystem similar to the /proc filesystem in memory, where one file for each device your system needs is created. The /dev/ files exist in RAM only, so there's no problem in changing attributes of the devices. There is, however, a disadvantage: changes to /dev/, including symlinks for your mouse and CD-ROM, are lost. As a solution to this problem you can use the script rc.devfs, which comes with devfs. Any changes you make to /dev can be saved by using this script; simply type /etc/rc.d/rc.devfs save /etc/sysconfig , and your changes are recorded. In short, all you have to do is compile your kernel with devfs support and record changes you make to /dev using rc.devfs, and you are able to use and modify all necessary devices on the read-only filesystem.
For the files in directories including /var, /tmp and eventually the user's home directories, we need another solution. To make it possible to change and create files in these directories later on, you have to create them in an early stage of the boot process. You can do this by including some code at the beginning of rc.sysinit. In the example below, we use a special file called rc.iso for this step.
#rc.iso. Must be included at the beginning of rc.sysinit. # #create /var echo Creating /var ? mke2fs -q -I 1024 /dev/ram1 4096 mount /dev/ram1 /var -o defaults,rw cp -a /lib/var / #restore devfs settings, if any. Needs proc mount -t proc /proc /proc /etc/rc.d/rc.devfs restore /etc/sysconfig umount /proc
In the listing, two different things happen. First, a RAM drive is created and mounted on /var. Next, any settings saved to rc.devfs are restored to /etc/sysconfig so you can use them the next time you boot your system.
When you've done that, you can go on to the next important step: disabling the read/write remounting of your root filesystem and all lines associated with it. Simply look for the command mount -n -o remount,rw / in /etc/rc.d/rc.sysinit. At the same time, you can disable all lines that perform a check of your filesystems, because it doesn't make sense to check check a read-only filesystem automatically when you are booting your system.
Before you go on and burn the first trial version of your own distribution, you have to make some arrangements to create a symbolic link to a /tmp directory and to an /etc/mtab directory. The latter one is needed so the system can work with mounted filesystems. In addition, you need to make a template for /var. All of these steps are in a script, included below. Be aware, however, that you need to do this from the complete Linux distribution to the distribution you are creating on the reserved partition. In the listing below, the Linux partition that serves as the model for the CD to be created later is mounted on the directory /mnt/hda7. You need to execute this script only once.
#!/bin/sh
# make arrangements for /tmp
# delete tmp on hda7 if it exists
rm -fR /mnt/hda7/tmp
# create a symbolic link for /tmp to /var/tmp which will be writable when the cd is used
ln -s var/tmp /mnt/hda7/tmp
###
# create /proc/mounts on the cd so that you can make a link
touch /mnt/hda7/proc/mounts
# remove mtab if it exists
rm /mnt/hda7/etc/mtab
# recreate mtab as a link to /proc/mounts on the cd
ln -s /proc/mounts /test/etc/mtab
###
# create a template for /var/lib in /lib
mv /mnt/hda7/var/lib /mnt/hda7/lib/var-lib
mv /mnt/hda7/var /mnt/hda7/lib
mkdir /mnt/hda7/var
ln -s /lib/var-lib /mnt/hda7/lib/var/lib
rm -fR /mnt/hda7/lib/var/catman
rm -fR /mnt/hda7/var/log/httpd
rm -f /mnt/hda7/lib/var/log/samba/*
# recreate all files in /var/log as new empty files
for I in `find /mnt/hda7/lib/var/log -type f`; do
cat /dev/null > $i;
done
rm `find /mnt/hda7/lib/var/lock -type f`
rm `find /mnt/hda7/lib/var/run -type f`
Take a moment here to test if everything works so far. Save any changes you made and reboot from the CD image partition of your hard drive. You probably will see a lot of errors on your next reboot, but don't worry about them. Think of them as the fine-tuning that needs to be done afterwards. For now, the only important thing is that you end up at a login prompt. You also may encounter some serious error messages that end in something like this:
touch: creating '/var/lock/subsys/xfs': No such file or directory ] touch: creating '/var/lock/subsys/local': No such file or directory mkdir: cannot create directory '/var/root': File exists mkdir: cannot create directory '/var/temp': File exists ln: '/var/temp/tmp': File exists mkdir: cannot create directory '/var/log': File exists INIT: Id "1" respawning too fast: disabled for 5 minutes INIT: Id "9" respawning too fast: disabled for 5 minutes INIT: no more processes left in this runlevel
If you receive something like this, you probably to activate the devfs filesystem. Be sure that you included the line /sbin/devfsd /dev at the beginning of rc.sysinit. If you didn't your devices won't behave the way they should, and you can't do anything with your system. You say you just checked that devfsd is started and you still have problems? Be sure your RAM drives are initialized. If they are, you should see the line /dev/ram1 on /var type ext2 (rw) when using mount. If you don't see any RAM device, make sure that support for RAM drives is available in your current kernel configuration.
If you have been successful to this point, it isn't a bad idea to burn it all to a CD. You never know what might happen later, so it is a good idea to be have something stable to fall back on if you can't see what you did later in the process. Here's the procedure in short:
Get boot.img form a Red Hat installation CD.
Mount boot.img through loopback by typing
mount boot.img /somedir -o loop -t vfat
Remove everything from the mounted boot.img file except for ldlinux.sys and syslinux.cfg.
Copy the kernel image from your test partition to boot.img.
Edit syslinux.cfg so it contains the following, in which bzImage should refer to the kernel image file you use and /dev/cdrom should refer to the device file of your CD-ROM device.
default Linux label Linux kernel bzImage append root=/dev/hdc
Umount boot.img with umount /somedir.
Copy boot.img to the partition that is the master for the CD.
Change directories to the location where you want to store the image, and make sure you have enough free space.
Create the image with
mkisofs -R -b boot.img -c boot.catalog -o mydistro.iso /
Write the image to a CD.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- New Products
- Linux Systems Administrator
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Web & UI Developer (JavaScript & j Query)
- Designing Electronics with Linux
- Dynamic DNS—an Object Lesson in Problem Solving
- Using Salt Stack and Vagrant for Drupal Development
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- another very interesting
27 min 48 sec ago - Reply to comment | Linux Journal
2 hours 21 min ago - Reply to comment | Linux Journal
9 hours 15 min ago - Reply to comment | Linux Journal
9 hours 31 min ago - Favorite (and easily brute-forced) pw's
11 hours 22 min ago - Have you tried Boxen? It's a
17 hours 14 min ago - seo services in india
21 hours 46 min ago - For KDE install kio-mtp
21 hours 46 min ago - Evernote is much more...
23 hours 46 min ago - Reply to comment | Linux Journal
1 day 8 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?



Comments
great article! if your
great article!
if your wanting to remaster ubuntu or other debian based distributions check out this guide:
http://www.cyberpunkcafe.com/page.php?15
thanks anyhow!
creating a live cd
nice article, i'm trying to create one based on this. but i've some doubts.
1. i didn't find any devfs in /etc/rc.d/rc.devfs( thn wht did u mean by tht)
2.i installed a minimum of fedora core but not gotgraphics. how could i enable it, on live cd
Re: Creating a Complete Distribution on CD
Would it be possible to keep in mind that non-x86 Linux ports exist?
I realize it's really beyond the scope of this article to cover the different boot formats needed for non-x86 architectures, but you could at least mention that the procedure is different for them.
The Linux community is quick to point at how many platforms Linux runs on, but then assumes everyone's machine is x86.
Re: Creating a Complete Distribution on CD
Try the Gentoo LiveCD. I haven't personally tried it, but it claims to work on several different types.
Gentoo
Re: Creating a Complete Distribution on CD
Smaller than Knoppix and Morphix: DamnsmallLinux and LinuxBBC
bootcd automates the process
At least in the Debian distro, there is a set of scripts in a package called "bootcd" that automates the creation of a bootable live CD.
The scripts basically copy the installed system to a working directory, compress the directory, and generate a compressed ISO (using the Rockridge compressed filesystem extensions in the Linux kernel). I've personally gotten a 1.6GB system onto a 700MB CD in this way. The scripts even handle creating ram disks to hold /dev, /var, /etc, /tmp, /root, and /home. You can tweak what is and isn't included on the CD and what is and isn't loaded into the ram disks through the config file.
I use a 10GB partition for the install and to allow room for authoring the CD. 1.6GB of installed software + roughly 1.6GB for the "working directory" copy it creates + roughly 1-1.4GB for the compressed directory + 700MB for the resulting ISO == about 5-6GB (with some room to spare). Once the script finished creating the ISO, it automatically cleans up after itself by removing the working and compressed directories. By default it removes the ISO as well if it is configured to immediately burn a CD. I turned this off in the config file so I can burn multiple copies.
I've been impressed so far.
As since I'm doing this in Debian, configuring exactly what packages I want on the CD is simple with apt-get. Do a very simple install, "apt-get install" the software you want, "apt-get remove" the software you don't, and then start making ISOs.
Descriptions, sources, and packages (for Debian) can be found at
http://packages.qa.debian.org/b/bootcd.html
http://packages.debian.org/stable/utils/bootcd.html
Re: Creating a Complete Distribution on CD
This is not a good article, it really doesn't prove the point of why you should make your own bootable; makes erroneous comments in options like knoppix, doesn't cover very important topics like how to discover where the cd rom is, it just forces you to have a distribution customized for a particular configuration... nevertheless you can see some of the "behind the scenes" live cds preparation
Re: Creating a Complete Distribution on CD
Also check out Timo's Rescue Cd Creation Set on sourceforge:
http://sourceforge.net/projects/rescuecd/
The iso is a great pre-built rescue disk based on debian, but you can also download the source and custom tweak it however you like.
More than 650 MB?
How do you get more than 650 MB? I believe that Knoppix is using compression and allows one to have considerably more software than one could have in just a 650MB partition. Interesting article.
what about morphix
If you want a prepackaged distro that allows you to add
exactly what you want, try
http://www.morphix.net/
Re: what about morphix
http://www.morphix.net/ is a web site designer, what you want is
Morphix.org
Re: Creating a Complete Distribution on CD
About Knoppix author wrote:
3. Knoppix. Knoppix is a solution that looks a lot like the SuSE Live Evaluation. It is a nice solution based on Debian Linux, and it includes everything you need. The only drawback is you do need a DHCP server to activate the network card with a fixed IP address.
No, that is not true. In Knoppix you can activate the network card with a fixed IP address! You do not need DHCP server for that.
1. Command prompt : netcardconfig
2. KDE Menu: KNOPPIX-Network/Internet-Network card configuration
Re: Creating a Complete Distribution on CD
Morphix seems to be another good choice.
its originally based upon knoppix but is designed as a framework
for adding just the components you need.
http://www.morphix.net/
Re: Creating a Complete Distribution on CD
The web address is http://www.morphix.org.
The Mandrake method
1)Install Mandrake 9.2
2)Add a urpmi medium for contrib
See http://plf.zarb.org/~nanarodon for help on doing this (or 'urpmi urpmi.setup; urpmi.setup)
3)Install mklivecd
# urpmi mklivecd
4)Make your Live CD
# mklivecd livecd.iso
Of course, there are many things you might want to change, and that is why mklivecd has a lot of options (allowing you to build the image from a chrooted installation, specifying which kernel to run, which bootsplash screen to use etc).
What does this method give over the method in the article?
-cloop support (like Knoppix), so you can have filesystems of up to about 2GB
-important places in /etc and /var writeable, as well as /home (in memory)
-it's trvial to use
-It's quicker to do than remastering Knoppix
There are some things that don't work in the version in 9.2 contrib (like local printing, although remote printing works fine), but most of those are fixed in CVS. Also, be sure to use the updated kernels for Mandrake 9.2, you need cloop-1.02 for reliable use of a live CD, which was merged into the official kernels for 2.4.22-18mdk.
One CD has already been distributed en masse, and there are a few more coming.
Unfortuntely the web site (actually, minicd's website at http://minicd.berlios.de) hasn't been updated, but the mailing list is relatively active, and CVS has a few commits a week.
Re: Creating a Complete Distribution on CD
Don't forget the excellent and improving Dyne::Bolic -- not just a general distribution on CD, but specializing in audio/video editing and streaming tools. Great "brickout" style game, too. :)