Auto Install with Kickstart


  • Copy install files of redhat
  • Setup NFS server
  • Related files
  • Setting
  • Start
  • Usage
  • Kickstart config file
  • File
  • Note
  • DHCP
  • PXE
  • Set bios for DELL
  • set tftp server
  • set boot item
  • More Scripts
  • boot.msg
  • pxelinux.cfg/default
  • ks.cfg
  • ks_more.cfg
  • mysql.sh
  • qmail.sh
  • set.sh
  • Copy install files of redhat
    mkdir /misc/redhat 

    insert each install CD of RedHat
    mount /dev/cdrom /mnt/cdrom 

    if CD1
    cp -var /mnt/cdrom/. /misc/redhat 

    other CDs
    cp -var /mnt/cdrom/RedHat /misc/redhat umount /mnt/cdrom eject 

    Setup NFS server
    Related files
    /etc/exports -- config file/usr/sbin/exportfs/usr/sbin/showmount -- check/var/lib/nfs/xtab -- log
    Setting
    echo "/mis/redhat 192.168.2.0/24(ro,no_root_squash)" >> /etc/exports 

    ro -- readonlyno_root_squash -- every user on remote is nobody except root
    Start
    service portmap startservice nfs start
    Usage
    mount –t nfs -o soft,intr,timeout=30 192.168.2.119:/usr/home /usr/home/ 
  • timeo=n
  • This sets the time (in tenths of a second) the NFS client will wait for a request to complete. The default value is 7 (0.7 seconds). What happens after a timeout depends on whether you use the hard or soft option.
  • soft
  • Soft-mount (as opposed to hard-mount) the driver. This option causes an I/O error to be reported to the process attempting a file operation when a major timeout occurs.
  • intr
  • Allow signals to interrupt an NFS call. Useful for aborting when the server doesn't respond.
    Kickstart config file
    File
    ks.cfg content:
    #Generated by Kickstart Configurator 
    #System language
    lang en_US
    #Language modules to install
    langsupport zh_CN.GB2312 zh_TW.Big5 ja_JP.eucJP --default=en_US
    #System keyboard
    keyboard us
    #System mouse
    mouse generic3ps/2
    #Sytem timezone
    timezone Asia/Tokyo
    #Root password rootpw --iscrypted $1$yifNoGyM$fq2lHrrfGIEyvglxnSuZ0.
    #Reboot after installation
    reboot
    #Use text mode install
    text
    #Install Red Hat Linux instead of upgrade
    install
    #Use NFS installation Media
    nfs --server=192.168.2.119 --dir=/misc/redhat/
    #System bootloader configuration
    bootloader --location=mbr
    #Clear the Master Boot Record
    zerombr yes
    #Partition clearing information
    clearpart --all --initlabel
    #Disk partitioning information
    part / --fstype ext3 --size 5000 --asprimary
    part /boot --fstype ext3 --size 100 --asprimary
    part swap --size 1024 --asprimary
    part /home --fstype ext3 --size 5000
    part /usr --fstype ext3 --size 5000 --asprimary
    part /var --fstype ext3 --size 1 --grow
    #System authorization infomation
    auth --useshadow --enablemd5
    #Network information
    network --bootproto=dhcp --device=eth0
    #Firewall configuration
    firewall --disabled
    #Do not configure XWindows
    skipx
    #Package install information
    %packages --resolvedeps
    @ Development Tools
    ntp

    %post
    #!/bin/bash
    if [ -e /etc/ntp.conf ]; then
    mv /etc/ntp.conf /etc/ntp.conf.bak
    fi
    echo "server dns5.sakura.ad.jp
    driftfile /etc/ntp/drift
    broadcastdelay 0.008" > /etc/ntp.conf
    chkconfig --level 3 ntpd on

    copy to NFS directory
    cp ks.cfg /misc/redhat 

    enter the following command at the boot: prompt:
    linux ks=nfs:192.168.2.119:/misc/redhat/ks.cfg 

    Note
    When installing, it has following message:
    Could not allocate requested partitions Partitioning failed:
    Could not allocate partitions Press OK to reboot your system

    Maybe partitions are too large.
    DHCP
    Append this to/etc/dhcp.conf
    allow booting;
    allow bootp;
    class "pxeclients" {
    match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
    next-server <server-ip>;
    filename "linux-install/pxelinux.0";
    }

    Then
    service dhcpd restart 

    server-ip is tftp server's ip, e.g. 192.168.2.119
    PXE
    Set bios for DELL
    Selecting MBA UNDI allows the system to boot from the network server. The MBA UNDI option appears under Boot Sequence only if the Network Interface Controller option is set to On w/MBA. If the Network Interface Controller option is set to On or Off, set it to On w/MBA and then press to save the change and reboot the system. MBA UNDI then appears under Boot Sequence.
    set tftp server
    /sbin/chkconfig --level 345 xinetd on
    /sbin/chkconfig --level 345 tftp on
    mkdir /tftpboot/linux-install
    cd /tftpboot/linux-install
    cp /usr/lib/syslinux/pxelinux.0 ./
    # directory image and isolinux are on CD1 of redhat install CDs
    cp /mnt/cdrom/image/pxeboot/initr.img ./
    cp /mnt/cdrom/image/pxeboot/vmlinux ./
    mkdir pxelinux.cfg
    cp /mnt/cdrom/isolinux/isolinux.cfg ./pxelinux.cfg/default
    cp /mnt/cdrom/isolinux/*.msg ./

    set boot item
    Add this into boot.msg
    -  To auto install Red Hat Enterprise Linux, type:     autoinstall <ENTER>. 

    Add this into default.
    label autoinstall   kernel vmlinuz   append ks=nfs:192.168.2.119:/misc/redhat/ks.cfg initrd=initrd.img 

    Then at the "boot:"prompt type "autointall".
    More Scripts
    Using these scripts to choose to install MySQL and qmail.
    boot.msg
    splash.lss   -  To install or upgrade Red Hat Enterprise Linux in graphical mode,      press the <ENTER> key.   -  To install or upgrade Red Hat Enterprise Linux in text mode, type:      linux text <ENTER>.    -  To install Red Hat Enterprise Linux only, type:      base <ENTER>.   -  To install Red Hat Enterprise Linux, MySQL and qmail, type:     install <ENTER>.   -  Use the function keys listed below for more information.  [F1-Main] [F2-Options] [F3-General] [F4-Kernel] [F5-Rescue]  

    pxelinux.cfg/default
    default bse
    prompt 1 timeout 300
    display boot.msg
    F1 boot.msg
    F2 options.msg
    F3 general.msg
    F4 param.msg
    F5 rescue.msg
    F7 snake.msg
    label linux
    kernel vmlinuz
    append initrd=initrd.img
    label text
    kernel vmlinuz
    append initrd=initrd.img text
    label expert
    kernel vmlinuz
    append expert initrd=initrd.img
    label ks
    kernel vmlinuz
    append ks initrd=initrd.img
    label lowres
    kernel vmlinuz
    append initrd=initrd.img lowres
    label base
    kernel vmlinuz
    append ks=nfs:192.168.1.1:/misc/redhat/ks.cfg initrd=initrd.img
    label install
    kernel vmlinuz
    append ks=nfs:192.168.1.1:/misc/redhat/ks_more.cfg initrd=initrd.img

    ks.cfg
    # kickstart auto install config
    # Author : Wu Hao
    # Date : 2005/08/24
    #System language
    lang en_US
    #Language modules to install
    langsupport zh_CN.GB2312 zh_TW.Big5 ja_JP.eucJP --default=en_US
    #System keyboard
    keyboard us
    #System mouse
    mouse generic3ps/2
    #Sytem timezone
    timezone Asia/Tokyo
    #Root password
    rootpw --iscrypted $1$yifNoGyM$fq2lHrrfGIEyvglxnSuZ0.
    #Reboot after installation
    reboot
    #Use text mode install
    text
    #Install Red Hat Linux instead of upgrade
    install
    #Use NFS installation Media
    nfs --server=192.168.1.1 --dir=/misc/redhat/
    #System bootloader configuration
    bootloader --location=mbr
    #Clear the Master Boot Record
    zerombr yes
    #Partition clearing information
    clearpart --all --initlabel
    #Disk partitioning information
    part / --fstype ext3 --size 5000 --asprimary
    part /boot --fstype ext3 --size 100 --asprimary
    part swap --size 1024 --asprimary
    #part /home --fstype ext3 --size 5000
    #part /usr --fstype ext3 --size 5000 --asprimary
    part /var --fstype ext3 --size 1 --grow
    #System authorization infomation
    auth --useshadow --enablemd5
    #Network information
    network --bootproto=dhcp --device=eth0
    #Firewall configuration
    firewall --disabled
    #Do not configure XWindows skipx
    #Package install information
    %packages --resolvedeps
    @ Development Tools
    ntp
    %post --nochroot
    #!/bin/bash
    SOURCE_DIR=/mnt/source/others
    TARGET_DIR=/mnt/sysimage/usr/src
    R_TARGET_DIR=/usr/src
    mkdir -p $TARGET_DIR
    #set
    cp $SOURCE_DIR/set.sh $TARGET_DIR
    chroot /mnt/sysimage/ $R_TARGET_DIR/set.sh

    ks_more.cfg
    Only post part is different from ks.cfg.
    %post --nochroot
    chvt 3
    exec > /dev/tty3 < /dev/tty3
    SOURCE_DIR=/mnt/source/others
    TARGET_DIR=/mnt/sysimage/usr/src
    R_TARGET_DIR=/usr/src
    mkdir -p $TARGET_DIR
    #default set
    cp $SOURCE_DIR/set.sh $TARGET_DIR
    echo "#!/bin/sh" >> /mnt/sysimage/tmp/run
    echo $R_TARGET_DIR/set.sh >> /mnt/sysimage/tmp/run
    #mysql
    echo "Do you want to install MySQL?[y/n]"
    read answer
    if [ $answer == "y" ]; then
    cp $SOURCE_DIR/perl-DBI-1.32-5.i386.rpm $TARGET_DIR
    cp $SOURCE_DIR/MySQL-server-standard-4.1.13-0.rhel3.i386.rpm $TARGET_DIR
    cp $SOURCE_DIR/MySQL-client-standard-4.1.13-0.rhel3.i386.rpm $TARGET_DIR
    cp $SOURCE_DIR/mysql.sh $TARGET_DIR
    echo $R_TARGET_DIR/mysql.sh >> /mnt/sysimage/tmp/run
    fi
    #qmail
    echo "Do you want to install qmail?[y/n]"
    read answer
    if [ $answer == "y" ]; then
    echo "Input FQDN of your mail server"
    read mail_server
    cp $SOURCE_DIR/checkpassword-0.90.tar.gz $TARGET_DIR
    cp $SOURCE_DIR/qmail-1.03.tar.gz $TARGET_DIR
    cp $SOURCE_DIR/ucspi-tcp-0.88.tar.gz $TARGET_DIR
    cp $SOURCE_DIR/qmail.sh $TARGET_DIR
    echo "$R_TARGET_DIR/qmail.sh install" >> /mnt/sysimage/tmp/run
    echo "echo $mail_server | $R_TARGET_DIR/qmail.sh setup" >> /mnt/sysimage/tmp/run
    fi
    chvt 1

    %post
    chvt 3
    chmod 755 /tmp/run /tmp/run
    chvt 1

    mysql.sh
    #!/bin/bash
    cd /tmp
    rpm -i perl-DBI-1.32-5.i386.rpm
    groupadd mysql
    useradd -g mysql mysql
    rpm -i MySQL*.rpm

    qmail.sh
    使用渡濑先生的屏幕
    set.sh
    #!/bin/bash 
    #ntp
    if [ -e /etc/ntp.conf ]; then
    mv /etc/ntp.conf /etc/ntp.conf.bak
    fi
    echo "server dns5.sakura.ad.jp
    driftfile /etc/ntp/drift
    broadcastdelay 0.008" > /etc/ntp.conf
    chkconfig --level 3 ntpd on
    #close useless services
    chkconfig microcode_ctl off
    chkconfig gpm off
    chkconfig mdmonitor off
    chkconfig atd off
    chkconfig apmd off
    chkconfig isdn off
    chkconfig pcmcia off
    chkconfig autofs off
    chkconfig rhnsd off
    chkconfig cups off
    chkconfig xfs off
    chkconfig canna off
    chkconfig FreeWnn off
    chkconfig rawdevices off
    #DNS
    echo "nameserver 202.216.224.67
    nameserver 202.216.224.66
    nameserver 210.188.224.9
    nameserver 210.224.172.13
    nameserver 202.222.22.172
    search localhost" > /etc/resolve.conf