[linux-fai] add packages to /usr/lib/fai/nfsroot
Thomas Gebhardt
gebhardt at HRZ.Uni-Marburg.DE
Mon Jun 5 11:51:32 CEST 2000
Hi,
there has been a thread "Initiales Booten und /usr per NFS" on this
list discussing whether or not it makes sense to mount /usr on a
fai client or to install additional packages on the fai nfsroot
root partition.
Thomas Lange wrote:
> erzeuge ein sources.list in /usr/lib/fai/nfsroot
> cp sources.list /usr/lib/fai/nfsroot/etc/apt
> chroot /usr/lib/fai/nfsroot apt-get update
> chroot /usr/lib/fai/nfsroot apt-get install rdate cfengine ....
>
> das muesste dann in das postinst Skript rein. Kling jetzt einfach, werde ich
> aber erst im Juni testen. Ich habe auch schon daran gedacht ein
Since I prefer not to mount /usr from the server I tried to write
a script that does exactly this,
1. Copies apt sources list
2. Updates packages on nfsroot
3. Reads two lists of packages from /etc/fai/nfsroot-packages.dist
and /etc/fai/nfsroot-packages.local
(the packages from the *.dist configuration file are considered
to be needed for fai, the packages in *.local are my personal
add-ons. BTW: I really enjoy using FAI as a "rescue disk" providing
a root shell in case of emergency)
4. Installs additional packages
Here is /etc/fai/nfsroot-packages.dist:
# Packages added to fai nfsroot
kernel-image-2.2.15
perl-5.005
cfengine
rsh-client
wget
bootpc
file
rdate
ntpdate
/etc/fai/nfsroot-packages.local:
# Packages added to fai nfsroot (local add-ons)
emacs20
ssh
lvm
less
raidtools2
and, finally, the script:
#!/usr/bin/perl
$dist_packages_file = "/etc/fai/nfsroot-packages.dist";
$local_packages_file = "/etc/fai/nfsroot-packages.local";
$fai_client_root = "/usr/lib/fai/nfsroot";
# don't start daemons when installing packages on nfsroot image
system ("ln -sf ${fai_client_root}/bin/true ../../tmp/start-stop-daemon");
$ENV{PATH} = "/tmp:" . $ENV{PATH};
print "copying apt configuration files form /etc/apt/ to";
print " $fai_client_root/etc/apt/ ...\n";
system("cp /etc/apt/* $fai_client_root/etc/apt");
print "copying /etc/resolv.conf to $fai_client_root/tmp/etc/ ...\n";
system("mkdir -p $fai_client_root/tmp/etc");
system("cp -f /etc/resolv.conf $fai_client_root/tmp/etc/resolv.conf");
# some packages need /proc mounted during installation:
system("mount -t proc proc $fai_client_root/proc/ ");
# dummy fstab needed to make lilo installation script happy:
open (FSTAB, ">$fai_client_root/etc/fstab");
print FSTAB <<EOF;
# /etc/fstab: dummy file system information.
#
/dev/hda1 / ext2 defaults,errors=remount-ro 0 1
EOF
close (FSTAB);
print "updating database of available packages ...\n";
system("chroot $fai_client_root apt-get update");
print "upgrading packages to current version ...\n";
system("chroot $fai_client_root apt-get -f upgrade");
# need this if dependencies are broken:
system("chroot $fai_client_root apt-get -f install");
if (-r $dist_packages_file) {
open (DISTPACKAGES, $dist_packages_file) or warn
"cannot open $dist_packages_file for reading";
print "installing packages in $dist_packages_file ...\n";
while (<DISTPACKAGES>) {
chomp;
s/#.*//; # deleting comments
s/\s//g; # deleting whitespace
if (/^(\S+)$/) {
print "instaling packages $1 ...\n";
system ("chroot $fai_client_root apt-get -f install $1");
}
}
close(DISTPACKAGES);
}
if (-r $local_packages_file) {
open (LOCALPACKAGES, $local_packages_file) or warn
"cannot open $local_packages_file for reading";
print "installing packages in $local_packages_file ...\n";
while (<LOCALPACKAGES>) {
chomp;
s/#.*//; # deleting comments
s/\s//g; # deleting whitespace
if (/^(\S+)$/) {
print "instaling packages $1 ...\n";
system ("chroot $fai_client_root apt-get -f install $1");
}
}
close(LOCALPACKAGES);
}
system("umount $fai_client_root/proc/ ");
# cfengine need /var/run/ writable
system ("chroot $fai_client_root rm -rf /var/run");
system ("chroot $fai_client_root ln -s /tmp/var/run var/run");
# ssh needs .ssh writable
system ("chroot $fai_client_root rm -rf .ssh");
system ("chroot $fai_client_root ln -s /tmp/.ssh .ssh");
--------------------------------------------------------
This script is not intended to work without user interaction,
you have to type "return" several times. Up to now there is one
additional glitch: the lilo installation script expects to
find a kernel image "/vmlinuz". I don't yet have an idea how
to handle this gracefully. I just manually set a symbolic link
from /vmlinuz to the kernel image in /boot in the nfsroot
filesystem when running the script ("fai_add_packages") the first
time.
Kind regards, Thomas
More information about the linux-fai
mailing list