The Swede in the middle of Silicon Valley

Monday, June 16, 2008

Diskless linux boot

DRAFT!

Prep DHCP

# yum install dhcp

# emacs /etc/dhcpd.conf

allow bootp;
allow booting;

ddns-update-style interim;
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.10 192.168.0.254;
default-lease-time 3600;
max-lease-time 4800;
option routers 192.168.0.1;
option domain-name-servers 192.168.0.1;
option subnet-mask 255.255.255.0;

filename "pxelinux.0";
next-server 192.168.0.1;
}

Prep TFTP
# yum install tftp-server dhcp syslinux
# emacs /etc/xinet.d/tftp
disabled = no

# mkdir /tftpboot/pxelinux.cfg
# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/

# cd /tftpboot/pxelinux.cfg
# emacs 01-FF-FF-FF-FF-FF-FF
prompt 0
default linux
timeout 1000

label linux
kernel vmlinuz-.nfsboot.
append init=/sbin/init root=/dev/nfs rw nfsroot=192.168.0.254:0.0.0.0:192.168.0.1:255.255.255.0 noapic acpi=off


Install CHROOT environment

# mkdir -p /nfsroot/slave1
# emacs installslave.sh

MYCHROOT=/nfsroot/slave1

mkdir -p $MYCHROOT/etc $MYCHROOT/dev $MYCHROOT/dev $MYCHROOT/proc $MYCHROOT/sys

cp /var/cache/yum/fedora/mirrorlist.txt /nfsroot/slave1/var/cache/yum/fedora/
cp /var/cache/yum/updates/mirrorlist.txt /nfsroot/slave1/var/cache/yum/updates/

cp -r /etc/yum* $MYCHROOT/etc
touch $MYCHROOT/etc/fstab

mknod $MYCHROOT/dev/null c 1 3
chmod 666 $MYCHROOT/dev/null

mount --bind /proc $MYCHROOT/proc
mount --bind /sys $MYCHROOT/sys

yum --installroot=$MYCHROOT groupinstall "Base"

umount $MYCHROOT/proc
umount $MYCHROOT/sys

./installslave.sh

NFS
# emacs /etc/exports
/nfsroot/slave1 192.168.0.254(rw,no_all_squash,no_root_squash)

Build kernel
$ su -c 'yum install yum-utils rpmdevtools'
$ rpmdev-setuptree
$ yumdownloader --source kernel
$ su -c 'yum-builddep kernel-.src.rpm'
$ rpm -Uvh kernel-.src.rpm
$ cd ~/rpmbuild/SPECS
$ rpmbuild -bp --target=`uname -m` kernel.spec
$ cd ~/rpmbuild/BUILD/kernel-/linux-./
$ cp configs/ .config
$ make oldconfig
$ make menuconfig
$ cp .config ~/rpmbuild/SOURCES/config-
$ cd ~/rpmbuild/SPECS
$ emacs kernel.spec
% define buildid .nfsboot

$ rpmbuild -bb --with baseonly --without debuginfo --target=`uname -m` kernel.spec
$ cp ~/rpmbuild/RPMS//kernel-..rpm /nfsroot/slave1
# chroot /nfsroot/slave1
# rpm -ivh ~/rpmbuild/RPMS//kernel-..rpm
# exit
# cp /nfsroot/slave1/boot/vmlinuz-.nfsboot. /tftpboot


emacs /nfsroot/slave1/etc/rc.local
/bin/mount 192.168.0.1:/nfsroot/slave1 /

pwconv

http://www.digitalpeer.com/id/linuxnfs
http://fedoraproject.org/wiki/Docs/CustomKernel

No comments: