Gentoo Kernel – Change Number of Generated /dev/tty Devices

devicesgentookerneltty

I'm building an embedded Linux system, based on Gentoo. Using udev, all tty devices are probed with a PROGRAM stanza to determine if they are a modem.

Right now the system boots up with 64 /dev/tty*. When udev probes the tty devices, the system runs out of memory.

How can I reduce the number of produced tty devices to 4? Is this an OS setting or a kernel setting?

Best Answer

I'm not sure exactly how the device nodes are created (i.e. the exact sequence of events that lead to their creation), but I'm pretty sure the kernel creates the underlying devices for the 63 /dev/ttyN devices (plus /dev/tty) internally, and udev does the work of making them available inside /dev (except for /dev/tty and /dev/tty1 which are created by /etc/init.d/udev-mount with mknod).

I don't think you can limit the number of kernel devices via configuration.

Here is a workaround if you want to limit the number of devices that appear in your /dev though. Create a /etc/udev/rules.d/99-my-tty-rules.rules file and put something like the following in it:

KERNEL=="tty[2-9][0-9]", RUN="/bin/rm /dev/%k", OPTIONS+="ignore_device"

This will get rid of tty device files numbered 20 and above.

Notes:

  • Using rm in there looks really strange, but I can't find a way to not create the node in the first place
  • Playing with these entries a bit too enthusiastically can lead to interesting problems - use with caution.