Bootstrapping a virtual machine at University of Canterbury
From BeSTGRID
There are two existing solutions: generic Build.sh script (APAC repo Gbuild package), and the rpmstrap tool (recommended in the MyProxy and VOMRS instructions). Both these solutions are based on installing RPMs from a repository; the list of RPMS is a small predefined list.
I instead wanted to set up the virtual machine with a number of 'comfortable' packages I have on the host system - so I wrote my own script that bootstraps the machine in a similar way, but instead uses the list of packages that exist on the host system. In addition, the script set's up a number of services in a way they should run on the target host.
Contents |
[edit] Bootstrapping a Xen virtual machine
The script vmstrap should be run with the path to the mounted filesystem, and a hostname for the target virtual machine:
/home/vme28/vmstrap/bootstrapvm /mnt/vmRoot/ gridgwtest
[edit] Assumptions
- the target path is an existing directory
- yum is set up (/mnt/CentOS-Media exists, YUM_CONF exists)
[edit] Setup done
- Set up a default /etc/fstab with sda1 as root, sda2 as swap and /dev/pts, /dev/shm and /proc and /sys
- Import Centos4 RPM GPG key
- mknod --mode=0666 "${VMBASE}/dev/null" c 1 3
- Some RPM packages have scriptlets redirecting output to /dev/null - make sure it exists.
- Install basesystem
- Install coreutils
- Install perl
- move /lib/tls to /lib/tls.disabled in the target system
- make device nodes console zero null random sda sda1 sda2
- Install existing RPMs (minus banned)
- rpm -ivh --oldpackage kernel-xenU-*
- With -i --oldpackage, the specific kernel will install in addition to a kernel package installed from the RPM repositories.
- rpm -e kernel
- umount "${VMBASE}/proc"
- create /etc/hosts with localhost
- create ifcfg-eth0 with DHCP_HOSTNAME = vmhostname
- create /etc/sysconfig/network with full hostname (${VMHOSTNAME}.canterbury.ac.nz)
- create /etc/sysctl.conf with APAC recommended controls
- chkconfig ntpd on, chkconfig unneeded services off (installed for dependencies)
- set up local environment from the host system: /etc/localtime /etc/sysconfig/clock /etc/sysconfig/i18n
- change ntp.conf: only talk to ucgridgw.canterbury.ac.nz
- create empty resolv.conf
- create dhclient-eth0.conf to search in canterbury.ac.nz
- install pine (DAG)
- put APAC-Grid.repo, Ece-updates.repo into /etc/yum.repos.d/
- put /etc/mail/mailertable{,.db} into "${VMBASE}/etc/mail/" (set up default email gateway - ucgridgw for local mail, smtphost for outgoing)
- add TCP send buffer settings to /etc/sysctl.conf
- call pwconv and grpconv to turn on shadow passwords
- setup forwading of root's mail to a central account.
- set up root password
- killall minilogd cups-config-daemon - to allow the FS to be unmounted.
[edit] Local yum.conf
Basic considerations:
- must use repos with URLs without parameters (releasever,arch)
- - distrover package is not available in empty VM FS root
Creating yum.conf from /etc/yum.conf:
- set reposdir=/dev/null
- append all repositories /etc/yum.repos.d/* to yum.conf
- expand releasever to 4 and arch to i386
Command-line:
yum -y -c $YUM_CONF --installroot=${VMBASE} --disablerepo=* --enablerepo=eceupdates --enablerepo=c4-iso-media install
[edit] Remaining notes - rationale
Packages not provided in Repos:
- kernel-xenU{,-devel}
- pine
- rpmstrap
- gpg-pubkey-443e1821-421f218f
Optional enhancement:
- local repo for xenU kernel, pine
- see if xenU kernel satisfies kernel dependency
- service stop instead of kill: minilogd(??started) cups-config-daemon(rc.d)
- add the following line to /etc/sysconfig/network to stop the RedHat network subsystem from creating a route to 169.254.0.0/16 on network interfaces.
NOZEROCONF=yes
Notes:
- beware - yum creates RPM dirs but not lock dir
- fstab is not created
- base system commands not found - install these first - used in scriptlets
- basesystems coreutils gawk perl
- basesystem installs fine (+3 packages)
- coreutils installs +70 packages (including kernel, needs /etc/fstab)
