0

When my b+ (raspbian 3.18.12+) boots, it actually loads 6 tty.

Is there a way to reduce the number of tty?

  • Could you check if this procedure works out: crunchbanglinux.org/wiki/howto/disable_extra_ttys (I have no raspbian available right now and arch seems to use a different sytem (systemd/logind)). – Ghanima May 7 '15 at 12:45
  • With this procedure, I can't access to my raspberry anymore $> ssh -vvv user@ip => ssh: connect to host "ip" port "X": Connection refused – Jérémy Pouyet May 7 '15 at 12:59
  • All you need to do is comment out the lines in inittab -- ignore that bit about /etc/securetty at the end. – goldilocks May 7 '15 at 13:08
2

When my b+ (raspbian 3.18.12+) boots, it actually loads 6 tty.

If you look at ls /dev, you'll see the kernel in fact creates 64 tty devices that are exported by udev, not including special ones such as the serial port. I'm not sure what the reason for this is; I could not find a kernel config option for changing it, but you can "hide" them by not having them exported to /dev. However, I'd guess the logic is better too many than too little since if they are not used for anything, they do not represent any use of resources beyond perhaps a few bytes of kernelspace (if that).

But I think what you are actually referring to are the login getty applications that run by default on tty1-6. These are started by init.

These use almost no resources as well, so if that is your justification, save yourself some time and don't worry about it. On a system using SysV init such as Raspbian Wheezy, they'll probably show up with ps -A | grep getty; there's one on the serial port too, which makes 7. Pick one and have a look in top at the RES and SHR numbers. I get ~1600 bytes for the former and ~1500 bytes for the latter, which is shared memory. All seven of them will be sharing that, so what each one really adds to RAM is -- gasp -- ~100 bytes of memory. Closing six of them would therefore only save you a little over a 1/2 kB, i.e., 0.0001 % of the 512 MB total.

It is not hard to do if you want though. This is specific to SysV init, which is Raspbian Wheezy; Jessie and other pi distros use a different init system by default. Open /etc/inittab for editing and find this section:

# Note that on most Debian systems tty7 is used by the X Window System,
# so if you want to add more getty's go ahead but skip tty7 if you run X.
#
1:2345:respawn:/sbin/getty --noclear 38400 tty1 
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

You can comment out any of those lines but I would leave at least the first one. This will prevent the spawning of getty on those ttys. It won't prevent the ttys from existing, but all you will see on them is a blank screen, unless some output has been directed there (e.g., try as root, sudo will not work: echo "hello!" > /dev/tty4 and then switch over to look).

  • I've commented the tty 3 to 6 and I can't ssh to my raspberry pi anymore – Jérémy Pouyet May 7 '15 at 13:10
  • That is pretty odd. I just tried this (commenting out 3-6) on a wheezy B and had no such problem. Try uncommenting them without changing anything else just to confirm the issue. Also, if you have a screen attach that and see if boot otherwise looks normal. – goldilocks May 7 '15 at 13:20
  • I've connected a keyboard to the raspberry and I've uncommented the lines. I can re access the pi by ssh. I can't try the procedure anymore until Monday. I keep you informed – Jérémy Pouyet May 7 '15 at 13:38
  • You could also try leaving them uncommented, but change the 23 of the ones you don't want to 45. Those are the runlevels (1-5) these happen in; the default is 2, so the ones without that won't start then. That maybe a more correct method. – goldilocks May 7 '15 at 13:48
  • I don't know why but after a second try, this answer works. – Jérémy Pouyet May 27 '15 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.