3

While anaconda kickstart installer runs the "Performing post-installation setup tasks" tasks are not visible on console and their outcome is only saved to ks-post.log file.

I do want to also display it on the console as these steps could take a long time and there is a clear need to see what happens in real time.

How can I do this?

sorin
  • 7,668
  • 24
  • 75
  • 100

3 Answers3

4

I have used a method similar to what is shown below.

Logging %pre and %post

When using a %pre or %post script you can simply log the output to a file by using --log=/path/to/file

%post --log=/root/my-post-log
echo 'Hello, World!'
enter code here

Another way of logging and displaying the results on the screen would be the following:

%post
exec < /dev/tty3 > /dev/tty3
chvt 3
echo
echo "################################"
echo "# Running Post Configuration   #"
echo "################################"
(
echo 'Hello, World!'
) 2>&1 | /usr/bin/tee /var/log/post_install.log
chvt 1

From: https://wiki.centos.org/TipsAndTricks/KickStart

Aaron Copley
  • 12,345
  • 5
  • 46
  • 67
  • Clearly you answer and link look quite valid but the real life testing was not so good, the "Performing post-installation setup tasks" was still silent even after implementing that change. I should mention that I am using a serial console deployment and I suspect this may have somethign to do with it. https://github.com/ssbarnea/harem/blob/master/roles/dsm/defaults/main.yml#L37 – sorin Dec 05 '18 at 19:07
  • 1
    Yes, that detail is important since there are no VTY when using serial and thus `chvt` wouldn't work. Sorry.. I don't know of a way to do it via serial. – Aaron Copley Dec 05 '18 at 21:28
  • You could try to write the log to `/proc/self/fd/1`. Depending on the startup procedure for the post script, it eventually could work. Otherwise checking for the pid of the process using the serial device (e.g. lsof) could get the right pid to write output into /proc//fd/1. – hargut Jun 03 '19 at 18:56
3

I don't see any obvious way in the docs to log the %post script to console, but if you really need to see the script output while it's still running during installation, then you might try switching to another virtual console and running tail -f /mnt/sysimage/root/ks-post.log.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
0

Not sure how it will work with a serial console, but this is how I show progress on TTY3:

%post --interpreter /bin/bash

printf "\r\nChanging output to TTY 3; press Alt-F3 to view\r\n" > /dev/tty1

{
## do stuff
} 2>&1 | tee /root/postinstall.log > /dev/tty3
%end

See https://unix.stackexchange.com/questions/350415/cant-monitor-kickstart-post-install-log

miken32
  • 930
  • 1
  • 11
  • 32