[ale] bug in RHEL5/CentOS anaconda breaks DVD kickstart install

Jim Kinney jim.kinney at gmail.com
Wed May 13 11:04:20 EDT 2009


For the archives

Scenario: A single disk, automatic kickstart installation of RedHat
5.x or CentOS 5.x with a custom embedded ks.cfg file. The kickstart
%Post section is used to install the custom application file(s) from
the install disk and make some scripted configuration changes.

Problem: Disk ejects and file is not copied from disk to new system -
really fouls up things in vmware and there is no notice the disk
ejects.

Solution: Hack and fix the anaconda setup in the install disk to
correct the bug.

HowTo:

mount iso of DVD image.
copy all contents to a working directory (/opt/images/working_files).
Copy .diskinfo file from DVD image to working_files.
cd <working_files>/images
the file stage2.img is a squashfs filesystem that has the anaconda
installation process.
squashfs is a _read_only_ filesystem so make a pair of directories,
one to mount to (tmp) and another to copy to(new_stage2).
The file to work on is usr/lib/anaconda/dispatch.py
edit the file and change:

("methodcomplete", doMethodComplete, ),
("dopostaction", doPostAction, ),

for

("dopostaction", doPostAction, ),
("methodcomplete", doMethodComplete, ),


mksquashfs is used to rebuild the new stage2.img.
Replace the busted stage2.img with the new one in working_files/images/

Now put your ks.cfg file in working_files/
edit isolinux/isolinux.cfg and change default boot line to:

label linux
  kernel vmlinuz
  append initrd=initrd.img ks=cdrom:/ks.cfg

recreate the DVD image with the script below:

#!/bin/sh

cd /opt/images/working_files

mkisofs -r -T -J -V "Custom RHEL5 Build" -b isolinux/isolinux.bin -c
isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o
/opt/images/customRHEL5.1-x86_64.iso /opt/images/working_files/



Now you have a file called /opt/images/customRHEL5.1-x86_64.iso that
will install the appliance and NOT eject the DVD before your custom
code is in place

NOTE: Here's a working %POST section that takes a self-executing
tarball and plops it in /root and preps system to autologin as root to
finalize config

%post  --nochroot
# put tarball copy and extraction here
/mnt/sysimage/bin/mount -t iso9660 /tmp/cdrom /mnt/source
/mnt/sysimage/bin/touch /mnt/sysimage/root/.bashrc
/mnt/sysimage/bin/echo "./codeloader" >> /mnt/sysimage/root/.bashrc
/mnt/sysimage/bin/sed -i 's/tty1/--autologin root tty1/'
/mnt/sysimage/etc/inittab
/mnt/sysimage/bin/cp /mnt/source/codeloader /mnt/sysimage/root/
umount /mnt/source


The file codeloader is a self-executing tarball created with a header
file called header.sh :
#!/bin/bash
SKIP=`awk '/^__TARFILE_FOLLOWS__/ { print NR + 1; exit 0; }' $0`
#remember our file name
THIS=`pwd`/$0
# take the tarfile and pipe it into tar
tail -n +$SKIP $THIS | tar -x
#
./payload.sh
clear
sleep 2s
echo "Finished with codeloader"
sleep 3s
exit 0
# NOTE: Don't place any newline characters after the last line below.
__TARFILE_FOLLOWS__


Be sure to end the header.sh file with the cursor at the end of the
__TARFILE_FOLLOWS__ or else it will break the tarball extraction.
Create a tarball (tar cvf tarball.tar foo bar, etc) and cat header.sh
tarball.tar > codeloader
the line ./payload.sh runs a script called payload.sh that is
unpackaged from tarball.tar and is the next step in the process to do
final appliance configuration.

Enjoy!

-- 
-- 
James P. Kinney III
Actively in pursuit of Life, Liberty and Happiness


More information about the Ale mailing list