J. Mike Rollins (Sparky) [rollins@wfu.edu]
  CISSP, GIAC GPEN
Hyperbola New
My Cats New
Kitty New
Mike is on
  LinkedIn
  FaceBook
BackYardGreen.Net
HappyPiDay.com
Green Cycle Design Group
CamoTruck.Net
  Resume  
  My Stuff  
  Art  
  My Truck  
  People  
Electronics
Jacob's Ladder
Scripts
Math
Notes
My House
My Cars
My Cats New
My Jokes
Pi Poetry
pumpkin
Toro Mower
Development
Speed of a Piston
Not a Pipe
Linux
   Home Linux
   RTIR
















Home Linux

My Home Linux System

June 23, 2007

I spent a while working on my home system. I kept good notes at the beginning, but that did not last long. So, now I am forcing myself to create this web page for future reference.

DISCLAIMER: The following worked for me, I do not guarantee these notes are accurate. I do not guarantee that they will work for you.

My goals were numerous. I wanted the ability to reboot the machine and choose from the following:

  • re-install various Fedora versions from local media using manual configuration.
  • re-install various Fedora versions from local media using an automated process.
  • perform as a kickstart/pxe server. In this mode I can have my other computers kickstart install using pxeboot.
The drives sda and sdb will execute the above goals. The disks sdc and sdd will be the targets of the re-install process.

Notes

When running multiple version of Fedora/RedHat you can tell the versions apart by inspecting the contents of the RedHat release file:
   cat /etc/redhat-release 

Basic System

I started with two drives: sda and sdb. I use them in a RAID1 setup. I installed Fedora Core 5 from an old kickstart setup. Here is the listing of /dev/sda. I played around with the raid configuration and now the partitions are not in disk order. The second disk, /dev/sdb, is layed out the same way.

   [root@terry ~]# fdisk -l /dev/sda

   Disk /dev/sda: 320.0 GB, 320072933376 bytes
   255 heads, 63 sectors/track, 38913 cylinders
   Units = cylinders of 16065 * 512 = 8225280 bytes

      Device Boot      Start         End      Blocks   Id  System
   /dev/sda1   *           1          33      265041   fd  Linux raid autodetect
   /dev/sda2              34          66      265072+   b  W95 FAT32
   /dev/sda3              67       10509    83883397+  fd  Linux raid autodetect
   /dev/sda4           10510       38913   228155130    5  Extended
   /dev/sda5           14687       15730     8385898+  fd  Linux raid autodetect
   /dev/sda6           15731       15861     1052226   fd  Linux raid autodetect
   /dev/sda7           10510       14686    33551721   fd  Linux raid autodetect
   
   Partition table entries are not in disk order
I use the /data file system to store files I want to keep. I serve out the file system with Samba and NFS. I also have a Subversion repository in /data.
   [root@terry ~]# df -h
   Filesystem            Size  Used Avail Use% Mounted on
   /dev/md3              7.8G  3.7G  3.7G  51% /
   /dev/md0              251M   15M  224M   7% /boot
   /dev/md5               78G   18G   56G  24% /data
   tmpfs                 500M     0  500M   0% /dev/shm
   /dev/md4               32G   19G   12G  62% /pub

ISO Images

The /pub filesystem is devoted to linux. This filesystem is a RAID1 mirror composed of sda7 and sdb7. Many Fedora distributions are store in /pub along with some kickstart scripts and other scripts.
   [root@terry pub]#  ls -l /pub/linux/fedora/
   total 12
   drwxr-xr-x 5 root root 4096 Jun 17 06:49 5
   drwxr-xr-x 5 root root 4096 Jun 17 22:23 6
   drwxr-xr-x 6 root root 4096 Jun 19 11:46 7
Each of these directories contains three sub directories: iso, mnt and net. The ISO directory contains the DVD image of Fedora. I found that the ISO image is required when installing from local media. The NFS or HTTP installs only require a filesystem view of the CDs, but the local install requires the ISO.
   [root@terry ~]# ls -l /pub/linux/fedora/?/iso/*
   -rw-r--r-- 1 root root 3260809216 Jun 20 06:19 /pub/linux/fedora/5/iso/FC-5-i386-DVD.iso
   -rw-r--r-- 1 root root 3526717440 Jun 18 14:27 /pub/linux/fedora/6/iso/FC-6-i386-DVD.iso
   -rw-r--r-- 1 root root 2894616576 Jun 18 19:23 /pub/linux/fedora/7/iso/F-7-i386-DVD.iso

