Kickstarting a virtualized guest

If you need to provision hosts at a regular interval, kickstarting an installation is an effective and productive way of systematically creating guests. All of our Linux builds are now done via kickstart and as a result we have drastically reduced the turn-around time on the availability of new guests to our customers. So for a first article, here’s a quick how-to on getting guests installed via kickstart over NFS.

What you will need:

  • A host to act as the hypervisor for the guest.
  • A host that will provide NFS an export the ISO image and kickstart files. This can be the hypervisor if necessary.

Tasks:

  1. Get the ISO. CentOS 5.2 is here and direct DVD downloads can be found by visiting the mirror page.
  2. Install CentOS onto the system that will be your hypervisor. Be sure that the Virtualization group is checked so Xen will get installed.
  3. On your NFS host, make the directories that will be NFS mounted and contain the ISO files as well as your kickstart file:
    # mkdir -p /opt/install /opt/install/5.2 /opt/install/ks
  4. On the NFS host, mount the image and copy the contents to  /opt/install/5.2

    # mount -t iso9660 -o loop ./CentOS-5.2-x86_64-bin-DVD.iso /mnt
    # rsync -av /mnt/ /opt/install/5.2/
  5. Configure your NFS implementation. If your on a Linux/UNIX host, make sure you have the proper permissions in place and export the /opt/install directory accordingly.
  6. Create the kickstart file.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    
    # CENTOS 5.2 PVM Kickstart file
    # THIS IS FOR PARAVIRTUALIZED GUESTS ONLY!
    # Created By Jason Howk
     
    install
    nfs --server=192.168.0.240 --dir=/opt/install/5.2
    text
     
    # System Configuration...
    lang en_US.UTF-8
    keyboard us
    # Temporary root password.  Should be changed once host is ready.
    rootpw password
    firewall --disabled
    authconfig --enableshadow --enablemd5
    selinux --enforcing −−port=22:tcp
    timezone --utc America/Denver
    zerombr
    # xvda (Xen Virtual Disk) is the xen block tap device for paravirtualized hosts.
    # Non-PV hosts would see a normal hdx block device
    # http://wiki.xensource.com/xenwiki/blktap
    bootloader --location=mbr --driveorder=xvda --append="console=xvc0"
    reboot
     
    # Network Settings
    network --device eth0 --bootproto dhcp
     
    # Partitioning
    clearpart --all --initlabel --drives=xvda
    part /boot --fstype ext3 --size=100 --ondisk=xvda
    part pv.2 --size=0 --grow --ondisk=xvda
    volgroup VolGroup00 --pesize=32768 pv.2
    logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
    logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=256 --grow
    --maxsize=512
     
    # Disable unneeded services
    services --disabled microcode_ctl,smartd
     
    # Package Selection.  Core and Base are always selected by default.
    # see: http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.2/html/Installation_Guide/s1-kickstart2-packageselection.html
    %packages
    @ system-tools
     
    %pre
     
    %post
    #!/bin/sh
     
    # Localize the resolv.conf.
    cat << EOF > /etc/resolv.conf
    domain subaquatic.net
    search subaquatic.net
    nameserver 192.168.0.223
    nameserver 192.168.0.224
    EOF
     
    # Update to local ntp servers.
    sed -i -e "s/0.centos.pool.ntp.org/192.168.0.1/" /etc/ntp.conf
    sed -i -e "s/1.centos.pool.ntp.org/192.168.0.2/" /etc/ntp.conf
    sed -i -e "/2.centos.pool.ntp.org/d" /etc/ntp.conf
    chkconfig ntpd on
    service ntpd start
     
    # Turn off unnecessary services
    chkconfig bluetooth off
    chkconfig cups off
    chkconfig gpm off
  7. Create your VM.
    1
    2
    3
    4
    
    #!/bin/sh
    virt-install -n ${1} -r 256 -f /var/lib/xen/images/${1}.img -s 4 --vnc
    --os-type=linux --os-variant=centos5 -l nfs:192.168.0.240:/opt/install/5.2
    -x "ks=nfs:192.168.0.240:/opt/install/ks/centos52_text_pvm.ks" -p
  8. Done!

24. November 2008 by Jason
Categories: Virtualization | Tags: , , , , | 1 comment

One Comment

  1. If you can’t see your console with virt-viewer, change the kickstart bootloader stanza to include console=tty1 as well as console=xvc0. That will allow the console to appear on the virtual frame buffer as well.

Leave a Reply

Required fields are marked *

*