Redhat – How to execute a command before kickstart parses ks.cfg

kickstartredhat

How do I execute a command before kickstart parses ks.cfg?

My specific problem is that I want to install redhat into a tmpfs by telling kickstart:

part / --fstype ext3 --size 1000 --maxsize 4000 --ondisk loop1

I've tried doing:

%pre
#!/bin/sh
mkdir /tmp-root
mount -t tmpfs tmpfs /tmp-root
dd if=/dev/zero of=/tmp-root/tmp-root.img bs=4096 count=1000000
losetup /dev/loop1 /tmp-root/tmp-root.img

but that is not done early enough. Ugh!

Update: I'm beginning to think it has nothing to do with being done early enough. I believe it has to do with anaconda and kudzu not thinking that a loopback device is a valid device. I'm not a python guy, so the idea of hacking up the kickstart code sucks!

-Vinnie

Best Answer

You'll need to %include your disk config, something like this:

%include /tmp/part.ks

%pre 
cat > /tmp/part.ks <<END
part / --fstype ext3 --size 1000 --maxsize 4000 --ondisk loop1
END

mkdir /tmp-root
mount -t tmpfs tmpfs /tmp-root
dd if=/dev/zero of=/tmp-root/tmp-root.img bs=4096 count=1000000
losetup /dev/loop1 /tmp-root/tmp-root.img