Kickstart post install tips for customizing your own distribution

Posted in Linux , howto , tweaks

Oh %post install, what would I do without you?


Switch virtual terminals

This can be handy for outputting information that might be useful to the installer. You can switch to one terminal then switch to another later on.

%post
chvt 5
echo "do stuff"
chvt 1

Install files into the system

You’re in a chroot while the kickstart post install is running. Therefore, you can’t just move around files at their normal location because it will only take effect within the chrooted environment.

%post --nochroot
cp /etc/resolv.conf /mnt/sysimage/etc/resolv.conf

Record the installation time and date

You should make sure the clock is set first. It might be a good idea to force ntpdate on your preferred time server and then echo the date into a file because if the system clock is bad, installation date might be epoch zero or something else that’s pretty much useless.

%post --nochroot
date --iso-8601=minutes > /mnt/sysimage/root/system-install-info
echo "installed with ks.cfg" >> /mnt/sysimage/root/system-install-info

Got Networking?

Something about worlds and oysters comes to mind… If you have network access during the installation, you can pretty much do anything you want.

Try mounting a remote file system that contains installation specific scripts. Once mounted, you can just execute them to act on your local system. You could have dir/file overlays for dropping into home directories, find and replace strings in system files for where you need a little tweak such as a proxy setting for wget and yum or flipping a variable setting.

The %post install section of the kickstart file, (usually named ks.cfg), provides an almost unlimited means of customizing an installation that’s extremely useful to fill in where distribution packaging tools such as revisor fall short.

Posted by admica   @   2 August 2010

Related Posts

Like this post? Share it!

Digg Twitter StumbleUpon Delicious Technorati Facebook RSS

4 Comments

Comments
Jan 28, 2011
8:57 am
#1 Valent Turkovic :

I tried coping files in %post part of Fusion Linux kickstart but anything with /mnt/sysimage/ gives file doesn’t exist error :(

We currently use this scheme:
%post –nochroot
cd /home/fusion-linux/temp/imgcreate-*
cd install_root
INSTALL_ROOT=$(pwd)
echo $INSTALL_ROOT

then we just use $INSTALL_ROOT to copy files into LiveCD enviroment like this:
cp -fR Examples/ “$INSTALL_ROOT/etc/skel/Desktop/” # copy sub directories and all files

Hope this helps somebody.

Jan 28, 2011
9:34 am
#2 admica :

Because it’s a chroot by default, you can’t access anything outside of that chrooted environment. As long as you’re just moving files around and not trying to use paths that exist in the installed product, you can just work in the “nochroot” using the full mounted path. The only time you’re stuck with the chroot is when you want to run commands on the installed system that will operate on files such as chkconfig for example.

chkconfig would try to make links in /etc/rc.d/rcX.d/ but what you would need it to do from a nochroot is /mountpath/etc/rc.d/rcX.d/. Perhaps there’s a mechanism I don’t know about such as rpmbuild’s $RPM_BUILD_DIR that can be set globally, but it would be really hard to enforce system wide unless it was part of the shell itself I think.

Feb 17, 2011
11:48 pm
#3 jayesh :

Try mounting a remote file system that contains installation specific scripts. Once mounted, you can just execute them to act on your local system.

can u detailt it how to mount a perl script residing on NFS and execute in %post

Feb 18, 2011
1:15 pm
#4 admica :

This should be pretty easy…
%post
# bring up your network interface
dhclient eth0 || ifup eth0
# start nfs in whatever manner is best for your dist.
/etc/init.d/nfs start || service portmap start
# mount
mkdir /mnt/dir && mount -t nfs 192.168.10.1:/exportdir /mnt/dir

Leave a Comment

Name

Email

Website

Previous Post
« Microsoft Bing Maps Street Slide too good to be true?
Next Post
Convert pixel based images to vector graphics files »
Powered by Wordpress   |   Lunated designed by ZenVerse