LinuxDevCenter.com

oreilly.comSafari Books Online.Conferences.

We've expanded our Linux news coverage and improved our search! Search for all things Linux across O'Reilly!

Search
Search Tips

advertisement

Listen Print Discuss Subscribe to Linux Subscribe to Newsletters

Using and Customizing Knoppix
Pages: 1, 2, 3

Part 3. Making a New Bootable CD

After much work, you now have a working image of the Knoppix distribution on the hard drive, the file system has been copied, and you have the scripts and the requisite RAM. Creating a successful, bootable CD is the process of removing and adding packages, followed by fine-tuning services and the user's account configuration files. Let's make it happen!



Step 1: Upgrading and installing packages

The very first thing to do is to make sure that your distribution has the most recent libraries and security patches. You can do this with the network applications available from the live-CD distribution. My own preference is to use my original, native distribution. GNU/Linux, as Debian calls itself, is remarkable in its ease of applying updates and patches. Knoppix is just as easy, by virtue of its lineage. You just need to use the Debian package management utilities to update the OS.

Assuming you are connected to the Internet, on your normal installation version of Linux, open a console as root and navigate to the KNOPPIX_remastered directory. Run chroot to get a new root directory:

bash-2.05# /usr/sbin/chroot ./

You may see a race condition consisting of /dev/null permission denied messages. If that happens, remount the drive with the nodev option set. Here's a sample configuration that I put in my own fstab file:

/dev/hdc1 /mnt/linux ext2 (rw,nosuid,nodev) 0 0

You will also need to mount the /proc file system within the console to allow Internet access and the use of such utilities as screen:

bash-2.05# mount -t proc /proc proc

At this point, I always invoke the screen application, since I always move from activity to another and end up running several jobs at the same time (such as reading documentation while doing an upgrade). Before going onto the Internet, assuming that you put your primary OS online before chrooting, make sure the chrooted resolv.conf file has the correct DNS entries for successful name resolution.

Updating the distribution will resynchronize the package index files from their sources. Use the apt-get update command. Upgrading will install the newest versions of all packages currently installed. You are now ready to install a package and all of its dependencies (though you may need to go to the Debian site to figure out the package name). Use the apt-get install <package name> command.

Step 2: Removing what you don't want

The process of removing packages correctly is critical. Removing too little means you can't install what you want, due to space restrictions on the CD. Removing too much runs the risk of removing those packages that make the live-CD functional. The Knoppix site has a lot of information on the subject of remastering on the Knoppix site. The technique presented here is to remove packages via a kick list.

The kick list is an ordered list of my personal list of unwanted packages. It is by no means the final word, so be prepared for a bit of experimentation as you figure out what you do and don't want. Copy the list and place it inside the chrooted root directory. The order of packages listed has been carefully researched. Editing the text file is straightforward; packages near the top do not have any packages dependent upon them. However, they themselves may be depend on packages listed further down. When you're satisfied with the list of packages to remove, use the command:

bash-2.05# apt-get remove `cat ./mykicklist.txt`

An alternate command uses the purge switch to remove configuration files specific to that package:

bash-2.05# apt-get purge `cat ./mykicklist.txt`

It is recommended to begin by removing only a small subset of packages; start with a small kick list. Don't worry if you make a mistake — you can use the same list to replace those removed packages:

bash-2.05# apt-get install `cat ./mykicklist`

If you would like to remove packages based on their size, then try this to see where you should start:

bash-2.05# dpkg-query -W --showformat='${Installed-Size} ${Package}\n' |
	sort -nr | less

Running apt-get clean will free up disk space after you've finished removing packages. You can run the scripts to make your compressed file system once you're satisfied with your changes. The remastering FAQ has more tips on removing and cleaning your installation. Remember to unmount /proc when you've completed editing your packages.

Step 3: Altering the desktop configuration

To tell you the truth, I love the Knoppix desktop and user interface setups, so I didn't change mine very much. But there will be times when you will want to change those defaulted user account settings. You can change user configurations in one of two ways:

  • Use the command-line options at boot time to tell the OS to read configuration instructions from a device such as a diskette.

  • Alter the following distribution configuration files that are invoked at boot time:

    /etc/init.d/xsession /etc/init.d/knoppix-autoconfig
    /etc/init.d/knoppix-halt

Step 4: Running the scripts

You've fine-tuned the packages and configuration scripts. Now it's time to see your creation work. If you haven't already done so, now is the time to invoke createSwap.sh (if you need the swap) and to run the free command to make sure you have 1GB of RAM. You will now cycle through the following steps until you're satisfied with your creation:

  • Create the hard drive mounted version of the distribution by invoking testDistribution.sh.

  • Reboot the PC and test the prototyped distribution.

  • Make changes by rebooting back into your development environment.

    I don't recommend making configuration adjustments while in the prototype distribution environment, because it's too easy to get confused between the files you want to change and those that are temporary and in RAM.

  • Once you are satisfied with your creation, invoke createLiveCD_iso.sh to create the self-booting isoimage, knoppix.iso, which can then be burned to a CD-R.

Permanently Installing the Live CD Operating System onto the Hard Drive

Do you like what you've created? Would you like to put this on your machine permanently as a real installation? Guess what? You can! There is a utility on the Knoppix live-CD that will create and format a file system and a swap partition, and will mirror the CD's file system to the hard drive. What is especially cool about this process is that it will install a true home directory with the standard session logins that you'd find in any standard installation of Linux.

Running the knoppix-hdinstall command will invoke a script that asks several questions, including where you want to install the distribution, the swap partition, and the type of the filesystem (ext2, ext3, reiser, or xfs). It will ask for user accounts that you may want to install, along with a password. The script finally copies the entire compressed file system from the CD onto the hard drive. Take note: there are no questions about configuring graphics or selecting applications to installed. After all, that's the whole point to this CD!

Conclusion

This article has just scratched the surface of what the Knoppix live-CD can do. Unfortunately the only published books on this distribution are in German. Although I've referenced Linux as the primary development platform, it is quite reasonable to extend this development environment onto other UNIX and Unix-like environments, such as Solaris and FreeBSD.

References

Knoppix home site

man Pages

  • fdisk, the partition table manipulator for Linux
  • resize2fs, the ext2 file system resizer
  • mke2fs, to create a Linux second extended file system
  • losetup, to set up and control loop devices
  • lilo, to install the bootloader
  • lilo.conf, the lilo configuration file
  • mkswap, to set up a Linux swap area
  • dd, to convert and copy a file
  • free, to display the amount of free and used memory in the system
  • swapon, to enable devices and files for paging and swapping
  • swapoff, to disable devices and files for paging and swapping
  • mkisofs, to create a hybrid ISO9660 filesystem
  • chroot, to run a command or interactive shell with special root directory
  • screen, a screen manager with VT100/ANSI terminal emulation
  • apt-get, the APT package-handling utility

Robert Bernier is the PostgreSQL business intelligence analyst for SRA America, a subsidiary of Software Research America (SRA).


Return to the Linux DevCenter.


Have a question about Robert's tips, tricks, or tools? Ask him here.
You must be logged in to the O'Reilly Network to post a talkback.
Post Comment
Full Threads Oldest First

