From BStegmaier

Jump to: navigation, search

Useful only on systems used by one single user (e.g. personal notebook). startx is initiated after all runlevel services has been started. If you want to start X earlier, you would have to write an initscript.

  • Install rungetty
  • Add the following line to /etc/inittab
    • loginuser is the user to be logged in, runasuser, runasgroup are the user and group as which the startx script is executed
    • In this case tty2 is the terminal for X debug logging (terminal number has to be equal to the first column). X uses the first unused terminal it detects
    • rungetty is executed when entering one of the runlevels 2 to 5
/etc/inittab
2:2345:respawn:/sbin/rungetty --autologin loginuser -u runasuser -g runasgroup tty2 /somepath/startx.sh
  • Create /somepath/startx.sh and chmod +x
startx.sh
#!/bin/sh

# set some environment variables
HOME=/home/user
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/games:/sbin:/usr/sbin:/usr/local/sbin:/usr/games

# set language,..
[ -f /etc/environment ] && . /etc/environment

# change to $HOME, otherwise the working directory in X is /
cd

# finally start the x server
/usr/bin/startx