HOWTO Redirect Linux Console Without Reboot

You can re-apply your /etc/inittab file in real-time without rebooting your machine. This allows you to do a lot of neat things, such as redirect your system console to the serial port without a reboot.

  1. Edit your /etc/inittab file and add this line:
    • S0:12345:respawn:/sbin/agetty -L 9600 ttyS0 vt102
  2. Execute the following command:
    • telinit q && telinit u
  3. Your primary console (ttyS0) should magically appear on the serial console!

So what just happened? The /etc/inittab file is read by the init system at boot. If you added the line from step 1 and simply rebooted, you would have your console show up on the serial port right away. We told init to re-read the /etc/inittab file (telinit q) and then to re-execute itself (telinit u) while preserving the init state. Since the only change was the location of ttyS0, the console was redirected, but the system continued to run as though nothing else changed.

The reason we used the && method was because we may loose our console before we get a chance to execute telinit u. This way both commands are run and init is always executed after re-reading its config.

Did you find this post useful or have questions or comments? Please let me know!

This entry was posted in How Tos, linux. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *