Operating System - Linux
1748200 Members
3943 Online
108759 Solutions
New Discussion юеВ

Re: kickstart issues in %post section

 
Dakotak1d
New Member

kickstart issues in %post section

Gurus,

I've been successfully doing network kickstarts for some time now, but needed to create an "all-inclusive" CDROM/(virtual CDROM via ISO image) kickstart for automated builds with no PXE/NFS/HTTP services to a physical box or VMware VM.

I generate the ISO file with custom ks.cfg & a directory with additional rpms & scripts....it boots up just fine, does what the kickstart file wants it to, up to the %post section, then stuff breaks down bigtime.

I really want to just set a few variables then cp the main post script from the cdrom to the system & execute it. I have put several echos in the %post to find out what's going on. Apparently there is a very limited shell environment at this stage...why is this different from a network build?? (Here's my post section, simplified way beyond the original so I could troubleshoot it:

%post --nochroot
echo "Here is what we have mounted" > /mnt/sysimage/opt/POST.txt
df -k >> /mnt/sysimage/opt/POST.txt
cp /cdrom/third-party/rhel_post.bash /mnt/sysimage/opt/rhel_post.bash
%post
#!/bin/bash
echo "Entering POST section" >> /opt/POST.txt
echo $SHELL >> /opt/POST.txt
ls -la /opt >> /opt/POST.txt
#export METHOD=NETWORK
export METHOD=CDROM
echo "METHOD=${METHOD}" >> /opt/POST.txt
export VER=RHEL5_32
echo "VERSION=${VER}" >> /opt/POST.txt
#
#/bin/mount -t iso96660 -o ro /dev/cdrom /cdrom
[ -f /opt/rhel_post.bash ] && cd /opt
bash -x /opt/rhel_post.bash ${VER} ${METHOD} >> /opt/POST.txt 2>&1
#####################

The ONLY output I get are a few of the echos to a file called /opt/POST.txt? (yes, with a ? at the end of it - dunno where that comes from)

The rhel_post.bash script of course never gets copied or run...

Any ideas?

7 REPLIES 7
Ivan Ferreira
Honored Contributor

Re: kickstart issues in %post section

Before starting to troubleshoot this issue, I want to ask you why do you use that script to write information that you can obtain from /etc/redhat-release and /root/anaconda-ks.cfg?
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Justin_99
Valued Contributor

Re: kickstart issues in %post section

I don't have much experience with custom dvd/cd's so just throwing this out there. Have you tried giving the full path for bash or possibly sh?

/bin/bash -x ........
Dakotak1d
New Member

Re: kickstart issues in %post section

Yes, I realize I can get that info by parsing those 2 files on the server that has just been built. I support multiple versions of RHEL, therefore I have multiple versions of ks.cfg files anyway - so if they are already unique, I find it very easy to simply pass those arguments to the common rhel_post.bash script, rather than parsing it. 6 of 1, half dozen the other. I wish the ks.cfg file was actually scriptable themselves (beyond the %pre & %post sections) & I would maintain a single copy.
Dakotak1d
New Member

Re: kickstart issues in %post section

Justin: It won't even copy the file from cdrom to /opt so that I can execute /bin/bash -x /opt/rhel_post.bash

In a --nochroot environment, I've ascertained what is mounted & available:

Filesystem 1K-blocks Used Available Use% Mounted on
/dev 127812 0 127812 0% /dev
/tmp/loop0 83264 83264 0 100% /mnt/runtime
/dev/System/root 6094400 1288952 4490876 23% /mnt/sysimage
/dev/System/tmp 4062912 139396 3713804 4% /mnt/sysimage/tmp
/dev/System/csm 507748 18768 462766 4% /mnt/sysimage/csm
/tmp/sda1 124427 11727 106276 10% /mnt/sysimage/boot
/dev 127812 0 127812 0% /mnt/sysimage/dev


So, logic would tell me that I could mount my cdrom up like so:

/mnt/sysimage/bin/mount /dev/cdrom /mnt/sysimage/media

But this does not work....

Dakotak1d
New Member

Re: kickstart issues in %post section

The %post section of my ks.cfg now looks like this:

%post --nochroot
/mnt/sysimage/bin/mount /dev/cdrom /mnt/sysimage/media
echo "Here is what we have mounted" > /mnt/sysimage/opt/POST.txt
df -k >> /mnt/sysimage/opt/POST.txt
/mnt/sysimage/bin/cp /media/third-party/rhel_post.bash /mnt/sysimage/opt/rhel_post.bash
%post
#!/bin/bash
echo "Entering POST section" >> /opt/POST.txt
echo $SHELL >> /opt/POST.txt
ls -la /opt >> /opt/POST.txt
#export METHOD=NETWORK
export METHOD=CDROM
echo "METHOD=${METHOD}" >> /opt/POST.txt
export VER=RHEL5_32
echo "VERSION=${VER}" >> /opt/POST.txt
#
[ -f /opt/rhel_post.bash ] && cd /opt
bash -x /opt/rhel_post.bash ${VER} ${METHOD} >> /opt/POST.txt 2>&1
#####################

CONTENTS of output file: /opt/POST.txt? :

Here is what we have mounted
Filesystem 1K-blocks Used Available Use% Mounted on
/dev 127812 0 127812 0% /dev
/tmp/loop0 83264 83264 0 100% /mnt/runtime
/dev/System/root 6094400 1288952 4490876 23% /mnt/sysimage
/dev/System/tmp 4062912 139396 3713804 4% /mnt/sysimage/tmp
/dev/System/csm 507748 18768 462766 4% /mnt/sysimage/csm
/tmp/sda1 124427 11727 106276 10% /mnt/sysimage/boot
/dev 127812 0 127812 0% /mnt/sysimage/dev
Entering POST section
/bin/bash
total 24
drwxr-xr-x 2 root root 4096 Mar 6 19:00 .
drwxr-xr-x 23 root root 4096 Mar 6 19:00 ..
-rw-r--r-- 1 root root 625 Mar 6 19:00 POST.txt
METHOD=CDROM
VERSION=RHEL5_32

Justin_99
Valued Contributor

Re: kickstart issues in %post section

Oops yeah guess I overlooked that detail. Again I do not have much experience with "self contained" dvd's and post scripting. Is it possible that maybe the device links for /dev/cdrom are just not there? Possibly try /dev/hda as the device. One would think they would be there since the system has for the most part finished installing.

# ls -ld /dev/cdrom
lrwxrwxrwx 1 root root 3 Sep 10 12:45 /dev/cdrom -> hda
Dakotak1d
New Member

Re: kickstart issues in %post section

Mystery solved. A pitfall of working in a joint windows/linux environment.DOS put special characters in the ks.cfg file that I did not see & had me chasing down other avenues. After running ks.cfg through dos2unix, which strips them out, I was good to go: dos2unix ks.cfg > ks.cfg.clean; mv ks.cfg.clean ks.cfg