# Howto kickstart gentoo

## hadfield

Introduction

In this how-to I aim to demonstrate kickstarting/jumpstarting gentoo installs. I think genstart is a suitable nickname for the process  :Wink: . I did this mostly as a learning project for myself. If you have any suggestions for improvements to this process, let's hear them!

If you don't already know what kickstart/jumpstart is, it is a way to install Redhat/Solaris on a workstation. I'm only familiar with Redhat's Kickstart but I assume Jumpstart is nearly identical. You first need a kickstart server, this contains all of the data necessary for the install, including workstation specific configuration files which contain information as to which applications to install and how to partition the hard drive. Then when you want to kickstart a machine, insert the kickstart disk, reboot and voila, 30-60 minutes later you have a newly installed Redhat linux machine. This is most useful when installing or upgrading Redhat on a large number of workstations. It also speeds up recovery time after a harddrive failure on one of your workstations.

Genstart works by mounting an NFS root filesystem (from the Genstart server) while booting and then uses GLIS to install gentoo on the system once booted.

If you don't already know what GLIS is, it stands for Gentoo Linux Install Script and can be used to perform automated installs of Gentoo. A dialog based install program is on the way but currently you have to make all configurations manually in the GLIS config file. Glis can be found at: http://glis.sourceforge.net Although there's not much for documentation on the web site, the default config file that ships with GLIS has every possible option documented reasonably well.

GLIS is still very young, the last (and only) official release was 0.1, and you shouldn't fully trust it to install on a system with important data. However, when kickstarting (genstarting) a workstation you generally plan on trashing everything that's there anyway, so GLIS's instability doesn't really matter too much for this purpose.

Note: Currently (January 18, 2004) you will need the latest glis snapshot for genstart. http://glis.sourceforge.net/release/beta/

Prerequisites

This document assumes some basic understanding of DHCP, the linux boot process, and NFS.

Genstart Server Setup

Setup the DHCP Server

emerge dhcp and configure it appropriately to your system. Here's an example dhcpd.conf that I use.

```
# Sample configuration file for ISCD dhcpd

# with boot menu

# Some general options

ddns-update-style             ad-hoc;

default-lease-time            21600;

max-lease-time                21600;

use-host-decl-names           on;

# Bootp options

allow booting;

allow bootp;

# Network Options

option subnet-mask            255.255.255.0;

option broadcast-address      192.168.0.255;

option routers                192.168.0.1;

option domain-name-servers    192.168.0.1;

option domain-name            "yourdomain.com";

option log-servers            192.168.0.1;

next-server                   192.168.0.1;

shared-network WORKSTATIONS {

    subnet 192.168.0.0 netmask 255.255.255.0 {

   range dynamic-bootp 192.168.0.101 192.168.0.200;

    }

}
```

Note: DHCPD needs CONFIG_PACKET and CONFIG_FILTER activated in the kernel to work.

Setup the TFTP Server

emerge app-admin/tftp-hpa.

I'm using xinetd to run tftpd. My /etc/xinetd.d/tftp file looks like this: 

```

service tftp

{

        socket_type = dgram

        protocol    = udp

        user        = root

        server      = /usr/sbin/in.tftpd

        server_args = -c -s /genstart/tftpboot

        port        = 69

        wait        = yes

        only_from   = 0.0.0.0

        disable     = no

        per_source  = 11

        cps         = 100 2

}

```

However, if you plan on running a standalone tftpd server put the following in /etc/conf.d/in.tftpd:

```

INTFTPD_PATH="/boot/tftpboot"

INTFTPD_USER="nobody"

INTFTPD_OPTS="-u ${INTFTPD_USER} -l -vvvvvv -p -c -s ${INTFTPD_PATH}"

```

Create the tftpboot directory:

```
mkdir -p /genstart/tftpboot/
```

Configure NFS

If you haven't already then emerge nfs.

Configure your nfs exports file to export the root genstart directory used by the workstation you plan on genstarting. To /etc/exports, add the following:

```
/genstart/root   192.168.0.0/255.255.255.0(rw,no_root_squash,async)
```

Configuring the Client Files on the Server

I decided to generate my genstart root directory from the gentoo livecd as this is what GLIS is mostly tested with. It also has some cool autodetection stuff that might be useful.

Get the cloop livecd image

Mount your livecd and then mount the cloop image and copy it to your genstart root directory.

