DXSUSE - Native {disk,state}{less,ful} openSUSE over network

Steps, summarized:

With a little personal tweaking, this can be used to have clients work with a local disk (save network bandwidth) or without (save disk noise), and be stateless (we just /bin/rm it on boot) or stateful. Your decision.

Requirements

aufs needs to be available either in the kernel or as a module, and the kernel needs to have the aufs-lhash patch; hence I suggest using a ccj kernel. Do not forget to install the aufs-kmp-flavor package (usually aufs-kmp-default). You can either install the kernel parts before finishing off the base install on a dedicated machine, or install it after step 2, so you already get the mkinitrd creation for free as a result of the update process for the kernel rpm.

2. Edit /tftpboot/linux/etc/sysconfig/bootloader

To not accidentally tamper with the host bootloader, take some safety measures by disabling bootloader activities from within the diskless install, by changing the variables' value in /tftpboot/linux/etc/sysconfig/bootlaoder to the following:

LOADER_TYPE="none"
LOADER_LOCATION="none"

3. Edit /tftpboot/linux/etc/fstab

fstab needs to be adjusted to contain this line for the root filesystem:

none / aufs defaults,noauto 0 0

4. Edit /tftpboot/linux/etc/sysconfig/kernel

Put at least the following modules in the INITRD_MODULES variable:

So for example, this is our INITRD_MODULES line, supporting RealTek cards and SIS900 onboard for regular machines pcnet32/e1000 for VMware. For storage controllers, e.g. PIIX for real-world machines, or mptspi for VMware. XFS we use as temporary storage for whatever gets modified while the system is up.

INITRD_MODULES="af_packet 8139too sis900 pcnet32 mptspi ata_piix nfs xfs aufs"

5. Create the initrd image

Self-explanatory. Run `mkinitrd`.

6. Change the scripts

This one is a bit tough, and unfortunately, not automated yet.

cd /tftpboot/linux;
md boot/initrd-dev;
cd boot/initrd-dev;
gzip -cd ../initrd-2.6.22.9-ccj54-default | cpio -diuv;

Then copy the following files/symlinks (use `cp -a`) from the real root to the chroot (same place):

Source Target inside initrd-dev
/usr/bin/env bin/env (yes, strip usr)
/lib/libresolv-2.5.so lib/libresolv-2.5.so
/lib/libresolv.so.2 lib/libresolv.so.2
/lib/libwrap.so.0 lib/libwrap.so.0
/lib/libwrap.so.0.7.6 lib/libwrap.so.0.7.6
/sbin/dhclient sbin/dhclient
/sbin/ip sbin/ip
/sbin/portmap sbin/portmap

(E.g. copy /sbin/ip to /tftpboot/linux/boot/initrd-dev/sbin/ip.)

Then apply the following patch while inside the initrd-dev directory:

# Assuming you are in the same directory as you were during cpio, do:
patch -p1 -i /where/you/put/the/patch.diff;
chmod 755 sbin/dhclient-script;

The init script -- obviously named init -- assumes that /tftpboot/linux is the root path as exported by the NFS server, so you might have to adjust it since the DHCP client, dhclient, does not pass it yet. (In short, it is hard-coded at this time.)

Further, if a partition with the label "tmp" exists, it will be used as temporal storage. (See the manpage for your favorite mkfs, man mkfs.xfs for details about labels.)

Now repack the initrd for final delivery. You can use the create_initrd script that has been added as part of the patch in the initrd-dev directory. Rename the new initrd image (written to ../initrd.cpio if using the script) to the usual naming if you like, and do not forget to put the names into your bootloader (mostly PXELINUX) configuration.

7. Set up the NFS export

Add a line like this to (the real) /etc/exports (not the one inside the chroot):

/tftpboot/linux 192.168.222.0/24(ro,no_root_squash,async,subtree_check)

Feel free to adjust for your network address. Yes, readonly is enough, this diskless openSuse patch does not modify any files on the server. See this Wikipedia article on unionfs how this is done. Note however, that unionfs does not work (just hangs in an infinite loop during boot...wtf), we need aufs!

Ideas for you

Networked read-write branch

The following function and caller, placed where `mount /.LABEL=tmp STATIC` would be, make it possible to use an NFS share as the rw branch. It is just an inspiration for how it might work, it is not a full command set. Instead of uuidgen, you could also use the IP address (since it is unique), but that is left as an exercise for you. (Don't use ifconfig, you have lost.)

function mount_static()
{
    server=`cat /.DYNAMIC/.next-server`;
    uuid=`uuidgen`;
    mount "$server:/tftpboot/rw" /.STATIC || return 1;
    rm -Rf "/.STATIC/$uuid";
    mkdir "/.STATIC/$uuid" || return 1;
    umount /.STATIC;
    mount "$server:/tftpboot/rw/$uuid" /.STATIC;
}

Xorg

Remove /etc/X11/xorg.conf, and X.org will automatically configure itself. It does not seem perfect, but better than X not starting at all because graphic cards oder mode lines does not match. (Anyone got a hint?)

 

Additional keywords: netboot netbooting pxe unionfs suse sles sled opensuse