Automounter

You can mount an ISO image file to view its contents: mount -o loop FC-6-i386-DVD.iso /mnt. I figured this would be a good use of the automounter service. The mnt directory contains the mount point for the iso image. The following shows the additions to the /etc/auto.master. Remember to make sure the autofs service is running and will start upon boot.
   [root@terry ~]# cat /etc/auto.master 
   # ...
   /pub/linux/fedora/5/mnt         /etc/auto.fedora5
   /pub/linux/fedora/6/mnt         /etc/auto.fedora6
   /pub/linux/fedora/7/mnt         /etc/auto.fedora7
   # ...

   [root@terry ~]# chkconfig --levels 345 autofs on
   [root@terry ~]# service autofs restart
Each linux distribution will require an additional entry in the /etc/auto.master file. Here is the contents of the /etc/auto.fedora6 file:
   [root@terry ~]# cat /etc/auto.fedora6 
   dvd      -fstype=iso9660,ro,nosuid,nodev,loop      :/pub/linux/fedora/6/iso/FC-6-i386-DVD.iso
I now have the ISO image that is necessary for installation from local media. And the mnt directory provides the contents of the ISO. Later, we will have to unpack the iso and make a slight modification.
   [root@terry ~]# ls -l /pub/linux/fedora/6/mnt/dvd
   total 336
   -r--r--r-- 1 root root   5625 Mar  8  2006 eula.txt
   dr-xr-xr-x 4 root root   2048 Mar 14  2006 Fedora
   -r--r--r-- 1 root root   2307 Mar 14  2006 fedora.css
   dr-xr-xr-x 3 root root   2048 Mar 14  2006 figs
   -r--r--r-- 1 root root  18385 Apr  5  2005 GPL
   dr-xr-xr-x 4 root root   2048 Mar 14  2006 images
      ...
      ...

Prepare for HTTP and NFS

With automounter, the mount point does not always respond well to directory listings. The net directory contains symlinks to the various directories necessary for the NFS and HTTP install. This provides a permanent link so the web server can navigate into the automounted files.
   [root@terry ~]# cd /pub/linux/fedora/6/net
   [root@terry net]# ln -s ../mnt/dvd/Fedora 
   [root@terry net]# ln -s ../mnt/dvd/images
   [root@terry net]# ln -s ../mnt/dvd/repodata
I had to configure the web server to allow access to this directory. I added the following to the /etc/httpd/conf/httpd.conf file. Remember to make sure the web server will start upon reboot.
   [root@terry net]# vi /etc/httpd/conf/httpd.conf 
   # ...
   Alias /pub "/pub"
   <Directory "/pub">
       Options Indexes MultiViews FollowSymLinks
       Order allow,deny
       Allow from all
   </Directory>
   # ...
   
   [root@terry net]# chkconfig --level 345 httpd on
   [root@terry net]# service httpd restart

Interactive installs with images/diskboot.img

Each Fedora distribution contains a boot file, images/diskboot.img. I wrote this image to my sda2 partition. This partition is grossly over-sized for this purpose.
      Device Boot      Start         End      Blocks   Id  System
   /dev/sda1   *           1          33      265041   fd  Linux raid autodetect
   /dev/sda2              34          66      265072+   b  W95 FAT32
Zero out the partition and then write the diskboot.img file to the partition.
   dd if=/dev/zero of=/dev/sda2 bs=512
   dd if=/pub/linux/fedora/6/mnt/dvd/images/diskboot.img of=/dev/sda2
Next, we need to configure the /boot/grub/grub.conf file to boot to this partition.
   title New Install (Fedora Core 6) diskboot.img
           rootnoverify (hd0,1)
           chainloader +1
The sdb2 partition contains the diskboot.img file for Fedora Core 5.

Grub should now allow us to boot into this image and begin an interactive install. You will need to provide the disk and directory of the iso image. Since we use RAID1, we can specify either sda7 or sdb7. The directory you specify is relative to the root of the filesystem. We would use the directory linux/fedora/6/iso. The /pub is just our mount point.

