home *** CD-ROM | disk | FTP | other *** search
/ Freelog Special Edition 1: Linux / CD1.iso / doc / HOWTO / KickStart-HOWTO < prev    next >
Text File  |  1998-10-14  |  28KB  |  1,189 lines

  1.   RedHat Linux KickStart HOWTO
  2.   Martin Hamilton <martinh@gnu.org>
  3.   v0.0, 10 August 1998
  4.  
  5.   This HOWTO briefly describes how to use the RedHat Linux KickStart
  6.   system to rapidly install large numbers of identical Linux boxes.  For
  7.   advanced users, we describe how to modify the KickStart installation
  8.   procedure to do your own thing, and give a quick guide to building RPM
  9.   packages of your own.
  10.   ______________________________________________________________________
  11.  
  12.   Table of Contents
  13.  
  14.  
  15.   1. Homepage
  16.  
  17.   2. Introduction
  18.  
  19.   3. Prerequisites
  20.  
  21.   4. Configuring BOOTP/DHCP and NFS
  22.  
  23.   5. The KickStart config file
  24.  
  25.      5.1 System info
  26.      5.2 Packages to install
  27.      5.3 Post-installation shell commands
  28.  
  29.   6. Installation itself
  30.  
  31.   7. Mounting the boot/supp disks
  32.  
  33.   8. Modifying the RedHat installer
  34.  
  35.   9. Making your own RPMs
  36.  
  37.   10. FAQs/Wish list
  38.  
  39.   11. Credits
  40.  
  41.  
  42.  
  43.   ______________________________________________________________________
  44.  
  45.   1.  Homepage
  46.  
  47.  
  48.   If you got this document from a Linux HOWTO mirror site or a CD-ROM,
  49.   you might want to check back to the KickStart HOWTO home page
  50.   <http://wwwcache.ja.net/dev/kickstart/> to see if there's a newer
  51.   version around.
  52.  
  53.  
  54.  
  55.  
  56.   2.  Introduction
  57.  
  58.  
  59.   RedHat Linux version 5 comes with a a little-known (and until now, not
  60.   hugely documented) feature called KickStart.  This lets you automate
  61.   most/all of a RedHat Linux installation, including:
  62.  
  63.  
  64.  
  65.   ╖  Language selection
  66.  
  67.   ╖  Network configuration and distribution source selection
  68.  
  69.   ╖  Keyboard selection
  70.  
  71.   ╖  Boot loader installation (e.g. lilo)
  72.  
  73.   ╖  Disk partitioning and filesystem creation
  74.  
  75.   ╖  Mouse selection
  76.  
  77.   ╖  X Window system server configuration
  78.  
  79.   ╖  Timezone selection
  80.  
  81.   ╖  Selection of an (initial) root password
  82.  
  83.   ╖  Which packages to install
  84.  
  85.  
  86.   Eagle eyed RedHat users will probably have realised by now that these
  87.   are essentially the main steps involved in the manual installation of
  88.   a RedHat Linux system.  KickStart makes it possible for you to script
  89.   the regular installation process, by putting the information you would
  90.   normally type at the keyboard into a configuration file.
  91.  
  92.  
  93.   But wait - there's more!
  94.  
  95.  
  96.   Having finished the normal installation process, KickStart also lets
  97.   you specify a list of shell level commands which you would like to be
  98.   executed.  This means that you can automatically install extra local
  99.   software not distributed as part of RedHat Linux (yes, there are even
  100.   more free software programs than the ones you get with the RedHat
  101.   distribution!  Some can't be distributed by RedHat on legal grounds,
  102.   e.g. the ssh and PGP encryption systems) and carry out any tidying up
  103.   you may need to do in order to get a fully operational system.
  104.  
  105.  
  106.  
  107.  
  108.   3.  Prerequisites
  109.  
  110.  
  111.   In theory all you need is a RedHat boot disk, onto which you copy your
  112.   KickStart configuration file.  In practice I wasn't able to make this
  113.   work, and opted for an alternative approach...
  114.  
  115.  
  116.  
  117.   1. Intel (i386) class machines - KickStart appears to only work on
  118.      these at the time of writing.
  119.  
  120.   2. KickStart config file - we'll talk about this in the next section!
  121.  
  122.   3. RedHat boot disk - preferably from the updates directory, to take
  123.      advantage of any fixes/driver updates.
  124.  
  125.   4. DNS entries for the IP addresses you'll be using - optional, but
  126.      will stop the installation from prompting you for your machine's
  127.      domain name.
  128.  
  129.   5. A BOOTP/DHCP server for the network(s) your machine(s) will be
  130.      installed on.  Some servers will allocate new addresses in a given
  131.      range automatically, e.g. the CMU BOOTP server   with dynamic
  132.      addressing extensions <ftp://ftp.ntplx.net/pub/networking/bootp>.
  133.   6. On the same machine as the BOOTP server, an NFS server with a copy
  134.      of the RedHat distribution mounted on it, and the KickStart config
  135.      file (see next section for naming details) in an NFS exported
  136.      directory /kickstart.
  137.  
  138.  
  139.   It may be possible to do without the BOOTP server - this is certainly
  140.   implied in the KickStart documentation.  I've not tried this myself.
  141.   Likewise, you may be able to install off a CD-ROM rather than an NFS
  142.   server.  If you try either of these, let me know how you get on, so
  143.   that I can fold your info back into this document.
  144.  
  145.  
  146.   Note that it's not strictly necessary for the NFS server to hold both
  147.   the RedHat distribution and the KickStart config file - just makes
  148.   things a bit simpler to have everything in one place.
  149.  
  150.  
  151.  
  152.  
  153.   4.  Configuring BOOTP/DHCP and NFS
  154.  
  155.  
  156.   If you're wondering what on earth this BOOTP and DHCP stuff is, more
  157.   information is available at the DHCP WWW site <http://www.dhcp.org/>.
  158.   NFS is documented separately in detail in the NFS HOWTO.
  159.  
  160.  
  161.   In the BOOTP/DHCP + NFS configuration we're discussing, the KickStart
  162.   config file should be NFS mountable by the machine being installed
  163.   from /kickstart/IPADDR-kickstart on the BOOTP/DHCP server, where
  164.   IPADDR is the IP address of the new machine, e.g.
  165.   /kickstart/198.168.254.254-kickstart for the machine 198.168.254.254.
  166.  
  167.  
  168.   In theory you should be able to override this location by returning
  169.   the bf parameter (boot file) in your BOOTP/DHCP response.  It may even
  170.   be possible to have this NFS mounted off another machine entirely.
  171.  
  172.  
  173.   To NFS export some directories from an existing Linux box, create the
  174.   file /etc/exports with contents something like:
  175.  
  176.  
  177.  
  178.  
  179.        /kickstart *.swedish-chef.org(ro,no_root_squash)
  180.        /mnt/cdrom *.swedish-chef.org(ro,no_root_squash)
  181.  
  182.  
  183.  
  184.  
  185.  
  186.   Note that if you didn't register the IP addresses you're going to be
  187.   using in the DNS, you may be told to get lost by the NFS server and/or
  188.   the RPC portmapper.  In this you can probably get away with putting IP
  189.   address/netmask pairs in the config files, e.g.
  190.  
  191.  
  192.  
  193.  
  194.        /kickstart 198.168.254.0/255.255.255.0(ro,no_root_squash)
  195.  
  196.  
  197.  
  198.  
  199.   and in /etc/hosts.allow:
  200.  
  201.  
  202.  
  203.  
  204.        ALL: 194.82.103.0/255.255.255.0: ALLOW
  205.  
  206.  
  207.  
  208.  
  209.  
  210.   Be aware that if you include a root password in your KickStart config
  211.   file, or NFS export directories containing sensitive information, you
  212.   should take care to expose this information to as few people as
  213.   possible.  This can be done by making the NFS export permissions as
  214.   fine grained as possible, e.g. by specifying a particular host or
  215.   subnet to export to rather than a whole domain.
  216.  
  217.  
  218.   Most NFS servers require you to tell mountd and nfsd (on some versions
  219.   of Unix they're prefixed with a rpc.) that the /etc/exports file has
  220.   changed - usually by sending a SIGHUP.  There's often a program or
  221.   script called exportfs, which will do this for you, e.g.
  222.  
  223.  
  224.  
  225.  
  226.        # exportfs -a
  227.  
  228.  
  229.  
  230.  
  231.  
  232.   If you didn't have NFS up and running when this machine was booted,
  233.   the directories may not be exported automatically.  Try rebooting, or
  234.   running the following programs as root:
  235.  
  236.  
  237.  
  238.  
  239.        # portmap
  240.        # rpc.nfsd
  241.        # rpc.mountd
  242.  
  243.  
  244.  
  245.  
  246.  
  247.   As noted, on some systems the rpc. prefix isn't used.  In most modern
  248.   Unix distributions, these programs can be found in the /usr/sbin
  249.   directory.  This might not be in your path already.  The portmap
  250.   program is also sometimes called rpcbind, e.g. on Solaris.
  251.  
  252.  
  253.   If you're using the CMU BOOTP server with DHCP and dynamic addressing
  254.   extensions referred to earlier, a sample /etc/bootptab entry
  255.   (/etc/bootptab is the normal location of the BOOTP/DHCP configuration
  256.   file) would look something like this:
  257.  
  258.  
  259.  
  260.  
  261.          .dynamic-1:ip=198.168.254.128:T254=0x30:T250="ds=198.168.254.2:
  262.          dn=swedish-chef.org:sm=255.255.255.0:gw=198.168.254.1:
  263.          dl=0xFFFFFFFF":
  264.  
  265.   (wrapped for clarity)
  266.  
  267.  
  268.   This says to allocate IP addresses dynamically on encountering new
  269.   machines, starting at 198.168.254.128 and continuing for the next 48
  270.   (the hexadecimal value 30) addresses.  Each client will be passed back
  271.   the value of T250.  In this case that sets:
  272.  
  273.  
  274.  
  275.   ╖  the DNS server ds to 198.168.254.2
  276.  
  277.   ╖  the domain name dn to swedish-chef.org
  278.  
  279.   ╖  the subnet mask sm to 255.255.255.0
  280.  
  281.   ╖  the default gateway gw to 198.168.254.1
  282.  
  283.   ╖  the lease length dl (how long the address is valid for) to
  284.      "forever"
  285.  
  286.  
  287.   There seem to be a number of other versions of this server kicking
  288.   around which do not support dynamic addressing.  For these, you would
  289.   have to list the hardware (typically Ethernet MAC) address of each to-
  290.   be-installed machine in /etc/bootptab, and the entries would look
  291.   something like this:
  292.  
  293.  
  294.  
  295.  
  296.        bork.swedish-chef.org:\
  297.          ip=198.168.254.128:\
  298.          ha=0000E8188E56:\
  299.          ds=198.168.254.2:\
  300.          dn=swedish-chef.org:\
  301.          sm=255.255.255.0:\
  302.          gw=198.168.254.1:\
  303.          dl=0xFFFFFFFF":
  304.  
  305.  
  306.  
  307.  
  308.  
  309.   Note that the parameter ha corresponds to the hardware address of the
  310.   machine being installed.
  311.  
  312.  
  313.  
  314.  
  315.   5.  The KickStart config file
  316.  
  317.  
  318.   There are three main sections to the config file:
  319.  
  320.  
  321.  
  322.   1. System info, e.g. disk partitioning and network config
  323.  
  324.   2. RedHat packages to install
  325.  
  326.   3. Post-installation shell commands to run
  327.  
  328.  
  329.   There are some other possibilities which we won't talk about here, but
  330.   might work.  For more information check out the sample KickStart
  331.   config in misc/src/install/ks.samp and doc/README.ks under the top
  332.   level i386 RedHat distribution directory on your CD-ROM or local
  333.   RedHat mirror site.
  334.  
  335.  
  336.  
  337.  
  338.   5.1.  System info
  339.  
  340.  
  341.   The available directives which I've been using are:
  342.  
  343.  
  344.  
  345.      lang
  346.         Language configuration, e.g. for English
  347.  
  348.  
  349.           lang en
  350.  
  351.  
  352.  
  353.  
  354.      network
  355.         Network configuration, e.g. to use BOOTP/DHCP
  356.  
  357.  
  358.           network --bootp
  359.  
  360.  
  361.  
  362.  
  363.      nfs
  364.         NFS server and directory to install from, e.g.
  365.  
  366.  
  367.           nfs --server chicken.swedish-chef.org /mnt/cdrom
  368.  
  369.  
  370.  
  371.  
  372.      to use the NFS server chicken.swedish-chef.org and try to mount the
  373.      RedHat distribution from the directory /mnt/cdrom.
  374.  
  375.      keyboard
  376.         Select keyboard type, e.g. for UK keyboards
  377.  
  378.  
  379.           keyboard uk
  380.  
  381.  
  382.  
  383.  
  384.      zerombr
  385.         Clear the Master Boot Record - removes any existing operating
  386.         system boot loader from your disk
  387.  
  388.      clearpart
  389.         Clear existing partitions - e.g. to remove all existing disk
  390.         partitions prior to installation
  391.  
  392.  
  393.           clearpart -all
  394.  
  395.  
  396.  
  397.      part
  398.         Partition the disk, e.g. to make a root filesystem of 500MB
  399.  
  400.  
  401.           part / --size 500
  402.  
  403.  
  404.  
  405.  
  406.      install
  407.         Make a fresh installation of RedHat Linux.
  408.  
  409.      mouse
  410.         Set the mouse being used, e.g. for a PS/2 or compatible "bus
  411.         mouse"
  412.  
  413.  
  414.           mouse ps/2
  415.  
  416.  
  417.  
  418.  
  419.      timezone
  420.         Set the timezone, e.g. for local time in the UK
  421.  
  422.  
  423.           timezone --utc Europe/London
  424.  
  425.  
  426.  
  427.  
  428.      rootpw
  429.         Set the initial root password, based on a previously derived
  430.         encrypted password
  431.  
  432.  
  433.           rootpw --iscrypted XaacoeGPmf/A.
  434.  
  435.  
  436.  
  437.  
  438.      lilo
  439.         Install the LILO boot loader, e.g. in the Master Boot Record
  440.  
  441.  
  442.           lilo --location mbr
  443.  
  444.  
  445.  
  446.  
  447.      %packages
  448.         Packages to install - see below.
  449.  
  450.      %post
  451.         Post-installation shell commands - see below.
  452.  
  453.  
  454.   Note that the directory where KickStart is looking for the RedHat
  455.   distribution should have a subdirectory RedHat, which contains the
  456.   RedHat distribution tree for the platform in question.  In the above
  457.   example, we should see something like the following files
  458.   anddirectories:
  459.  
  460.  
  461.  
  462.  
  463.   /mnt/cdrom/RedHat
  464.   /mnt/cdrom/RedHat/base
  465.   /mnt/cdrom/RedHat/contents
  466.   /mnt/cdrom/RedHat/i386
  467.   /mnt/cdrom/RedHat/instimage
  468.   /mnt/cdrom/RedHat/RPMS
  469.   /mnt/cdrom/RPM-PGP-KEY
  470.  
  471.  
  472.  
  473.  
  474.  
  475.   If you want to create your own encrypted passwords, it's very easy
  476.   using Perl, e.g.
  477.  
  478.  
  479.  
  480.  
  481.        % perl -e 'print crypt("schmurrdegurr", "Xa") . "\n";'p
  482.  
  483.  
  484.  
  485.  
  486.  
  487.   Other options (or mooted options), which I've not tried:
  488.  
  489.  
  490.  
  491.      cdrom
  492.         Install off CD-ROM rather than network.
  493.  
  494.      device
  495.         Explicitly declare device details, e.g.
  496.  
  497.  
  498.           device ethernet 3c509 --opts "io=0x330, irq=7"
  499.  
  500.  
  501.  
  502.  
  503.      Alternative values of device include scsi for SCSI controllers and
  504.      cdrom for proprietary CD-ROM drives.
  505.  
  506.      upgrade
  507.         Upgrade an existing installation rather than make a fresh
  508.         installation.
  509.  
  510.      xconfig
  511.         Configure X Window server, graphics card and monitor.  e.g.
  512.  
  513.  
  514.           xconfig --server "Mach64" --monitor "tatung cm14uhe"
  515.  
  516.  
  517.  
  518.  
  519.  
  520.   I've not delved too deeply into this last one, because I'm not ever
  521.   planning to run X on the console of any of my KickStarted machines.
  522.   If you do, please let me know how you get on.
  523.  
  524.  
  525.   Here's how this first part of a KickStart config file looks when we
  526.   put all the bits together:
  527.  
  528.  
  529.        lang en
  530.        network --bootp
  531.        nfs --server chicken.swedish-chef.org /mnt/cdrom
  532.        keyboard uk
  533.        zerombr yes
  534.        clearpart --all
  535.        part / --size 500
  536.        part swap --size 120
  537.        install
  538.        mouse ps/2
  539.        timezone --utc Europe/London
  540.        rootpw --iscrypted XaacoeGPmf/A.
  541.        lilo --location mbr
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.   5.2.  Packages to install
  550.  
  551.  
  552.   The start of the packages section of the KickStart config file is
  553.   indicated by the presence of a %packages directive on a line of its
  554.   own.  This is followed by one or both of two types of package
  555.   specifier - individual packages may be installed by giving the name of
  556.   their RPM (excluding the version and platform information), and groups
  557.   of packages may be installed by giving their group name.
  558.  
  559.  
  560.   Here's a sample packages section for a KickStart config file:
  561.  
  562.  
  563.  
  564.        %packages
  565.        @ Base
  566.        netkit-base
  567.        bind-utils
  568.        ncftp
  569.        rdate
  570.        tcp_wrappers
  571.        traceroute
  572.        cmu-snmp
  573.  
  574.  
  575.  
  576.  
  577.  
  578.   So, what are these groups ?  Well, there are a number of groups
  579.   defined by default in a file called base/comps under the RedHat
  580.   distribution's top level directory.  Here are the ones which were
  581.   current at the time of writing:
  582.  
  583.  
  584.  
  585.   ╖  Base
  586.  
  587.   ╖  Printer Support
  588.  
  589.   ╖  X Window System
  590.  
  591.   ╖  Mail/WWW/News Tools
  592.  
  593.   ╖  DOS/Windows Connectivity
  594.  
  595.   ╖  File Managers
  596.  
  597.   ╖  Graphics Manipulation
  598.  
  599.   ╖  X Games
  600.  
  601.   ╖  Console Games
  602.  
  603.   ╖  X multimedia support
  604.  
  605.   ╖  Console Multimedia
  606.  
  607.   ╖  Print Server
  608.  
  609.   ╖  Networked Workstation
  610.  
  611.   ╖  Dialup Workstation
  612.  
  613.   ╖  News Server
  614.  
  615.   ╖  NFS Server
  616.  
  617.   ╖  SMB (Samba) Connectivity
  618.  
  619.   ╖  IPX/Netware(tm) Connectivity
  620.  
  621.   ╖  Anonymous FTP/Gopher Server
  622.  
  623.   ╖  Web Server
  624.  
  625.   ╖  DNS Name Server
  626.  
  627.   ╖  Postgres (SQL) Server
  628.  
  629.   ╖  Network Management Workstation
  630.  
  631.   ╖  TeX Document Formatting
  632.  
  633.   ╖  Emacs
  634.  
  635.   ╖  Emacs with X windows
  636.  
  637.   ╖  C Development
  638.  
  639.   ╖  Development Libraries
  640.  
  641.   ╖  C++ Development
  642.  
  643.   ╖  X Development
  644.  
  645.   ╖  Extra Documentation
  646.  
  647.  
  648.   You'll notice that they correspond to the various configurations which
  649.   you're prompted for during a manual installation.  Note that some of
  650.   the packages in a given package group are duplicated in other groups,
  651.   and that you can install multiple groups of packages without this
  652.   causing problems.  Each group's entry in the comps listing looks
  653.   similar to this:
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.   0 Extra Documentation
  662.   sag
  663.   lpg
  664.   howto
  665.   faq
  666.   man-pages
  667.   end
  668.  
  669.  
  670.  
  671.  
  672.  
  673.   It seems that groups with a 1 next to their name (the first line
  674.   above) are selected for installation by default.  It looks like you
  675.   might be possible to customise the Linux installation process even
  676.   further by creating your own groups or redefine existing ones - let me
  677.   know if you try this!
  678.  
  679.  
  680.  
  681.  
  682.   5.3.  Post-installation shell commands
  683.  
  684.  
  685.   This is probably the best feature of all, and something which there is
  686.   no direct equivalent to in the manual installation process.  What we
  687.   can do here is specify a sequence of shell level commands which should
  688.   be executed after the main installation (disk partitioning, package
  689.   installation, and so on) is complete.
  690.  
  691.  
  692.   The beginning of this section is signified by the %post directive in
  693.   the KickStart config file.  In what follows you can take advantage of
  694.   all of the utilities which have been installed on your newly built
  695.   Linux system, e.g.
  696.  
  697.  
  698.  
  699.  
  700.        %post
  701.        ln -s /etc/rc.d/init.d /etc/init.d
  702.        ln -s /etc/rc.d/rc.local /etc/rc.local
  703.        ln -s /usr/bin/md5sum /usr/bin/md5
  704.        ln -s /usr/bin/perl /usr/local/bin/perl
  705.        chmod ug-s /bin/linuxconf
  706.        mkdir /var/tmp/tmp
  707.        perl -spi -e 's!image=/boot/vmlinuz-.*!image=/boot/vmlinuz!' /etc/lilo.conf
  708.        rm /etc/rc.d/rc*.d/*sendmail
  709.  
  710.  
  711.  
  712.  
  713.  
  714.   You can also use I/O redirection and here documents:
  715.  
  716.  
  717.  
  718.  
  719.        cat <<EOF >>/etc/passwd
  720.        squid:*:102:3500:Squid Proxy:/usr/squid:/bin/bash
  721.        EOF
  722.  
  723.        cat <<EOF >>/etc/group
  724.        cache:x:3500:
  725.        EOF
  726.  
  727.   Modify the run-time startup scripts:
  728.  
  729.  
  730.  
  731.  
  732.        cat <<EOF >>/etc/rc.local
  733.        echo 8192 > /proc/sys/kernel/file-max
  734.        echo 32768 > /proc/sys/kernel/inode-max
  735.  
  736.        [ -x /usr/sbin/sshd ] && /usr/sbin/sshd
  737.        [ -x /usr/sbin/cfd ] && /usr/sbin/cfd
  738.  
  739.        EOF
  740.  
  741.  
  742.  
  743.  
  744.  
  745.   Set up crontab entries:
  746.  
  747.  
  748.  
  749.  
  750.  
  751.        cat <<EOF >/tmp/crontab.root
  752.        # Keep the time up to date
  753.        0,15,30,45 * * * * /usr/sbin/ntpdate -s eggtimer 2>&1 >/dev/null
  754.        # Recycle Exim log files
  755.        1 0 * * * /usr/exim/bin/exicyclog
  756.        # Flush the Exim queue
  757.        0,15,30,45 * * * * /usr/exim/bin/exim -q
  758.        EOF
  759.  
  760.        crontab /tmp/crontab.root
  761.        rm /tmp/crontab.root
  762.  
  763.  
  764.  
  765.  
  766.  
  767.   And even install other RPMs which you made yourself:
  768.  
  769.  
  770.  
  771.  
  772.        rpm -i ftp://chicken.swedish-chef.org/rpms/squid.rpm
  773.        rpm -i ftp://chicken.swedish-chef.org/rpms/ssh.rpm
  774.        rpm -i ftp://chicken.swedish-chef.org/rpms/exim.rpm
  775.        rpm -i ftp://chicken.swedish-chef.org/rpms/cfengine.rpm
  776.        rpm -i ftp://chicken.swedish-chef.org/rpms/linux.rpm
  777.  
  778.        ssh-keygen -b 1024 -f /etc/ssh_host_key -N ""
  779.        depmod -a
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.   6.  Installation itself
  788.  
  789.  
  790.   Boot the to-be-installed machine off your RedHat boot floppy as usual,
  791.   but instead of pressing RETURN at the SYSLINUX prompt, type linux ks.
  792.  
  793.   If you're lucky, this will be all you have to type!
  794.  
  795.  
  796.   Since we're really just automating the normal steps involved in a
  797.   RedHat installation, the normal dialogs may appear if/when KickStart
  798.   gets confused about what to do next.  The most likely case is that
  799.   your network interface won't be detected automatically, and you'll be
  800.   prompted for its IRQ and I/O address space.
  801.  
  802.  
  803.  
  804.  
  805.   7.  Mounting the boot/supp disks
  806.  
  807.  
  808.   The RedHat boot disk boot.img is in MS-DOS format, using the SYSLINUX
  809.   program to boot up.  The supplementary disk supp.img is a Linux ext2
  810.   filesystem.  If you have support for the loopback filesystem in your
  811.   Linux kernel, you can mount both of these files in your filesystem and
  812.   hack at them:
  813.  
  814.  
  815.  
  816.  
  817.        # mkdir -p /mnt/boot /mnt/supp
  818.        # mount -o loop -t msdos boot.img /mnt/boot
  819.        # mount -o loop supp.img /mnt/supp
  820.  
  821.  
  822.  
  823.  
  824.  
  825.   Now you should be able to see and manipulate the files on the boot and
  826.   supplementary disk under /mnt/boot and /mnt/supp respectively.  Phew!
  827.   Note that older versions of mount may not be able to handle the -o
  828.   loop option.  In these cases you'll need to explicitly use losetup to
  829.   configure the loopback device for each file, e.g.
  830.  
  831.  
  832.  
  833.  
  834.        # losetup /dev/loop0 boot.img
  835.        # mount -t msdos /dev/loop0 /mnt/boot
  836.  
  837.  
  838.  
  839.  
  840.  
  841.   You might also need to explicitly use the -t ext2 option when mounting
  842.   an ext2 filesystem like on the supplementary disk.  But, it looks like
  843.   people with modern Linux distributions shouldn't have to worry about
  844.   this.
  845.  
  846.  
  847.   Of course, if you don't want to mess around too much, you can cut a
  848.   corner and manipulate actual floppy disks rather than these floppy
  849.   disk images.  If time is important, you'll probably prefer to use the
  850.   loopback devices, since you can hack around with the disk images
  851.   without incurring the latency associated with a genuine floppy disk
  852.   read/write.
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.   8.  Modifying the RedHat installer
  860.  
  861.  
  862.   If you want to mess around with the installation procedure itself, the
  863.   source code can be found on the RedHat CD-ROM or your local RedHat
  864.   mirror site.  It's in misc/src/install under the i386 distribution top
  865.   level directory.
  866.  
  867.  
  868.   If you examine the RedHat boot disk you'll see that, in addition to
  869.   the Linux kernel vmlinuz, there's a large file initrd.img:
  870.  
  871.  
  872.  
  873.  
  874.        -rwxr-xr-x   1 root     root          559 May 11 15:48 boot.msg
  875.        -rwxr-xr-x   1 root     root          668 May 11 15:48 expert.msg
  876.        -rwxr-xr-x   1 root     root          986 May 11 15:48 general.msg
  877.        -rwxr-xr-x   1 root     root       968842 May 11 15:48 initrd.img
  878.        -rwxr-xr-x   1 root     root         1120 May 11 15:48 kickit.msg
  879.        -r-xr-xr-x   1 root     root         5352 May 11 15:48 ldlinux.sys
  880.        -rwxr-xr-x   1 root     root          875 May 11 15:48 param.msg
  881.        -rwxr-xr-x   1 root     root         1239 May 11 15:48 rescue.msg
  882.        -rwxr-xr-x   1 root     root          402 May 11 15:48 syslinux.cfg
  883.        -rwxr-xr-x   1 root     root       444602 May 11 15:48 vmlinuz
  884.  
  885.  
  886.  
  887.  
  888.  
  889.   You guessed it, this is another ext2 filesystem saved as a file - but
  890.   with a twist.  It's actually compressed as well!  You can uncompress
  891.   it and then mount the result, e.g.
  892.  
  893.  
  894.  
  895.  
  896.        # gzip -dc /mnt/boot/initrd.img >/tmp/initrd.ext2
  897.        # mkdir /mnt/initrd
  898.        # mount -o loop /tmp/initrd.ext2 /mnt/initrd
  899.  
  900.  
  901.  
  902.  
  903.  
  904.   Probably the most important part of this filesystem is the collection
  905.   of loadable kernel modules which are included with the boot disk.  If
  906.   you need to merge in a new version of a driver, you'll need to either
  907.   replace vmlinuz with a new kernel which has this statically linked, or
  908.   replace it in the modules collection.  What's more, you may need to
  909.   throw other modules away to make room!
  910.  
  911.  
  912.   The modules collection is the file modules/modules.cgz.  Wondering
  913.   what that might be ?  It's actually a compressed cpio archive, believe
  914.   it or not!  Here's how to hack around with it:
  915.  
  916.  
  917.  
  918.  
  919.        # gzip -dc /mnt/initrd/modules/modules.cgz >/tmp/modules.cpio
  920.        # cpio -itv <modules.cpio >modules.listing
  921.        # mkdir modules
  922.        # cpio -idumv <../modules.cpio
  923.  
  924.  
  925.   I don't believe that there is currently a way under Linux (at least in
  926.   mainstream distributions) to transparently access compressed
  927.   filesystems.  Let me know if you know better!
  928.  
  929.  
  930.   If you change anything, remember to:
  931.  
  932.  
  933.  
  934.   1. Use cpio to recreate the archive.  How to do this is left as an
  935.      exercise for the reader...
  936.  
  937.   2. Use gzip to compress the resulting archive.
  938.  
  939.   3. Copy it to /mnt/initrd, or wherever you put the uncompressed
  940.      initrd.img archive.
  941.  
  942.   4. Unmount /mnt/initrd (or whatever you called it).
  943.  
  944.   5. Compress the new initrd.img using gzip again.
  945.  
  946.   6. Copy the resulting archive onto the boot disk image -
  947.      /mnt/boot/initrd.img in our example.
  948.  
  949.   7. Unmount the boot disk image, e.g. /mnt/boot.
  950.  
  951.  
  952.   Finally, you can now create new boot floppies using this modified boot
  953.   disk setup, e.g.
  954.  
  955.  
  956.  
  957.  
  958.        # cat boot.img >/dev/fd0
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.   9.  Making your own RPMs
  967.  
  968.  
  969.   The RPM package format is already very well documented, particularly
  970.   in the book Maximum RPM by Ed Bailey, which you can download from the
  971.   RPM WWW site <http://www.rpm.org/> - also available from all good book
  972.   stores!  This is just a couple of quick hints for people in a hurry.
  973.  
  974.  
  975.   RPM packages are built from a spec file.  This consists (in a similar
  976.   fashion to the KickStart config file) of a recipe of steps that need
  977.   to be taken in order to build the package - it's expected that you'll
  978.   have to build it from source, potentially for multiple platforms, and
  979.   may need to apply patches before compiling.  Once built and installed,
  980.   a binary RPM will be created from the files and directories you
  981.   specify as being associated with the package.  It's important to note
  982.   that RPM has no idea of which files and directories are related to a
  983.   given package - you have to tell it.
  984.  
  985.   Here's a sample specification for a custom RPM of the Squid WWW cache
  986.   server <http://squid.nlanr.net/>:
  987.  
  988.  
  989.  
  990.  
  991.   Summary: Squid Web Cache server
  992.   Name: squid
  993.   Version: 1.NOVM.22
  994.   Release: 1
  995.   Copyright: GPL/Harvest
  996.   Group: Networking/Daemons
  997.   Source: squid-1.NOVM.22-src.tar.gz
  998.   Patch: retry-1.NOVM.20.patch
  999.   %description
  1000.   This is just a first attempt to package up the Squid Web Cache for easy
  1001.   installation on our RedHat Linux servers
  1002.  
  1003.   %prep
  1004.   %setup
  1005.   %build
  1006.   configure --prefix=/usr/squid
  1007.   perl -spi -e 's!#( -DALLOW_HOSTNAME_UNDERSCORES)!$1!' src/Makefile
  1008.   make
  1009.  
  1010.   %install
  1011.   make install
  1012.  
  1013.   %files
  1014.   /usr/squid
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.   Here's how to build this RPM:
  1021.  
  1022.  
  1023.  
  1024.  
  1025.        % mkdir -p SOURCES BUILD SRPMS RPMS/i386
  1026.        % cp ~/squid-1.NOVM.22-src.tar.gz SOURCES
  1027.        % cp ~/retry-1.NOVM.20.patch SOURCES
  1028.        % rpm -ba squid-1.NOVM.22+retry-1.spec
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.   This will automatically create a subdirectory under the BUILD
  1035.   directory, into which it'll unpack the source code and then apply the
  1036.   patch (there are a number of options available for patching - check
  1037.   the book for details).  Now, RPM will automatically build the package
  1038.   by running configure and then make, install it using make install, and
  1039.   take a snapshot of the files under /usr/squid.  It's the latter which
  1040.   will form the binary RPM of the Squid software.
  1041.  
  1042.  
  1043.   Note that we can insert arbitrary shell commands into the unpacking,
  1044.   building and installing processes, e.g. the call to perl which tweaks
  1045.   one of Squid's compile-time parameters.
  1046.  
  1047.  
  1048.   The final binary RPM will be left under the RPMS directory in the
  1049.   platform specific subdirectory i386.  In this case it will be called
  1050.   squid-1.NOVM.22-1.i386.rpm.  Note that the filename is created by
  1051.   concatenating the values of the following parameters from the spec
  1052.   file: Name, Version and Release - plus the hardware platform in
  1053.   question, i386 in this case.  Try to bear this in mind when creating
  1054.   your own RPMs, to avoid giving them overly long or painful names!
  1055.  
  1056.  
  1057.   It's also worth bearing in mind that you can build RPMS without having
  1058.   to rebuild the whole software package, e.g.
  1059.  
  1060.  
  1061.  
  1062.  
  1063.        Summary: Linux 2.0.35 kernel + filehandle patch + serial console patch
  1064.        Name: linux
  1065.        Version: 2.0.35+filehandle+serial_console
  1066.        Release: 1
  1067.        Copyright: GPL
  1068.        Group: Base/Kernel
  1069.        Source: linux-2.0.35+filehandle+serial_console.tar.gz
  1070.        %description
  1071.        This is just a first attempt to package up the Linux kernel with patches
  1072.        for installation on our RedHat Linux servers
  1073.  
  1074.        %prep
  1075.        echo
  1076.  
  1077.        %setup
  1078.        echo
  1079.  
  1080.        %build
  1081.        echo
  1082.  
  1083.        %install
  1084.        echo
  1085.  
  1086.        %post
  1087.        /sbin/lilo
  1088.  
  1089.        %files
  1090.        /lib/modules/2.0.35
  1091.        /boot/vmlinuz
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.   In this case we simply create an RPM based on the /boot/vmlinuz file
  1098.   and the contents of the directory /lib/modules/2.0.35, and execute
  1099.   /sbin/lilo after the package has been installed on a target machine.
  1100.   Let me know if you know much neater way of writing the spec file than
  1101.   this.
  1102.  
  1103.  
  1104.  
  1105.  
  1106.   10.  FAQs/Wish list
  1107.  
  1108.  
  1109.   Can you have all outstanding patches (update RPMs) applied
  1110.   automatically too ?  How ?
  1111.  
  1112.  
  1113.   A single config file on the install server for all of the clients,
  1114.   perhaps as a fallback after trying IPADDR-kickstart ?
  1115.  
  1116.  
  1117.   More flexibility when things go wrong - e.g. prompt for alternate
  1118.   locations if distribution not found on CD-ROM.
  1119.  
  1120.  
  1121.   Explicit exclusion of packages - e.g. everything apart from sendmail.
  1122.  
  1123.   Choose which services are started automatically on boot-up by the run-
  1124.   level scripts under /etc/rc.d/.
  1125.  
  1126.  
  1127.   When executing the shell commands in the %post section, bring any
  1128.   output up in another virtual console rather than overwriting the main
  1129.   screen.  Could be done in the shell commands section using open?.
  1130.  
  1131.  
  1132.   Does the filesystem creation code check for bad blocks ?
  1133.  
  1134.  
  1135.  
  1136.   11.  Credits
  1137.  
  1138.  
  1139.   Your name here!
  1140.  
  1141.  
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.