Search:  
Gentoo Wiki

HOWTO_Livecd_From_Scratch

This is eventually going to be a comprehensive howto for a new way of making liveCDs. The idea behind it, or the process, already works. But there are in between details that might need tweaked. So feel free to make suggestions.

Instead of starting w/ a stage, buidling your own custom system, and turning it into a livecd, you do not actually need to install gentoo nor do you need to boot into a gentoo system. If you notice though we're kindof installing gentoo in a very different way but the final product wont have portage and will be much smaller than if you were to start w/ a stage. If you already have gentoo, skip ahead to locals.

Step 1 - Get Gentoo
All you really need is emerge.
Download a stage3 and portage-latest.

cd where you want gentoo (it doesn't need to have its own partition)
tar xvjpf stage3-*.tar.bz2
tar xvjf portage-lattest .tar.bz2 -C usr/
mount -t proc ./proc
mount --bind /dev ./dev
mount /future livecd ./livecd (you can do this latter at step 3)
cp -L /etc/resolv.conf gentoo/etc/resolv.conf
chroot gentoo
env-update
source /etc/profile
emerge portage
emerge -sync
emerge cdrtools (needed latter)
chose your profile - ln -snf /usr/portage/profiles/default-linux/x86/2006.1 /etc/make.profile

Now you should have a basic gentoo chroot from which to "emerge" your liveCD. All you need to do is set your locals (so all the language packs don't get installed and take up room).

nano /etc/local.gen
(for instance)
en_US ISO-8859-1
en_US.UTF-8 UTF-8

local-gen
cp /usr/share/zoneinfo/timezone /etc/localtime


Step 2 - Make.conf Make.conf can of course be optimized for size. One of the reasons gentoo is such a useful tool for making a liveCD is that the equivalent system on another distro (such as debian) would be much larger.

The first is the gcc optimization class for CFLAGS. -Os means it's size optimized. It should look something like this:
CFLAGS="-Os -march=i686 -pipe

The next, and probably most important, is your use variable. Although, slightly redundant, here's what I used for the majority of the process: USE="livecd minimal -doc -java -arts -kde -cjk -eds -emacs -gstreamer -maildir -mailwrapper -mbox -oss -test -selinux -gnome -bonobo -berkdb -readline -python -perl browserplugin -motifs -tiff -eds -cups -sdl -pam -gpm -nls-quicktime alsa"

Of course this isn't going to be a universal use flag. For instance if you were making a gentoo module, you'd want to remove -gnome -bonoboo temporarily.

And finally, features. It the ability to remove man pages, docs, and info. You can leave in man pages, etc, if you want to but taking them out will save some space.

FEATURES="noman nodoc noinfo buildpkg"
PKGDIR="/usr/local/portage/32"

It also might save you some hair to make it buildpkg. If something goes wrong you wont have to wait around for it to download and compile all over again.

Step 3 - Base System The livecd is going to be bootable from the hardrive and will use the slax precompiled kernel. So first make a partition for it to be on.

Then Download/untar the kernel from linux-live into your livecd. http://ftp.linux.cz/pub/linux/slax/kernel/linux-kernel-2.6.16-i486-1.tgz

(now make sure you have that partition mounted at gentoo/livecd)

A base system, I have found through trial and error, contains these minimal packages:

shadow
pam
debianutils
grep
which
util-linux
procps
USE=bzip2 tar
module-init-tools
gcc
coreutils
bash
glibc
baselayout
gawk
net-tools
zlib
sed
findutils
kbd
iputils
dhcp
dhcpcd
wget
udev
psmisc
hotplug

On top of these you might as well add a basic text editor such as nano..

Some of these are probably dependents of others, and hotplug might no longer be required, but if you run the preceding emerge command it'll create a basic system.

USE="bzip2" ROOT=/livecd emerge shadow pam debianutils grep util-linux procps tar module-init-tools gcc coreutils bash glibc baselayout gawk net-tools zlib sed findutils kbd iputils dhcp dhcpcd wget hotplug udev psmisc nano

Step 4 - Make it bootable Now you need to be able to boot in your system. (see http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?full=1#book_part1_chap8)

cp -L /etc/resolv.conf /livecd/etc/resolv.conf
chroot /livecd

Edit fstab.
/etc/conf.d/net
rc-update add net.eth0 default
passwd (here I found it wouldn't let me do a pssword; it was like enter were held down. Upon booting though I found there wasn't a password and passwd worked form in the system)
depmod (here you might have to temporarily symlink if you get an error like this:

WARNING: Couldn't open directory /lib/modules/2.6.12-oci6.mdk-i586-up-1GB: No such file or directory FATAL: Could not open /lib/modules/2.6.12-oci6.mdk-i586-up-1GB/modules.dep.temp for writing: No such file or directory

Just ln -s /lib/modules/2.6.16 /lib/modules/2.6.12-oci6.mdk-i586-up-1GB

update-modules (there is no System.map. This doesn't seem to cause any problems though)

Set up grub to boot vmlinuz

One last thing: Make sure there is a /dev/console and /dev/null. If not it'll complain about being able to open an initial console.
mknod -m 600 dev/console c 5 1
mknod -m 666 dev/null c 1 3

At this point you should be able to boot into your system. It presumably has one application; a text editor and all the basic utilities you should need (cp, tar, etc). Don't be too tempted to emerge xorg and a bunch of applications from your conferrable distro. You could go ahead and emerge simple apps though, if you wanted them to be available universally w/o optional modules, such as links. You need to boot into the system in order to use unionfs though. If your os has unionfs technically you could do all this from it and boot your liveCD when you want to configure the system.

When you first boot you'll probably notice that the Internet isn't working. /etc/init.d/net.eth0 should have already been started but you need to run, dhcpcd

I made a zcustom script in /etc/init.d/ and added it to default;

  1. /bin/bash


dhcpcd

rc-update add zcustom default

Step 5 - Install Applications This is the part where you install your software, customize your system, etc.

To install further software you need to chroot back into your gentoo installer.
mount /dev/hdXX /mnt/gentoo
mount -t proc none /mnt/gentoo/proc
mount --bind /dev /mnt/gentoo/dev
mount --bind / /mnt/gentoo/livecd (this is the important one; we're installing kind of recursively)
chroot /mnt/gentoo

(you technically don't have to have your gentoo installer on its own partition, so if that's the case just move the mounts relative to where it's located)

//Before you start installing programs think about what you want to modularize. You might want the ability to boot into either gnome/kde or xfce4 (or an even lighter windows manager), for instance, depending on how much RAM you have available (at home maybe you have 2G but at work/school only 256 ;). If that's the case it'd be best to install xorg-x11 (either as a module or in the actual system) and install gnome/xfce4 from that.

To make a module you basically union /livecd=ro and /modules/your_module together, point emerge to /modules/your_module, and let it install normally.

mkfs /modules/your_module
mount -t unionfs -o dirs=/modules/your_module:/livecd=ro none /modules/your_module

ROOT=/modules/your_module emerge stuff

xorg
The slax kernel already has all the drivers you need, and you cant build anymore anyway (no kernel source), so when configuring xorg make sure to set VIDEO_CARDS (this can be placed in make.conf). If you want certain graphics card support all you need are the packages xf86-video-CARD. For instance don't emerge nvidia-drivers or ati-drivers; instead get xf86-video-nv (the driver is going to be "nv" not "vidia) and xf86-video-ati. You'll probably want vesa as well.

libgcc doesn't get put in /usr/lib automatically so you'll have to symlink it from /usr/lib/gcc/kernel/version/libgcc_s.so.1
There ae other's like this in /usr/lib/gcc/... that you may run across, jsut symlink them.
You'll need to modprobe psmouse to get the mouse working.
If your mouse doesn't work it's a problem with xorg.conf.

Step 6 - Create the livecd Download and extract linux live scripts somewhere; http://www.linux-live.org/ .

runme.sh and config need to be edited to get everything working right. In config add dev to MKMOD. For modules you need to add a completely new variable, MKMODD, which will parallel mkmod. For instance if you have two modules, it'd look like

# list of directories which will be modularized
# You may add 'dev' inthere in the case your distro doesn't have udev installed
MKMOD="bin etc home lib opt root usr sbin var"

MKMODD="module1 module2"



In ./runme.sh, right after this bit,

for dir in $MKMOD; do
   if [ -d $ROOT/$dir ]; then
     echo "base/$dir.mo"
     create_module $ROOT/$dir $CDDATA/base/$dir.mo -keep-as-directory
     if [ $? -ne 0 ]; then exit; fi
   fi
done

add

for dir in $MKMODD; do
  if [ -d /modules/$dir ]; then
    echo "module/$dir.mo"
    create_module /modules/$dir $CDDATA/optional/$dir.mo #-keep-as-directory
    if [ $? -ne 0 ]; then exit; fi
  fi
done



Now all you need to do is create ./kernel-modules/2.6.16 inside linux-live and copy squashfs.ko/unionfs.ko to it.

You should have cdrtools emerged in your gentooinstaller so just run ./runme.sh and it'll create an iso for you.

If at any point these instructions didn't work, let me know, because I might have left out something. I plan to go through them again and work on the document (especially add formatting for code. I've never used wiki much so I'm not familiar with all this stuff).

Links TIP Some LiveCD related tips
http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?full=1

todo When booting the liveCD slax puts a little penguin at the top and presumable sets a "resolution" but this interferes w/ udev's coldplug utility that should make the screen look all nice (as it does when it's booting the harddrive).

Retrieved from "http://www.gentoo-wiki.info/HOWTO_Livecd_From_Scratch"

Last modified: Thu, 04 Sep 2008 03:53:00 +0000 Hits: 853