In few weeks, I’ll have to upgrade our 2 clusters from old customised redhat 7.3 linux to FreeBSD 6-STABLE. The preliminary tasks are already done: applications are now FreeBSD friendly, they have been ports-ified too, config files are ready to be deployed. It sounds really good doesn’t it? But I have a big constraint: I have to install one of the clusters in 3 hours. The only way to install ten servers in this timeframe is to use PXE. I already use PXE for basic installations, but here I must install ready-to-go servers. The cluster is also made of 3 different kinds of servers. I need to support different NICs, types of disk and even set up software RAID on one box. How can I do with our PXE stuff? I was dreaming of kickstart for FreeBSD ;-) I was thinking about patching sysinstall, but I’m too lazy :-) Let’s cheat!
(you can download a tarball with files and scripts here. Warning ! it’s quick and dirty !)
Prerequires:
-
- FreeBSD source of the desired version
- A FreeBSD ISO image
- a Web and a FTP servers
- a working PXE installation (Ceri’s post on PXE)
Basically, the idea is the to fetch a configuration file at the begining of sysinstall process, load it into sysinstall, commit install, fetch a post-install script and finally run it.
-
-
Cook mfsroot (please read Ceri’s post to know how to play with it)
First of all we have modify the mfsroot image to add fetch(1), our install.cfg and a simple script to fetch/configure our sysinstall.
To add fetch, we need to regenerate boot_crunch to support fetch, like this one: pxe_crunch.conf.
mkdir crunch
cd crunch
fetch http://www.cotds.org/~clement/PXE/part1/pxe_crunch.conf
crungen pxe_crunch.conf
make -f pxe_crunch.mk
cd ..
Mount mfsroot in a directory called mfsfd. Now we repopulate /stand with our new binary.cd mfsfd/stand
rm *
install 755 ../../crunch/pxe_crunch .
for i in $(crunchgen -l ../../pxe_crunch.conf); do ln pxe_crunch ${i} ; done
install m 755 /sbin/dhclientscript .Now we install our small install.cfg and the fetch_config.sh script fetch http://www.cotds.org/~clement/PXE/part1/install.cfg
fetch http://www.cotds.org/~clement/PXE/part1/fetch_config.sh
chmod +x fetch_config.sh
cd ..
mkdir -p var/db tmp var/run
Umount mfsroot and copy it in you boot/ directory in your nfs share.
-
Populate web server
On your webserver, install pxe.conf and pxe.sh
mkdir ${DOCUMENTROOT}/pxeinstall
cd ${DOCUMENTROOT}/pxeinstall
fetch http://www.cotds.org/~clement/PXE/part1/pxe.conf
fetch http://www.cotds.org/~clement/PXE/part1/pxe.sh
Edit those files to suit your needs.
vi pxe.conf pxe.sh
If you want to install FreeBSD via the interface PXE used, keep %%IFNAME%% as netDev value.
Currently disk support is not yes available. It will be supported soon.
pxe.sh is executed in post-install stage so you can use previously installed stuff, like perl or so. It’s a live system so beware :)
Note: don’t put stuff in /etc/rc.conf, it will be commented out. Use /etc/rc.conf.local instead.
Note 2: you can put those file on the FTP server instead.
-
Populate FTP server
mkdir ${FTPROOT}/pub/FreeBSD/releases/i386/
tar xvf /path/to/6.1-RELEASE-i386-disc1.iso 6.1-RELEASE ${FTPROOT}/pub/FreeBSD/releases/i386/
-
Edit boot/loader.rc
We use loader.rc to set 2 variables: pxe_conf_url and pxe_post_install_script_url.
Your loader.rc shoud look like this:
load /boot/kernel/kernel
load -t mfs_root /boot/mfsroot
set vfs.root.mountfrom=”ufs:/dev/md0c”
set pxe_conf_url=”http://www.yourwebserver.org/pxeinstall/pxe.conf”
set pxe_post_install_script_url=”http://www.yourwebserver.org/pxeinstall/pxe.sh”
boot
-
The end
Boot your machine via PXE and it should be ok :-)
The future is to replace hard-coded pxe.conf et pxe.sh for a php script to generation config file/script on the fly. pxe.sh should be improved to make gmirror configuration, nss stuff, and more (like data restoration via bacula for example). I’ll surely add more functions when it get rewriten.
FYI, I use my own FreeBSD release, packages are built in marcuscom tinderbox and a script to generate INDEX file. I also use a meta-port to avoid polluting pxe.conf.
See ya for part II… if any :-)