This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: System Administration

Build your own ultimate boot disc

By Kurt Edelbrock on June 25, 2008 (4:00:00 PM)

Share    Print    Comments   

You turn on your trusty old Linux box, and things are going well as you pass through the boot loader, until the disk check reveals that your hard drive partition table is corrupt, and you are unable to access your machine. You need a good rescue disk -- and the best way to get one is to create your own.

You can customize an Ubuntu 8.04 Hardy Heron live CD to make a good bootable utilities disk by adding and removing packages from the standard installation. Specifically, you can remove most of the Ubuntu applications and install antivirus, a partition recover tool, a few disk utilities, and a rootkit checker, among other things. I'm going to create the live CD within an Ubuntu installation, but the directions should work for most Debian-based operating systems, and can be easily ported elsewhere. This guide largely follows the community documentation article on the Ubuntu customization process, which is a good place to look for more advanced information and troubleshooting support, while the livecdlist.com wiki is the best place to look for customized directions.

To create and use the Ubuntu-based boot CD, you'll need a computer with at least 3GB of disk space and 512MB RAM. 1GB of swap is recommended, though I did it with 512 MB.

Create the live CD environment

The first step is to download the Ubuntu 8.04 live CD ISO file for your system type. You can get it from the Web site, or you can use wget on the command line:

wget -v http://releases.ubuntu.com/hardy/ubuntu-8.04-desktop-i386.iso

To work with the image, you'll need to install a few packages to support the squashfs filesystem format, and mkisofs, the utility to create ISO images. On Ubuntu, you can install them with the command sudo apt-get install squashfs-tools mkisofs.

Now, load the squashfs module, then copy, mount, and extract the contents of the ISO file in order to customize the contents:

sudo modprobe squashfs mkdir rescue mv ubuntu-8.04-desktop-i386.iso rescue cd rescue mkdir mnt sudo mount -o loop ubuntu-8.04-desktop-i386.iso mnt mkdir extract-cd rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd mkdir squashfs sudo mount -t squashfs -o loop mnt/casper/filesystem.squashfs squashfs mkdir edit sudo cp -a squashfs/* edit/

You'll want to customize the CD in a chroot environment. Chroot changes the root directory of the environment, allowing you to access the files and applications inside the CD directly, which you must do in order to use tools like apt-get. In order to use a network connection inside chroot, which you'll probably want to do to add new packages, you'll need to copy in the hosts and resolv.conf files to configure your network settings. You can achieve this with the following:

sudo cp /etc/resolv.conf edit/etc/
sudo cp /etc/hosts edit/etc/

Once you've completed these steps, you can start to work inside the live CD. Mount the live CD to the edit/dev mountpoint, then change your root directory into the newly mounted volume. You'll need to mount /proc and /sys volumes to work with the kernel, and export your settings to avoid locale and GPG problems later on:

sudo mount --bind /dev/ edit/dev sudo chroot edit mount -t proc none /proc mount -t sysfs none /sys export HOME=/root export LC_ALL=C

Free space by removing unneeded packages

You can configure the packages that are included with the live CD using apt-get or Aptitude. You'll want to free up some space to add the rescue applications; even though the data is compressed, all of it needs to fit on a 700MB CD or on a higher-capacity DVD. You can remove packages and applications that aren't useful for the recovery. I chose to remove the OpenOffice.org suite, the GNOME games set, Ekiga, Ubiquity, Evolution, and the GIMP, saving me around 200MB. If you are comfortable without a command-line environment, you might want to get rid of GNOME and Xorg; if you do that, you need not install GParted and the other graphical tools in the next section. In any case, the goal is to get rid of large applications. To sort all of the installed packages by size, run the following command in the chrooted environment:

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

You can use apt-get to remove a package. Use it with the --purge argument to get rid of configuration files. The sudo command won't work in the chroot, and therefore should be omitted:

apt-get remove --purge package-name

Add rescue applications

Once you have removed all of the unneeded applications from the live CD you can start to add rescue and recovery applications. Generally, rescue CDs include a variety of disk utilities and security tools, as well as networking tools to find support and access outside machines. You may not want all of the applications I mention, and you can add some that I don't. This is your personal boot CD, and should be configured as you see fit. For ideas about what to include on your CD, you might want to check out some of the prebuilt rescue distributions mentioned in the sidebar.

You can install packages from the repositories using apt-get, but you must add the multiverse repository to your /etc/apt/sources.list file:

deb http://us.archive.ubuntu.com/ubuntu/ hardy main multiverse deb-src http://us.archive.ubuntu.com/ubuntu/ hardy main multiverse

A disk partition tool is the staple of a mature boot disk. Fortunately, the Ubuntu live CD comes with GParted, the GNOME Partition Editor, so adding a package isn't required. If you chose to forgo a graphical environment, you should make sure that parted is installed instead to handle partition tables from the command line. If you accidentally delete a partition, installing a program like testdisk can help you recover it, as well as provide a few other basic disk tools. If you are using the ext2 filesystem type and you accidentally delete a file, you'll find the e2undel package helpful in recovering it. If you need to copy an entire partition from a dying disk, or just want to make a backup, partimage is the way to go. You can also use it to restore a partition with a previously made backup.

If you plan to use this disc with Windows machines, you will want to install antivirus and rootkit tools. Clamscan provides quick and easy virus scan with a command-line-based update tool. Chkrootkit is a scanner to find and remove rootkits that could be hiding in your computer. You can use sleuthkit to conduct analysis of your filesystem and browse through hidden files.

After you finish adding packages, clean up your temporary data and unmount the environment:

apt-get clean rm -rf /tmp/* rm /etc/resolv.conf umount /proc umount /sys exit sudo umount edit/dev

Now, regenerate the manifest (which is basically a list of installed packages) and copy in into the correct directory:

chmod +w extract-cd/casper/filesystem.manifest sudo chroot edit dpkg-query -W --showformat='${Package} ${Version}\n' > extract-cd/casper/filesystem.manifest sudo cp extract-cd/casper/filesystem.manifest extract-cd/casper/filesystem.manifest-desktop sudo sed -i '/ubiquity/d' extract-cd/casper/filesystem.manifest-desktop

Compress the filesystem to squeeze it onto a disc:

sudo rm extract-cd/casper/filesystem.squashfs sudo mksquashfs edit extract-cd/casper/filesystem.squashfs -nolzma

And finally, create the ISO file:

cd extract-cd sudo mkisofs -r -V "$IMAGE_NAME" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../ubuntu-8.04-desktop-i386.iso

Once the image file is created, you need to burn it to a disc. You can do that pretty easily with K3b or Brasero. If you want, you can do it from the command line:

cdrecord dev=/dev/cdrom ubuntu-8.04-desktop-i386.iso

Once the CD is finished burning, you should be able to put it into your optical drive and boot into the environment you just created.

This should give you more than enough information to start building your ultimate custom rescue CD. Add the packages and tools you need, and hopefully you'll never be at a loss the next time your computer has a problem during startup.

Kurt Edelbrock is a technology journalist, blogger, and university student. He writes for a variety of open source publications, and serves as a technical consultant for a large public university.

Share    Print    Comments   

Comments

on Build your own ultimate boot disc

Note: Comments are owned by the poster. We are not responsible for their content.

Build your own ultimate boot disc

Posted by: Anonymous [ip: 76.171.185.195] on June 25, 2008 04:40 PM
Kurt,

Thanks for this excellent article on building a boot disc. I'll try this out this weekend.

Ramesh
<a href="http://www.thegeekstuff.com">The Geek Stuff</a>

#

Build your own ultimate boot disc

Posted by: Anonymous [ip: 76.224.73.28] on June 25, 2008 05:31 PM
You have a typo - that's boot loader, not book loader.

#

Re: Build your own ultimate boot disc

Posted by: Joe Barr on June 25, 2008 06:44 PM
Thanks, fixed now.

#

Build your own ultimate boot disc

Posted by: Anonymous [ip: 67.207.134.15] on June 25, 2008 07:06 PM
Another typo, just a note - Most CD's aren't 700GB :P

"all of it needs to fit on a 700GB CD or on a higher-capacity DVD"

#

Re: Build your own ultimate boot disc

Posted by: Joe Barr on June 25, 2008 08:24 PM
Thanks again! Fixed.

#

Build your own ultimate boot disc

Posted by: Anonymous [ip: 71.255.3.8] on June 25, 2008 07:37 PM
The above poster is correct,CD's are MB not GB

#

Build your own ultimate boot disc

Posted by: Anonymous [ip: 70.114.150.78] on June 25, 2008 11:20 PM
"If you are comfortable without a command-line environment..."

I believe this should read "If you are comfortable in a command-line environment..." or "If you are comfortable without a graphical environment...", otherwise a person who is uncomfortable using bash might inadvertently remove GNOME and Xorg and end up with a live disk that they don't know how to use.

#

Build your own ultimate boot disc

Posted by: http://tnetech.net on June 26, 2008 03:17 AM
This looks like an excellent guide, I will definitely be giving this one a go on the weekend also!

http://tnetech.net

#

which filesystem.squashfs on ubuntu-8.04-alternate-i386.iso ?

Posted by: Anonymous [ip: 194.231.78.1] on June 26, 2008 07:26 AM
I tried it with the alternate cdrom but did not find a "filesystem.squashfs".

(Posting a comment needs JavaScript enabled - why?)

#

Try the PC Linux OS way to do this

Posted by: Anonymous [ip: 12.47.15.38] on June 26, 2008 03:10 PM
Here's a webpage showing how to do this on PC Linux OS (PCLOS):
http://www.pclinuxonline.com/wiki/RemasterLiveCD

4 easy steps:
1) Download and burn PCLOS:
http://www.pclinuxos.com/index.php?option=com_ionfiles&Itemid=28
2) Install PCLOS:
http://docs.pclinuxos.com/HomePage
3) Configure it the way you want it(remove and install software, change backgrounds, etc.)
4) at the command line as root issue the command:
# mklivecd new.iso

#

Build your own ultimate boot disc

Posted by: Anonymous [ip: 151.204.98.163] on June 26, 2008 05:16 PM
Hi Kurk
Does this boot disc will work to boot my windows vista opreation system, I have been using this system for 5 months but honestly i don't like how it works and i want to use Linux but unfortunately i don't have a CD to errase all vista system. Please help me
Crywolf

#

Build your own ultimate boot disc

Posted by: Anonymous [ip: 76.172.224.49] on June 30, 2008 01:20 AM
In Ubuntu Hardy (the example distro referred to in the article) there is no mkisofs available, even in the repos. It seems that this has been replaced by a new utility "genisoimage", whose description is very similar to the old mkisofs. However, when I got to the iso image generation step, simply substituting genisoimage for mkisofs did not succeed. Could you suggest a suitable command-line for the last step, using genisoimage?

#

Re: Build your own ultimate boot disc

Posted by: Anonymous [ip: 76.172.224.49] on June 30, 2008 06:04 PM
After further checking - mkisofs is apparently still there, but called by genisoimage, which is maybe why there is no mkisofs package as such.

But when I use the command-line with mkisofs I get the same error, from genisoimage, complaining there is no [pathspec]. Any clues?

#

Build your own ultimate boot disc

Posted by: Anonymous [ip: 80.137.211.146] on June 30, 2008 06:42 PM
at this line: sudo mkisofs -r -V "$IMAGE_NAME" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../ubuntu-8.04-desktop-i386.iso
a . at the end is missing
it should look like this: sudo mkisofs -r -V "$IMAGE_NAME" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../ubuntu-8.04-desktop-i386.iso .

#

Re: Build your own ultimate boot disc

Posted by: Anonymous [ip: 76.172.224.49] on June 30, 2008 09:12 PM
Thanks! I thought I was crazy, but I was coming to the same conclusion......

#

Re(1): Build your own ultimate boot disc

Posted by: Anonymous [ip: 76.172.224.49] on June 30, 2008 10:11 PM
Yes - that did it! Now I just wonder why no-one mentioned it earlier in the Comments......

#

Only an idiot would "Build your own ultimate boot disc" in this way.

Posted by: Anonymous [ip: 69.138.175.116] on July 03, 2008 09:00 PM
Much easier way, Remastersys Backup automates the process for you and its pretty old and famous so i don't know how this person didn't find out about it while doing his research

#

Build your own ultimate boot disc

Posted by: Anonymous [ip: 213.213.43.104] on July 04, 2008 01:57 PM
Thanks for the guide and
Thanks to commenter that said to add '.' !

#

Automated Remastering Programs

Posted by: Anonymous [ip: 70.226.193.198] on July 05, 2008 03:03 AM
Reconstructor is a good option, although it will not play nice with hardy as of yet. Remastersys is a good option. UCK is also another option. Revisor is an option if your using Fedora.

btw, I believe your disc will spit out errors if you check it, since you didn't update the md5sum.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya