27 January 2008 - 15:46Automated mirror selection for LUG PXE installs
I’ve posted several times about the PXE-based install server I created/maintain for our local LUG’s installfests. We can network boot installers for all of the different Linux distros we support as well as various BSDs (and a GParted live image). The various Linux net-install images require users to specify a network mirror to retrieve installations files. For some distros (RHEL, Ubuntu, Fedora), I maintain local mirrors on the PXE server to speed installations (and in the case of RHEL, because there are no public network mirrors — our school has a site-license that affords every student a legitimate copy, so we can only do RHEL installs for attendees who are students). For most other distros, we use our school’s local mirror gtlib.gatech.edu.
For the first few installfests where we used the PXE server, I printed out several copies of a sheet with the various network mirrors for different distros. It would be something like this:
- Red Hat Enterprise Linux 5.1 — http://10.0.0.2/rhel5.1/i386/
- Ubuntu 7.10 (gutsy) — http://10.0.0.2/pub/ubuntu/
- Fedora 8 — http://10.0.0.2/fc8/i386/os/
- Debian testing — http://www.gtlib.gatech.edu/pub/debian/
- openSUSE 10.3 – http://128.61.111.11/pub/opensuse/distribution/10.3/repo/oss/
- Mandriva 2008.0 – http://www.gtlib.gatech.edu/pub/mandrake/official/2008.0/i586/
- Gentoo 2007.0 — http://10.0.0.2/gentoo (stage3 tarballs)
Now, obviously it was a minor pain to fill in that information repeatedly for each install, so I decided to automate it. For RedHat-based distros, I used a kickstart configuration file to specify the mirror, and for Debian-derived distros I used the installer “preseed” mechanism. Mandriva and openSUSE also provide features to do the same. Here’s how I set up each distro to automatically find the mirrors:
Red Hat Enterprise Linux / Fedora
For each distro version and architecture combination, create a kickstart configuration file available via HTTP. Here’s an example for Fedora 8 i386:
interactive
network --bootproto dhcp --noipv6
url --url http://10.0.0.2/fc8/i386/os/
firstboot --enable
The “interactive” and “firstboot –enable” parts are important because the installer assumes that you are doing a semi- or entirely automated installation if you use a kickstart configuration file. Without the “firstboot” line, it won’t give you the first boot system configuration dialogs where you create a non-root user and configure sound, video, etc. I wanted these installs to be basically identical to a manual install except with the network mirror pre-selected.
Now, all you have to do to use the kickstart config is edit your pxelinux configuration file. Append “ks=url_to_file” lines to the kernel boot parameters of each entry. E.g.:
LABEL fedora8_x86_64
kernel fedora/8/x86_64/vmlinuz
append initrd=fedora/8/x86_64/initrd.img ks=http://10.0.0.2/fc8/x86_64/ks.cfg
Debian / Ubuntu
The Debian installer (which is also used for Ubuntu network and alternate installs) allows you to “preseed” answers to all installer prompts. For each distro, you only need a single file for all version and architecture combinations assuming they all use the same mirror site (versions and architecture are not explicit in the mirror URL). Create a preseed configuration file like this:
d-i mirror/protocol string http
d-i mirror/country string enter information manually
d-i mirror/http/hostname string 10.0.0.2
d-i mirror/http/directory string /pub/ubuntu/
d-i mirror/http/proxy string
d-i apt-setup/security_host string
After creating the preseed file, simply append “preseed/url=url_to_file” to the kernel boot parameters of each entry. E.g.:
LABEL ubuntu_gutsy_i386
kernel ubuntu/gutsy/i386/ubuntu-installer/i386/linux
append vga=normal initrd=ubuntu/gutsy/i386/ubuntu-installer/i386
/initrd.gz preseed/url=http://10.0.0.2/ubuntu/lug.cfg --
One problem with using a local mirror for Ubuntu (10.0.0.2/pub/ubuntu) is that we have to go back and change the /etc/apt/source.list file to point to a public mirror after install — otherwise, after leaving the installfest, a user would be trying to use a non-existent Ubuntu mirror on RFC1918 IP space. I also used the pre-seed configuration file to automatically replace the source.list file after installation. The “preseed/late_command” option allows you to run stuff just before the install finishes (the root of the new system is in /target at this point). Here is the slightly hackish entry I use to fix the sources.list:
d-i preseed/late_command string cd /target/tmp ; wget http://10.0.0.2/ubuntu/fix_sources.sh ; cd /target ; sh tmp/fix_sources.sh
The fix_sources.sh simply replaces the entries in sources.list to point to a public mirror.
One other trick I did with the Ubuntu installer is disable the supremely annoying “Automatic Keyboard layout detection” mechanism. It prompts you “Yes/No,” but the default is Yes, so many people select it unwittingly. The result is a long and irritating process of pressing various keys on the keyboard which could have been solved in 1 second by simply selecting “American English” (99.9% of the time) from the keyboard layout menu. If you append “console-setup/ask_detect=false” to the kernel parameters to the installer image, it will go directly to the keyboard layout menu as if you selected “No” to keyboard autodetection.
openSUSE
The openSUSE installer supports setting the installation mirror source by passing “install=url_to_repository” as a kernel parameter to the install. The mirror path does not change with different architectures (like Debian), but it does change between versions. For example:
LABEL opensuse10.3_i386
kernel opensuse/10.3/i386/linux
append initrd=opensuse/10.3/i386/initrd splash=silent showopts install=http://128.61.111.11/pub/opensuse/distribution/10.3/repo/oss
The url provided uses a numeric IP address rather than a hostname because the openSUSE installer doesn’t handle DNS resolution (at least last time I checked; it may have been fixed in the meantime).
Mandriva
Mandriva supports mirror selection through the “automatic=config_list” kernel parameter, where config_list is a list of comma-separated key/value pairs in the form of “key:value.” To set the mirror, one could specify the string as follows: “automatic=method:http,network:dhcp,server:mirror_hostname,directory:mirror_path.” For example, here is an entry:
LABEL mandriva2008.0_i586
kernel mandriva/2008.0/i586/vmlinuz
append initrd=mandriva/2008.0/i586/all.rdz vga=788 splash=silent automatic=method:http,network:dhcp,server:www.gtlib.gatech.edu,directory:/pub/mandrake/official/2008.0/i586
The full directory above is “/pub/mandrake/official/2008.0/i586,” but fixed-width “code” entries don’t word-wrap without putting extra spaces. Note that Mandriva’s mirror URLs also include both architecture and distro version.
3 Comments | Tags: PXE-related