Automated install with images/pxeboot/*

After going through the interactive install the /root/anaconda-ks.cfg file will contain the information needed for an automated reload of sdc and sdd.

In addition to the /pub/linux directory, I also have a /pub/ks directory that contains the kickstart scripts. So, I would copy anaconda-ks.cfg from this install into the /pub/ks directory. To keep track of the version, I name these files with the version number: /pub/ks/reload_ks-N.cfg.

Next, update the kickstart file with the necessary drive layout. You will need to specify the install type to be harddrive.

   install
   harddrive --partition=sda7 --dir=linux/fedora/6/iso
The Fedora distributions contain a pxeboot image to use for kickstart installs. The directory images/pxeboot/ contains the files initrd.img and a vmlinuz. We can use grub to boot into these images.

There is one more problem. How will the install image read this kickstart file? We can explicitly configure grub to look for the kickstart file. We can use the ks=file:/path/to/file.cfg parameter to load the kickstart file. But the kernel is reading from the initrd filesystem at this point. So, we need to add our kickstart file to the initrd.img file. We will do something like this to create the initrd file for reloading Fedora Core 6:

   mkdir /tmp/initrd
   cd /tmp/initrd
   gunzip -c /pub/linux/fedora/6/net/images/pxeboot/initrd.img | cpio -i
   cp /pub/ks/reload_ks-6.cfg /tmp/initrd/reload_ks.cfg 
   find . -print | cpio -c -o | gzip -9 -c > initrd_reload-6.img
Now the installer will be able to find our kickstart file in the root of the initrd. We will pass the parameter ks=file:/reload_ks.cfg to the kernel image via grub. I copied the initrd and vmlinuz files to my /pub/images directory. So, my grub entry looks like the following:
   title Reload (Fedora Core 6)
           root (hd0,6)
           kernel /images/vmlinuz-6 ks=file:/reload_ks.cfg
           initrd /images/initrd_reload-6.img
The root (hd0,6) indicates these images are on the seventh partition (6) of the first disk (0). This is the same as /dev/sda7.

Post install remorse

We used the /pub iso images to install linux, but these files are not accessible after reboot. You can use the %post part of the kickstart file to configure this filesystem for use.

I've acquired quite a collection of customizations over the past year. I created a shell script that implements these customizations. I zip-up all of these scripts into one tar file. This archive can easily be obtained via TFTP or HTTP for network PXE boot installs. In this case, I copy the tar file directly from the /pub filesystem. But we first have to mount the /pub filesystem.

This is the post section from my kickstart file for Fedora Core 6. First, I create a mount point in the /root directory. I then mount the device that contains the /pub filesystem. Since /dev/sda7 is being used as part of the install, I will mount /dev/sdb7 to avoid potential conflicts.

   %post
   #!/bin/bash

   cd /root
   mkdir /root/mnt
   mount -t ext3 -o ro /dev/sdb7 /root/mnt
   
   # you can now read the contents from the pub filesystem and execute scripts from the filesystem.

   cd /root && tar xvf /root/mnt/post/terry_fc6.tar
   cd /root/terry_fc6 && ./copy_install.bash
One of the tasks of my copy_install.bash script is to update /etc/fstab with an entry for /pub. Another task is to configure the automounter system just like we did earlier. When the system reboots, I should now have access to the contents of the ISO images.

In addition to fstab and automounter, I also have customizations to the following: /etc/bashrc, /etc/dhcpd.conf, /etc/sysconfig/iptables, /etc/exports, /etc/samba/smb.conf, named.conf, sshd keys, subversion, vnc config, xorg config and yum repo config.

Yum

Now that /pub is mounted we can install RPMs using the rpm command. For example rpm -ivh /pub/linux/fedora/6/net/Fedora/RPMS/zlib-devel-1.2.3-3.i386.rpm. But, what about yum?

I first disabled the default repositories so I could focus on installing from the local rpms. Next, I created a yum repository to reference the rpms in /pub.

  [root@terry ~]# cat /etc/yum.repos.d/local-dvd.repo
  [dvd]
  name=Fedora Core DVD
  baseurl=file:///pub/linux/fedora/6/mnt/dvd
  enabled=1
  gpgcheck=0

Yuck

Now that yum is configured, we should be able to install. But, we have a problem. I get the following error when trying to use yum from this local repository.
   [root@terry yum.repos.d]# yum install "zlib*"
   Loading "installonlyn" plugin
   Setting up Install Process
   Setting up repositories
   Reading repository metadata in from local files
   Parsing package install arguments
   Resolving Dependencies
   --> Populating transaction set with selected packages. Please wait.
   ---> Downloading header for zlib-devel to pack into transaction set.
   media://1161131669.029329%232/Fedora/RPMS/zlib-devel-1.2.3-3.i386.rpm: 
       [Errno 4] IOError: <urlopen error unknown url type: media>
   Trying other mirror.
   Error: failed to retrieve Fedora/RPMS/zlib-devel-1.2.3-3.i386.rpm from dvd
   error was [Errno 4] IOError: <urlopen error unknown url type: media> 
I think this results from the use of a repository index intended for the CD, not our file location. You will see references to media://1161131669.029329 in the file /pub/linux/fedora/6/mnt/dvd/repodata/repomd.xml. We need to make a new index of this repository using our file reference.

createrepo

The createrepo command will repair the repository index. "This utility will generate a common metadata repository from a directory of rpm packages." (rpm -qip createrepo-0.4.4-2.fc6.noarch.rpm) Since /pub is mounted, we have the rpm on this local machine, so we don't need yum to install this utility.
   rpm -ivh /pub/linux/fedora/6/mnt/dvd/Fedora/RPMS/createrepo-0.4.4-2.fc6.noarch.rpm 
We will now rebuild the repository. We will stop automounter, copy the DVD ISO's contents, create the repo and rebuild the ISO image.
   # stop the automounter
   service autofs stop

   cd /pub/linux/fedora/6/mnt

   # mount the iso in an alternate location
   mkdir /mnt/dvd
   mount -o loop //pub/linux/fedora/6/iso/FC-6-i386-DVD.iso /mnt/dvd

   # copy the contents.  
   # WARNING: make sure your local directory is the intended destination!
   #          I made this mistake once and destroyed a few hundred web pages.
   tar cvf - -C /mnt dvd | tar xvf -
   umount /mnt/dvd


   # I don't know what purpose this directory serves, but we need to remove it.
   rm -rf /pub/linux/fedora/6/mnt/dvd/.olddata

   # Create the repository.  
   # -g 
   #    This indexes information for groups of rpms.
   #    A group file is necessary for this index.
   cd /
   createrepo -g Fedora/base/comps.xml /pub/linux/fedora/6/mnt/dvd

   # let's rename to original iso image and create the new iso image
   cd  /pub/linux/fedora/6/iso/
   mv FC-6-i386-DVD.iso original_FC-6-i386-DVD.iso

   # lots of options to mkisofs. (I don't know what they all mean either).
   # I compared the md5sum of each file from the new iso to that of the filesystem and found no discrepancies.
   cd  /pub/linux/fedora/6/mnt/
   mkisofs -r -R -J -l -L -allow-multidot -o ../iso/FC-6-i386-DVD.iso  -graft-points "/=dvd"

   # we don't need the dvd directory anymore
   rm -rf /pub/linux/fedora/6/mnt/dvd

   # restart the automounter
   service autofs start
Let's now test this new iso image. We saw that the file /pub/linux/fedora/6/mnt/dvd/repodata/repomd.xml contained references to media://1161131669.029329. You can inspect this file to see that the reference to media:// is gone.

Clean out the old yum cache and update it with the new information. Now when we run yum, we get the expected result.

   [root@terry ~]# yum clean all
   Loading "installonlyn" plugin
   Cleaning up Everything

   [root@terry ~]# yum install "zlib*"
   Loading "installonlyn" plugin
   Setting up Install Process
   Setting up repositories
   dvd                       100% |=========================| 1.1 kB    00:00     
   Reading repository metadata in from local files
   primary.xml.gz            100% |=========================| 811 kB    00:00     
   ################################################## 2242/2242
   Parsing package install arguments
   Resolving Dependencies
   --> Populating transaction set with selected packages. Please wait.
   ---> Downloading header for zlib-devel to pack into transaction set.
   zlib-devel-1.2.3-3.i386.r 100% |=========================| 7.1 kB    00:00     
   ---> Package zlib-devel.i386 0:1.2.3-3 set to be updated
   --> Running transaction check
   
   Dependencies Resolved
   
   =============================================================================
    Package                 Arch       Version          Repository        Size 
   =============================================================================
   Installing:
    zlib-devel              i386       1.2.3-3          dvd               100 k
   
   Transaction Summary
   =============================================================================
   Install      1 Package(s)         
   Update       0 Package(s)         
   Remove       0 Package(s)         
   
   Total download size: 100 k
   Is this ok [y/N]: