How to have X at startup on FreeBSD using xdm

This may be obvious for most Un*x users but this is a question I’m asked so frequently…

If you don’t have Xorg already installed, it may be a good idea to start by installing it:

# cd /usr/ports/x11/xorg && make config-recursive install clean

The FreeBSD ports system will take care of building and installing needed dependencies, using the config-recursive rule will ask the port system to bring you all the dependencies’ config menu before starting any compilation operation.
This should work smoothly but sometimes there is still a config menu that config-recursive did not find, so don’t be surprised if one pop up in the middle of the dependencies compilation.

Once X is built and installed, let’s try to auto-generate a xorg.conf file and start X with this brand new conf:

# Xorg -configure
# Xorg -config /root/xorg.conf.new

If you can see that the X server is running, then move this working xorg.conf to his default place and give startx a try:

# mkdir -p /etc/X11/
# cp /root/xorg.conf.new /etc/X11/xorg.conf
# startx

You should have twm launched, a very basic window manager, for some reason on my machine my mouse and keyboard were disabled and I had to add this to my xorg.xonf to get them running properly:

Section "ServerFlags"
Option "AllowEmptyInput" "false"
EndSection

I personnaly dislike twm and I want to use fluxbox as my window manager:

# cd /usr/ports/x11-wm/fluxbox && make install clean
# echo "exec startfluxbox" > ~/.xinitrc

startx looks in the user’s home folder for this .xinitrc to know which window manager you want to use.
Using startx, you should be now in the fluxbox window manager (good bye twm).

Your X server is up and running a nice window manager, but you want more !
I’m a lazy guy and typing startx& ; exit after each boot is too much for me, so let’s install xdm:

# cd /usr/ports/x11/xdm/ && make install clean

Just like startx, xdm look for a file named .xsession in the user’s home directory to know which window manager you want to be launched after authentication:

# echo "exec startfluxbox" > ~/.xsession

This will add fluxbox for the root user, don’t forget to create one in each user’s home specifying the WM that user wants to use.

The last step is to activate the preconfigured tty in /etc/ttys.
In this file you should see a line like this one:

ttyv8 "/usr/local/bin/xdm -nodaemon" xterm off secure

Simply change it to look like this:

ttyv8 "/usr/local/bin/xdm -nodaemon" xterm on secure

And that’s it, reboot your computer and you should see a nice (?) X window prompting you for your login & password and launching your favorite window manager once authenticated.

Tags: ,

2 Responses to “How to have X at startup on FreeBSD using xdm”

  1. Įvairūs FreeBSD patarimai | FreeBSD.lt Says:

    [...] How to have X at startup on FreeBSD using xdm [...]

  2. A Lurker Says:

    x11/slim is way prettier…

Leave a Reply