Friday 11 July 2014

DISABLE TTY TO IMPROVE SERVER PERFOMANCE ON CENTOS 5 and 6 boxes

A tty is just an extra terminal session on your computer. By default, there are 6 of them running and can be accessed by pressing [Ctrl]+[Alt]+[F1] to [F6]

ttyS: Serial console terminal

USEFULNESS OF TTYS
-------------------------
This is about  how to disable extra tty's on your computer.  BECAUSE THIS CAN SAVE US MEMORY.

By default 6 tty's are enabled, and your X session (the graphical interface) is held on the 7th 

You can switch tty's using the Ctrl+Alt+Fx keys (Ctrl+Alt+F1, Ctrl+Alt+F2, etc.). 

Switching tty's can be useful if your boot or shutdown stalls, as if you switch to a random tty then back to tty1 (Alt+F1) you will see where your system has hanged.


FOR CENTOS 5 boxes
=========
SET THE VARIABLE
=========

The first thing that needs to be done is change the setting that says how many tty's are available 

To do this, you have to edit /etc/inittab 

-----
You see an entry like this:
-----

1:2345:respawn:/sbin/getty 38400 tty1
2:2345:respawn:/sbin/getty 38400 tty2
3:2345:respawn:/sbin/getty 38400 tty3
4:2345:respawn:/sbin/getty 38400 tty4
5:2345:respawn:/sbin/getty 38400 tty5
6:2345:respawn:/sbin/getty 38400 tty6
STOP THE TTY'S RUNNING

now you can edit the tty files to stop them running on system boot. Put a # in front of the tty you want to disable. Do not put a # in front of tty1! Keep at least one more tty active. 

1:2345:respawn:/sbin/getty 38400 tty1
2:2345:respawn:/sbin/getty 38400 tty2
#3:2345:respawn:/sbin/getty 38400 tty3
#4:2345:respawn:/sbin/getty 38400 tty4
#5:2345:respawn:/sbin/getty 38400 tty5
#6:2345:respawn:/sbin/getty 38400 tty6

-----------
DISALLOW ROOT LOGIN FROM DIFFERENT CONSOLES
-----------
The ”/etc/securetty” file allows you to specify which TTY devices the “root” user is allowed to login . Edit the ”/etc/securetty” file to disable any tty that you do not need by commenting them out (# at the beginning of the line).

IN CENTOS 6 BOXES:
------------------------
[root@manoj ~]# ps aux | grep tty
root 772 0.0 0.2 1964 484 tty1 Ss+ 03:18 0:00 /sbin/mingetty /dev/tty1
root 774 0.0 0.2 1964 476 tty2 Ss+ 03:18 0:00 /sbin/mingetty /dev/tty2
root 776 0.0 0.2 1964 480 tty3 Ss+ 03:18 0:00 /sbin/mingetty /dev/tty3
root 778 0.0 0.2 1964 480 tty4 Ss+ 03:18 0:00 /sbin/mingetty /dev/tty4
root 780 0.0 0.2 1964 484 tty5 Ss+ 03:18 0:00 /sbin/mingetty /dev/tty5
root 782 0.0 0.2 1964 476 tty6 Ss+ 03:18 0:00 /sbin/mingetty /dev/tty6
root 787 0.0 0.2 1976 540 hvc0 Ss+ 03:18 0:00 /sbin/agetty /dev/hvc0 38400 vt100-nav
root 818 0.0 0.3 2236 568 pts/0 R+ 03:27 0:00 grep tty
[root@manoj ~]#
NAVIGATE THROUGH THE following line in file /etc/sysconfig/init:

EXAMPLE:
---------
# What ttys should gettys be started on?
ACTIVE_CONSOLES=/dev/tty[1-6]

I changed it to 2, as I need only 2 ttys as below:
=====
ACTIVE_CONSOLES=/dev/tty[1-2]
======

Now, after reboot I see the result as below:
=====
root@manoj [~]# ps -auxf | grep -i tty
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      2666  0.0  0.0 103240   860 pts/0    S+   06:09   0:00          \_ grep -i tty
root      1974  0.0  0.0   4064   568 tty1     Ss+  05:52   0:00 /sbin/mingetty /dev/tty1
root      1976  0.0  0.0   4064   568 tty2     Ss+  05:52   0:00 /sbin/mingetty /dev/tty2
root@manoj [~]#
=====

Kool :)

No comments:

Post a Comment

Note: only a member of this blog may post a comment.