From Fedora Project Wiki

Stateless Linux - Stateless Linux Create Client Image

See Stateless Linux HOWTO

The canonical form of a client profile is an anaconda kickstart file. We are no longer using raw ext3 images or the utilities to install and update the raw ext3 image (stacaccli and slcosi).


For the purposes of this HOWTO, we will assume you are going to create stateless Fedora Core 6 images using DVD ISO images. Clearly if you have physical DVD media, then minor modifications will be necessary.

Mount (temporarily) the install media and import it into cobbler.

$> mkdir /tmp/FC6media
$> mkdir /tmp/F7media
$> mount -o loop FC-6-i386-DVD.iso /tmp/FC6media
$> mount -o loop F-7-i386-DVD.iso /tmp/F7media
$> cobbler import --name=FC6 --mirror=/tmp/FC6media
$> cobbler import --name=F7 --miror=/tmp/F7media
$> umount /tmp/FC6media
$> umount /tmp/F7media


Instantiating a profile for NFS clients

Before we can add a diskless profile to cobbler, we must instantiate the NFS root image so that we can create an initrd for diskless clients. Instantiation is performed by running anaconda.

$> mkdir /export/NFSroots/FC6
$> anaconda -G -m nfs://var/www/cobbler/ks_mirror/FC6 --rootpath=/export/NFSroots/FC6 --kickstart=/var/lib/cobbler/fc6-diskless.cfg
$> mkdir /export/NFSroots/F7
$> anaconda -G -m nfs://var/www/cobbler/ks_mirror/F7 --rootpath=/export/NFSroots/F7 --kickstart=/var/lib/cobbler/f7-diskless.cfg

Note there have been reports that the F7 NFS client instantiation may hang running gcj-dbtool. Killing it (repeatedly) allows the instantiation to complete.

The post-installation script within the kickstart configuration file will take a long time to run. Rest assured it will complete and when it does you have an instantiated image that NFS clients can mount as their root filesystem. Note the newly created root filesystem will be used to create an initrd for diskless clients and will also be used as a root filesystem for diskless clients.

NFS exporting the client OS image

We instantiated the NFSroot filesystem into /export/NFSroots/FC6, we need to export that filesystem so that diskless clients can mount their root filesystem. These commands will export the filesystem to the world, read-only.

$> echo '/export/NFSroots/FC6 *(ro,no_root_squash,async)' >> /etc/exports
$> echo '/export/NFSroots/F7 *(ro,no_root_squash,async)' >> /etc/exports
$> service nfs restart


Creating an initrd for diskless clients

We need an initrd for tftpboot.

$> setenforce Permissive
$> chroot /export/NFSroots/FC6 /bin/bash
$> mount -t tmpfs none /tmp
$> mount -t tmpfs none /dev
$> cd /tmp
$> mkinitrd --with=XXX --rootopts=ro,nolock --net-dev=eth0 --rootdev=myserver:/export/NFSroots/FC6 --rootfs=nfs initrd-2.6.18-1.2798.fc6.img 2.6.18-1.2798.fc6
$> mv initrd-2.6.18-1.2798.fc6.img /boot
$> cd /
$> umount /tmp
$> umount /dev
$> exit
$> chroot /export/NFSroots/F7 /bin/bash
$> mount -t tmpfs none /tmp
$> mount -t tmpfs none /dev
$> cd /tmp
$> mkinitrd --with=XXX --rootopts=ro,nolock --net-dev=eth0 --rootdev=myserver:/export/NFSroots/F7 --rootfs=nfs initrd-2.6.21-1.3194.fc7.img 2.6.21-1.3194.fc7
$> mv initrd-2.6.21-1.3194.fc7.img /boot
$> cd /
$> umount /tmp
$> umount /dev
$> exit
$> setenforce Enforcing

Notes: You will need to replace XXX with the module name of your client's NIC. If you want to use multiple clients with different NICs, then you will need multiple --with= options. For example, --with=natsemi --with=8139too. Finally, replace "myserver" with the hostname of your server.

Creating diskless and diskfull profiles in cobbler

Profiles are used to describe how to instantiate a root filesystem for clients (aka systems). Many clients can use a shared profile. While cobbler provides some default profiles, they are not suitable as-is for stateless systems.

$> cobbler distro add --name=FC6-diskless --kernel=/export/NFSroots/FC6/boot/vmlinuz-2.6.18-1.2798.fc6 --initrd=/export/NFSroots/FC6/boot/initrd-2.6.18-1.2798.fc6.img
$> cobbler profile add --name=FC6-diskless --distro=FC6-diskless
$> cobbler profile add --name=FC6-diskfull --distro=FC6-i386 --kickstart=/var/lib/cobbler/fc6-diskfull.cfg

$> cobbler distro add --name=F7-diskless --kernel=/export/NFSroots/F7/boot/vmlinuz-2.6.21-1.3194.fc7 --initrd=/export/NFSroots/F7/boot/initrd-2.6.21-1.3194.fc7.img
$> cobbler profile add --name=F7-diskless --distro=F7-diskless
$> cobbler profile add --name=F7-diskfull --distro=F7-i386 --kickstart=/var/lib/cobbler/f7--diskfull.cfg
$> cobbler sync

Random notes

Note you may need to update /etc/hosts in the client images. This is especially true if you are not using DNS to manage hostnames. Similarly you will need to replace /etc/passwd and /etc/group with ones suitable for your network.

NetworkManager is the long term preferred way to manage network connections. It is disabled at the moment because it does not work with NFS clients. However, it is a necessity for fully-caching clients.

You can proceed to adding clients.