```

mkdir /genstart/root/

mount /mnt/cdrom

modprobe cloop file=/mnt/cdrom/livecd.cloop

mkdir /mnt/cloop

mount -r /dev/cloop /mnt/cloop

cp -Rp /mnt/cloop/* /genstart/root/

```

You'll need to add a few things to the /genstart/root/ folder to get it working for genstart. Add the following script to /genstart/root/etc/init.d/

```
cd /genstart/root/etc/init.d/

nano -w genstart

chmod a+x genstart
```

```

#!/sbin/runscript

depend() {

   after autoconfig

}

start() {

   ebegin "Starting genstart"

        cd /glis

        ./glis 2 3 4 5 6 7 8 9 10 11 config

   eend ${?}

}

```

The autoconfig init script has 'after *' as it's dependancy, so you'll need to modify it so that genstart has no problems running last. I modified /genstart/init.d/autoconfig like by changing the line (if anyone knows of a better way to do this please let me know):

'after *' (line 63)

to:

'after metalog net.log urandom'

Make a link in the default runlevel folder:

```
ln -s /etc/init.d/genstart /genstart/root/etc/runlevels/default/genstart
```

Although this link will be broken for the moment, it will be fine once /genstart/root/ is mounted as root on the workstation to be kickstarted.

Fetch glis and untar it to /genstart/root/:

```
wget http://glis.sourceforge.net/release/beta/glis-20040118.tar.bz2

tar jxvf glis-20040118.tar.bz2 -C /genstart/root/
```

You'll also need to create the /mnt/gentoo/ folder as it doesn't appear to be in the cloop image on the cd:

```
mkdir /gentstart/root/mnt/gentoo
```

At this point perhaps you should grab a stage tarball and place it somewhere under /genstart/root/. Remember to configure the TARBALL_LOCATION in your glis config file.

You might want to modify or remove the /genstart/root/etc/motd file as well.

Tweaking glis

We have to skip the first step of the glis install because it will attempt to restart your network connection. Since that's all the machine has it won't be able to bring the network back up again (Note that the genstart script above skips step 1). So you'll need to add this file to /genstart/root/glis if you plan on mounting any nfs partitions. It will bring up the portmap program.

cd /genstart/root/glis/

nano -w 020-pre.sh

#!/bin/bash

start-stop-daemon --start --quiet --exec /sbin/portmap

When GLIS executes step 2 (the partitioning/formatting/mounting step) you may get some warnings from parted about not being able to determine if the partitions are mounted, but these can be safely ignored (as long as you haven't mounted any partitions from the drives you wish to modify).

Now set the options you want in your glis config file. This is no easy task the first time you do it, in a way it's like going through the entire install process again. The config file is where you'll set your network devices, partition table, the kernel you wish to use, any drivers, any additional applications you want installed, and any tweaks to make.conf.

Building a kernel suitable for the NFS boot

This was the most difficult part for me. After hours of painful kernel config modifications I decided to use the kernel config that ships with the livecd. To get the kernel config used by the livecd you'll boot to the livecd and copy it from /proc/config.

When you build your kernel make sure you have the following enabled (this is from http://www.gentoo.org/doc/en/altinstall.xml#doc_chap5):

```

- Under "Networking Options":

[*] TCP/IP networking

[*] IP: kernel level autoconfiguration

[*] IP: DHCP support

[*] IP: BOOTP support

- Under "File systems --> Network File Systems":

<*> NFS file system support

[*] Provide NFSv3 client support

[*] Root file system on NFS

```

Notes:

If you don't have kernel level autoconfiguration enabled you won't see the dhcp, bootp, or root file system on NFS options in make menuconfig.

Don't forget to include support for the network devices you use as well. I built them directly into the kernel instead of as modules, I'm not sure if this was necessary though.

I also included support for devfs in the kernel.

Now that you've finished compiling your kernel, copy the bzImage file to /genstart/tftpboot/vmlinuz. This is the kernel image that the workstations to be genstarted will use.

If you built your kernel with modules be sure to copy your modules directory into the genstart root

```
cp -Rp /lib/modules/"kernel-version"/ /genstart/root/lib/modules/
```

Installing and Compiling Grub

Grub will need to be compiled with some special configure options so you will need to compile grub yourself (can't use emerge). This is relatively easy though. First get the grub sources.

```

emerge -f grub

mkdir /genstart/grub

cd /genstart/grub

tar zxvf /usr/portage/distfiles/grub-0.93.tar.gz
```

As I found out after quite some time, an unpatched version of grub won't compile with gcc 3.3 on most systems. So, if you run into problems compiling grub edit the file stage2/fsys_reiserfs and remove the word `long' from line 115, it should read:

```
 __u32 j_mount_id;
```

I found this at: http://www.xs4all.nl/~lennartb/installdisk/node10.html

Your grub.conf should look something like this:

```

default 0

timeout 3

title Genstart (NFS)

dhcp

tftpserver 192.168.0.1

root (nd)

kernel /vmlinuz root=/dev/nfs nfsroot=192.168.0.1:/genstart/root ip=dhcp
```

Now build grub and install it to a floppy:

```

cd grub-0.93/ ./configure --enable-preset-menu=../grub.conf --enable-$net

make

cat stage1/stage1 stage2/stage2 > /dev/fd0
```

Use the --enable-$net, where $net represents the driver your network card uses, for every network card device driver you use in your network. This way you will be able to use a single genstart bootdisk for all of your workstations.

For more information on the --enable-$net option check the netboot/README.netboot file

Now start the services and add them to your default run level:

```

/etc/init.d/dhcp start

rc-update add dhcp default

/etc/init.d/xinetd start

rc-update add xinetd default

/etc/init.d/nfs start

rc-update add nfs default
```

Note: If your running tftpd as a standalone server, replace xinetd with tftpd

Insert the newly created genstart disk into the workstation to be genstarted, reboot, and you should have gentoo installing in no time (well, about 2 or so days of compiling).

Final Notes

This setup assumes that all workstations will be configured exactly the same as it's only using a single glis config file. To enable workstation specific configurations you'll first need to modify dhcp to assign every workstation a hostname. Create a list of glis config files each named after the workstation hostnames. Then modify the genstart script above:

Replace the line ./glis 2 3 4 5 6 7 8 9 10 11 config

With ./glis 2 3 4 5 6 7 8 9 10 11 $HOSTNAME

I think I'd like to create an ebuild that will do all of this some day, but that day is not today.  :Wink: 

I'm still mostly just learning this stuff, and doing this was mostly a learning experience for me. If you have any suggestions on making this process better, more efficient, or more secure, let's hear them

I'd like to be able to boot off of the CD OR via the genstart server. I know you can do this with redhat's kickstart and I can see it being desirable in some cases.

References

http://www.gentoo.org/doc/en/ltsp.xml

http://www.gentoo.org/doc/en/altinstall.xml#doc_chap5

http://www.tldp.org/HOWTO/Clone-HOWTO/booting.html

----------

## agaffney

Wow, that looks pretty good. I'm going to have to put together another computer from spare parts just to try out this procedure. Or maybe I can run this on my Big Mouth Billy Bass <http://bigmouth.here-n-there.com/>  :Wink: 

----------

## Skywacker

modprobe cloop does not work so i tried to emerge cloop. that fails saying i need zlib built into the kernel. looking for something like that in make menuconfig, but I dont see anything. Help?

----------

## pjp

 *Skywacker wrote:*   

> that fails saying i need zlib built into the kernel. looking for something like that in make menuconfig, but I dont see anything. Help?

 If you are using a 2.6 kernel, I'm not sure.  What I've found suggests it should be automatic.

In earlier kernels, it appears to be under "Library routines."

----------

## hadfield

 *Skywacker wrote:*   

> modprobe cloop does not work so i tried to emerge cloop. that fails saying i need zlib built into the kernel. looking for something like that in make menuconfig, but I dont see anything. Help?

 

It should be under 'Library routines' in the 'make menuconfig' in 2.6 as well. I just checked mine and it's not there though. However, you can always edit your .config and set:

CONFIG_ZLIB_INFLATE=m

CONFIG_ZLIB_DEFLATE=m

They should be near the very end of the /usr/src/linux/.config file.

----------

## zend

can I use this kickstart 2005.1 ?

----------

## hadfield

I wouldn't. I doubt that the GLIS codebase will work with the 2005.1. I'd suggest you look into the new installer that's being developed. One of it's primary goals is to be used for automated installing, though I'm not sure how fulfulled that goal is so far.

It's actually possible to use the method above (slightly modified of course) to create a kickstart server and kickstart with the new installer.

HTH,

Scott

----------