Showing messages 1 through 12 of 12.

  • Customising ClusterKnoppix 3.6
    2006-04-18 11:25:17  anie [Reply | View]

    ClusterKnoppix is just another version of Knoppix with embedded OpenMosix but the above method doesnt seem to work out, plz help
  • Tomcat
    2004-04-28 03:51:55  gianfranco [Reply | View]

    Hi Robert,

    I've costumazed my knoppix LiveCd by using your howto. Now I have a question for you. Do you know how I can configure and run Tomcat web server in my liveCd?

    thank you
    • Tomcat
      2004-04-28 04:09:56  author_robert [Reply | View]

      You need to configure tomcat prior to committing it to the CD. Here's a snippet of a script that I wrote for installing PostgreSQL onto my own knoppix CD. It is part the standard Debian, init script except that it copies the database cluster over to the RAM drive so it can become writable after the CD has loaded the OS

      ##########################################################################
      # code added by Robert Bernier, December 2003
      #
      if [ -h /var/lib/postgres/dumpall/unknown/psql ]; then
      echo -n Replacing symbolic links with hard links for PostgreSQL/knoppix adaption; ech
      o
      rm -rf /var/lib/postgres
      cp -Lfr /KNOPPIX/var/lib/postgres /var/lib/
      chown -R postgres:knoppix /var/lib/postgres/data
      else
      echo This is not a knoppix CD
      fi
      #
      ##########################################################################
      • Tomcat
        2004-04-30 07:16:43  gianfranco [Reply | View]

        Ok, I see. Now I try to do it.

        Thank you very much.
  • Morphix
    2004-01-10 20:14:10  anonymous2 [Reply | View]

    This is all well and good, but... Morphix (http://morphix.sourceforge.net/) is a LiveCD distro that makes creating custom LiveCDs much, much easier.
  • mount: you must specify the filesystem type
    2003-12-27 22:04:58  anonymous2 [Reply | View]

    You instruction
    # mount /dev/loop0 /mnt/floppy/
    fails with:
    mount: you must specify the filesystem type

    What type should I use for a loop device?

    Patrick
    p at patrick.net
    • mount: you must specify the filesystem type
      2003-12-30 12:10:00  anonymous2 [Reply | View]

      yes you have to pass an option to the mount command telling it to mount it as the loopdevice. type this

      mount -o loop /dev/loop0 /mnt/floppy

      zaeem at linux dot net dot pk
      • mount: you must specify the filesystem type
        2005-04-03 21:11:56  Johncc [Reply | View]

        Doesn't seem to work for me:

        root@on6jc:/cd# mount -o loop /dev/loop0 /mnt/floppy/
        mount: you must specify the filesystem type

        (the losetup was accepted without problem)

        Also, there is no boot.img on the 3.7 Knoppix disk. I suspect it's the largest file - called KNOPPIX. (that's the one I losetup'd)

        John
  • Troubleshooting
    2003-12-22 14:32:00  anonymous2 [Reply | View]

    I pretty much followed your instructions but hit two
    problems (I'm using Knoppix 3.3-2003-11-19):
    1) I could not make the race condition go away for /dev/null. I did not understand which partition we should mount with the option nodev. Finally, I decided to boot my own debian and make the customizations on the remastered directory and the problem went away.
    2) After all customizations, I decided to create the compressed image. It did build it, however, the boot sequence fails when trying to read the compressed image. I suspect it may be a create_compressed_fs version problem. I tried then to recompile create_compressed_image and the cloop module on my debian. Interestingly I could not mount the image on the 3.3 knoppix disk but I was able to mount compreesed images produced with my own create_compressed_fs. Anyone with similar problems? I think we may need to customize miniroot.gz to contain a cloop.o that matches create_compreesed_fs..
    • Troubleshooting
      2004-02-11 11:27:14  seqb [Reply | View]

      The article has a mistake. The partition should be mounted withOUT "nodev", not with it as said in the article. At least, when I did "mount -o remount,rw,nosuid -t ext2 /dev/hda3 /mnt/hda3", the "dev/null: Permission denied" errors did not happen after "chroot /wherever/remaster".

      Brent
  • An other better product is PCLinuxOS
    2003-12-16 11:08:56  anonymous2 [Reply | View]

    Go to PCLinuxonline.com and find the new livecd from Texstar based on Mandrake 9.2 with kde3.1.4 and other goodies.
    Also see the discussion forum.

    PCLinux
  • article
    2003-11-26 20:13:38  anonymous2 [Reply | View]

    Excellent documentation, typical of what have come
    to expect from O'Reilly sourcing.

    Once have extra Gentoo setup using user-mode
    kernel, "linux inside linux" this tutorial is a must 4 me.

    Thank you, should have looked here 1st.

    Best, - R


Tagged Articles

Post to del.icio.us

This article has been tagged:

knoppix

Articles that share the tag knoppix:

True Stories of Knoppix Rescues (13 tags)

Using and Customizing Knoppix (11 tags)

View All

linux

Articles that share the tag linux:

Managing Disk Space with LVM (74 tags)

Use Your Digital Camera with Linux (60 tags)

mdadm: A New Tool For Linux Software RAID Management (59 tags)

Asterisk: A Bare-Bones VoIP Example (43 tags)

View All

livecd

Articles that share the tag livecd:

Building an OpenBSD Live CD (22 tags)

Using and Customizing Knoppix (6 tags)

A Network Administrator's Best Friend: BartPE (4 tags)

Feather Linux: The Swiss Army Knife of LiveCDs (2 tags)

Building a Web Cluster with FreeSBIE (2 tags)

View All

howto

Articles that share the tag howto:

Rolling with Ruby on Rails (258 tags)

From Weblog to CMS with WordPress (98 tags)

Top Ten Digital Photography Tips (92 tags)

Top Ten Mac OS X Tips for Unix Geeks (79 tags)

View All

technology

Articles that share the tag technology:

What Is Web 2.0 (632 tags)

What Is a Wiki (and How to Use One for Your Projects) (14 tags)

Remixing Culture: An Interview with Lawrence Lessig (13 tags)

Inventing the Future (13 tags)

Stewart Butterfield on Flickr (10 tags)

View All

Sponsored Resources

  • Inside Lightroom
Advertisement

Sponsored by:

O'Reilly Media

©2009, O'Reilly Media, Inc.
(707) 827-7000 / (800) 998-9938
All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.
About O'Reilly
Academic Solutions
Authors
Contacts
Customer Service
Jobs
Newsletters
O'Reilly Labs
Press Room
Privacy Policy
RSS Feeds
Terms of Service
User Groups
Writing for O'Reilly
Content Archive
Business Technology
Computer Technology
Google
Microsoft
Mobile
Network
Operating System
Digital Photography
Programming
Software
Web
Web Design
More O'Reilly Sites
O'Reilly Radar
Ignite
Tools of Change for Publishing
Digital Media
Inside iPhone
O'Reilly FYI
makezine.com
craftzine.com
hackszine.com
perl.com
xml.com

Partner Sites
InsideRIA
java.net
O'Reilly Insights on Forbes.com