X Windows Terminal

From FreeBSDwiki
Jump to: navigation, search



X Windows can be used in a Server-Client relationship. By setting up your X Windows Server you allow the use of all the programs on that computer to all the client PC's.

There are many advantages of running client computers in this manner:

  • They don't even need a hard drive.
  • It's silent as there are no moving parts
  • The solution saves power as your computers are very thin.
  • Everything can be backed up centrally.
  • Boot times for client PC's are the fastest around.
  • Clients don't need much CPU speed, memory, etc. Because of this they would be very cheap. You could get away with using a Pentium 100Mhz with 32MB ram, no hard drive, no CD-ROM, no Floppy and a fanless power supply. You just need a ethernet card with a PXEBOOT ROM. (XDM mode)
  • Central management of applications, users, config

From the Beginning

I've based this document on FreeBSD 6.1.

Install FreeBSD 6.1 as per usual. I've setup my mount points as this:

 Part    Mount        Size
 ad0s1b  Swap         (equal to how much memory I have in my machine)
 ad0s1a  /            512MB
 ad0s1d  /var         1G
 ad0s1e  /tmp         512MB
 ad0s1f  /usr         2GB    min.
         /diskless_ro 512MB
         /diskless_rw 1GB    min.

I selected 'A' for auto and then deleted /usr and created /usr as 2g.

Select User-X install. Yes to Ports if you have the room.

Select SSH Server and NFS Server in the installation process, for the rest of the options go with the default.

NOTE: If you forget to add any of the labels above, you will have to reboot as you cannot add labels to your boot drive when you have booted off it. So boot of the installation CD and use the configure -> label option in the sysinstall screen to add these labels to your boot drive. You may need to retype the mount points for /, /var, /tmp and /usr by hitting 'm' on each label. Once you have created these labels in the 'Disklabel Editor' then you can hit 'w' to write them to the disk. answer 'yes' to the next question, hit 'ok' to the warning message. Now quit and reboot. Add them to fstab (/dev/ad0s1g /diskless_ro) & (/dev/ad0s1h /diskless_rw) and mount.

I find the best way to get this working is to break it down in to small steps and get each step working independantly. IE: Setup NFS and see if you can mount it from another FreeBSD machine, don't just assume it will work and boot your PXE-Boot machine.

Throughout my documentation = the Server = the client (may be a full freebsd system or pxeboot)

At this point I normally install fluxbox with the following line:

shell# pkg_add -r fluxbox-devel

change your ~/.xinitrc file to the following:


Copy to .xsession

$ ln -s ~/.xinitrc ~/.xsession

Use the following command to update your fluxbox menus:

shell$ fluxbox-generate_menu

Running a single application

To get started I have my server setup running FreeBSD, with X-Windows and a few applications. Nothing too special. Then I have my client PC, which to start off I used the frenzy 1.0 boot CD to perform these initial tests. You can get this from frenzy website. I entered into fluxbox, but you could equally use any X session. You must allow incoming connections this is done with two commands

client$ startx -listen_tcp
client$ xhost +

This allows all computers to start applications on your client PC. It's dangerous but good for testing everything is setup correctly.

client$ ssh <server user@server ip>
eg: ssh mick@
ssh$ export DISPLAY=''

Or if your running bash:

ssh$ DISPLAY=<client ip>:<client display>; export DISPLAY
eg: DISPLAY=; export DISPLAY

ssh$ xcalc &

This should display on your client

Running a whole X Windows Session (XDM)

This sets up a server so that you can share your X session with any clients which want to connect. (Simular to Terminal Services under windows)




comment out with a '!' the request line

DisplayManager.requestPort: 0



Enter a single asterisk any where in the file, so the contents should be one asterisk and the rest commented out. There should be an asterisk on line 49 which you can uncomment.

Whilst in the /usr/X11R6/lib/X11/xdm directory do these commands:

shell# vi Xstartup

Add into this file:

# Xstartup
# This program is run as root after the user is verified
if [ -f /etc/nologin ]; then
   xmessage -file /etc/nologin -timeout 30 -center
   exit 1
sessreg -a -l $DISPLAY -x /usr/X11R6/lib/xdm/Xservers $LOGNAME
exit 0

shell# chmod +x Xstartup

Make sure your firewall has all traffic for you lan. (Need to know which exact ports to allow).

run xdm on server as root

shell# xdm

You can put this xdm into the /etc/ttys so that it starts automatically on boot up.


make sure your not in X

type this command:

shell# X -broadcast

This assumes that you are running only one server. Otherwise use:

shell# X -query

DHCP - Install and setup

Server setup.

install through package

# pkg_add -r isc-dhcp3-server

We do this so we can define the root path for the diskless system.

copy /usr/local/etc/dhcpd.conf.sample to /usr/local/etc/dhcpd.conf

edit /usr/local/etc/dhcpd.conf and make sure it has these lines in it.

# dhcpd.conf
# Sample configuration file for ISC dhcpd

# option definitions common to all supported networks...
#option domain-name "";
#option domain-name-servers,;

default-lease-time 3600;
max-lease-time 86400;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.

# ad-hoc DNS update scheme - set to "none" to disable dynamic DNS updates.
ddns-update-style none;

option root-path "";

# lines added for pxeboot client
use-host-decl-names on;
filename "pxeboot";

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.

# This is a very basic subnet declaration.

subnet netmask {

Create the leases file

# touch /var/db/dhcpd.leases

Restart the daemon

# killall dhcpd
# dhcpd

Add to /etc/rc.conf


Using a seperate DHCP server

If you already have a DHCP server and you want to use that instead then you have to do these steps.

On your DHCP Server

1. edit /usr/local/etc/dhcpd.conf and add the following

ddns-update-style none;

option root-path "<X Server IP>:/diskless_ro";

# lines added for pxeboot client
use-host-decl-names on;
next-server <X Server IP>;
filename "pxeboot";

restart dhcpd

# /usr/local/etc/rc.d/ restart


Your client should boot now just remember that you may get a different IP now that you are talking to a different DHCP server so you have to change your exports file and copy accross a directory in /diskless_rw for the new IP. All this is done on the X Server.

TFTP Setup

TFTP helps us transport the kernel to the PXE-Boot machines.

# mkdir /tftpboot
# cp /boot/pxeboot /tftpboot

Uncomment the following line in /etc/inetd.conf

tftp    dgram   udp     wait    root    /usr/libexec/tftpd      tftpd -l -s /tftpboot

Restart the inetd service

# killall -HUP inetd

If inetd has not started automatically do the following:

Add the following to /etc/rc.conf


Now start inetd manually.

# inetd


To test that tftp has loaded type the following:

# sockstat -4l | grep 69 

and you should see this:

root      inetd       13719 5   udp4    *:69                 *:*

NFS Setup

Network File System. Here we share all the directories from the server so that the diskless clients see these drives as if those directories were the diskless client's.

Server Setup

If you forgot to select 'Yes' to NFS server setup in the FreeBSD installation then you have to setup the server manually like so:

Enable NFS /etc/rc.conf



A quick test to see if your NFS server is acting normal:

Edit the /etc/exports and add the following

/usr       -alldirs

This allows anyone to connect to your /usr mount.

Now run these commands to restart and view your mounts

# kill -HUP `cat /var/run/`
# showmount -e

Now try and mount it from a client running BSD

# mount -t nfs /mnt

Server exports setup

Make directories for each IP for your clients

# cd /diskless_rw
# mkdir
# cd
# mkdir etc var

Configure /etc/exports

# file systems accessible only for reading:
# Original way of linking up the /usr
#/usr -ro -maproot=0 -network -mask

/usr -network -mask
/diskless_ro -ro -maproot=0 -network -mask
/diskless_rw/ /diskless_rw/ -maproot=root

Restarting NFS

# kill -HUP `cat /var/run/`

If NFS is not started yet do the following:

data# rpcbind
data# nfsd -u -t -n 20 -h
data# mountd -r

Testing to see if the exports are correct

data# showmount -e
Exports list on localhost:

Setup diskless_rw

Create directories

# cd /diskless_rw/
# mkdir pam.d X11

# cd /diskless_rw/
# mkdir home log run tmp
# chmod 1777 tmp

Create a swap file in the var directory for the client

# dd if=/dev/zero of=/diskless_rw/ bs=1k count=32000

in the /diskless_rw/<ip>/var/log directory I created the following log files so that syslogd would have files to write to:

# cd /diskless_rw/
# touch messages security auth.log maillog lpd-errs xferlog cron debug.log slip.log ppp.log

Copy the following files from the systems /etc directory to /diskless_rw/<client ip>/etc

# cp -Rv <files> /diskless_rw/<ip>/etc
termcap -> /usr/share/misc/termcap

Here is a shortcut which you can just copy and paste in an xterm window.

# cd /etc
# cp -Rv auth.conf disktab gettytab group hosts login.access login.conf login.conf.db master.passwd motd netconfig protocols pam.d pwd.db services spwd.db syslog.conf termcap ttys /diskless_rw/<ip>/etc

It's very important that you copy all the files in pam.d across otherwise you will not have a password prompt on your login.

Create a fstab in /diskless_rw/<ip>/etc

# touch /diskless_rw/<ip>/etc/fstab

Setup diskless_ro

This is the common root mount for all pxe-boot clients.

Copy accross important directories and kernel from boot to diskless_ro

# cp -rv /bin /lib /libexec /sbin /boot /diskless_ro

For some client machines you may have to disable the ACPI (Power management) in the /diskless_ro/boot/device.hints


So we can use the systems /var/tmp and /usr/home directory make soft links to them

# cd /diskless_ro
# ln -s /var/tmp /usr/home

In the /diskless_ro directory make the following directories: -dev so that clients can boot without freezing -var so we can mount from the /diskless_rw/<client ip>/var into the var directory -etc to store some common files

# mkdir usr dev var etc

We require a few files from the systems /etc directory to be copied into the /diskless_ro/etc for common use between the thin clients.

# cd /etc;
# cp services netconfig login.conf /diskless_ro/etc

rc file

The /diskless_ro/etc/rc file is the first file which is ran after the kernel has loaded. Here we mount a the labels from the server.

Create the /diskless_ro/etc/rc


PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin; export PATH
TMPDIR=~/tmp;export TMPDIR
TMP=~/tmp;export TMP

mount -t nfs /usr

boot_ip=`/sbin/ifconfig | /usr/bin/grep "inet " | /usr/bin/grep -v |
/usr/bin/awk '{print $2}'`
mount_nfs -L${boot_ip}/etc /etc
mount_nfs -L${boot_ip}/var /var

swapon /var/swap

#rm -rf /var/tmp/*
#rm -rf /var/tmp/.*

# Option if you choose XDM terminals
#X -query

. /etc/rc2
exit 0

Remember to change to your X server's IP

The -L on the mount_nfs is there so we don't get flock errors.

rc2 file

This sets up some links for libraries and the logging daemon.


mount -a
/sbin/ldconfig -elf /usr/lib/compat /usr/X11R6/lib /usr/local/lib


Now change permissions so rc can run.

# chmod +x rc*

Copy /diskless_ro/etc/rc and rc2 to /diskless_rw/<client ip>/etc

# cp /diskless_ro/etc/rc* /diskless_rw/

GRUB Floppy boot (optional)

(would like to compile this ourselves later) To get started we downloaded the image from

shell# dd if=/data/grub-net.img of=/dev/fd0

Then we mounted it as msdos Remove/rename menu.1st from the grub directory as it was doing something funny with it. We think that it was looking for a tftp server through our dhcp and we don't have a the dhcp setup correctly here, so we wanted to do it manually.

Reboot off the floppy now..

grub> ifconfig --address= --mask= --gateway=

OR you can use dhcp

grub> dhcp
grub> tftpserver

Setup tftp on your server, we created a directory /tftpboot.

Starting diskless system through GRUB

This is an alternative boot loader. You can use this for testing, if you don't have a pxeboot chip, otherwise skip this section.

These commands are half working...

grub> root (nd)
grub> kernel /kernel root=ad0s1a
grub> pxeboot

Completely Diskless System (PXEBOOT ROM) (optional)

Running completely diskless by booting from a Network ROM Chip.

We have now got a Intel GD82559 Etherexpress pro/100 Card.

When we boot up on the client machine with that card it displays:

Intel UNDI, PXE-2.0 (build 067)
Copyright (C) 1997-1998 Intel Corporation

Which we cannot get working so we have read that you have to update this version to Build 82.

copy /boot/pxeboot to /tftpboot directory we made before

- Downloaded proboot.exe from and unpacked into a windows box.
- Copied ibautil.exe onto a windows 98 boot disk.
- Rebooted the test box after disabling network boot on the nic (otherwise it'll kick in before the floppy).
- Ran ibautil -iv to see what embedded image versions were available:

Intel(R) Boot Agent XG v1.0.09
Intel(R) Boot Agent GE v1.2.36
Intel(R) Boot Agent FE v4.1.19

- Ran ibautil -up to perform the image upgrade.

It's interesting to note that no version showed up for out intel nic when initially running ibautil. After the upgrade, however, the version corectly showed as 4.1.19.

I made sure that I had simular features to this in my dhcpd.conf file:
option broadcast-address;
option domain-name-servers;
option domain-name "";
option routers;
option subnet-mask;
server-name "pxe-gw";
default-lease-time -1;

subnet netmask {
option root-path "/usr/local/export/pxe";
filename "pxeboot";
host {
hardware ethernet 00:e0:18:98:f0:cc;
host {
hardware ethernet 00:60:97:0e:bb:a7;

X config notes

On the X server the /etc/X11/xorg.conf file is only used for the X server not the clients.

To use this same configuration for your X Terminal Clients copy this file to /diskless_rw/<Client IP>/etc/X11 and it will use it.

Starting X on the client

There are two ways of doing this and it depends on your hardware mainly.

1. run all programs on the server using the servers CPU and Memory this we will call the 'XDM Method' 2. run all programs from the NFS mounts using the clients CPU and Memory but the HD of the server, this we will call the 'NFS Method'

Both methods will boot from PXE-Boot and can be diskless.

XDM Method

Recommended for machines less than 1Ghz 256MB

This is quite simple to setup. Change your rc file in the /diskless_ro/etc directory to have this line at the end:

X -query <server ip>

Make sure on the server you setup xdm to start on system startup

# vi /etc/ttys

Search for this line:

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

and change it to:

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

You can also type this command at the command line on the client to test before hand.

NFS Method

Recommended for machines over 1Ghz 256MB or if you want to utilise any of the clients devices such as local HD, USB, CD/DVD burners, etc.

This is much trickier.

Log in Now type 'startx' at the command line.

Custom Kernels

If you want to create custom kernels for your clients then do this:

Create your custom kernel

# cd /sys/i386/conf

Make changes and build and install

# cd /usr/src
# make buildkernel KERNCONF=DISKLESS
# make installkernel KERNCONF=DISKLESS DESTDIR=/diskless_ro

Convert an Existing system with standard mount points

If you cannot afford to create /diskless_ro and /diskless_rw then you can use /var/diskless_ro and /usr/diskless_rw instead.

Use the same notes and replace /diskless_ro with /var/diskless_ro and /diskless_rw with /usr/diskless_rw. Make sure you create these directories first.


Here are some of the jobs left to do to make this secure or generally better:

- There must be a simplier way to set this up if your going to use XDM in the end. IE: do we need to do half of this tutorial if we are going to run XDM.

- When the same user logs onto two seperate machines they cannot start firefox or thunderbird as it complains about being open somewhere else. This assumes you have firefox and thunderbird already open on both machines that you logged onto.

Known Issues

- Doesn't work with HP-COMPAQ-T5525 thin client as it doesn't want to boot, it says it's missing which we do have it just cannot find it for some reason. It's trying to use the VIA chipset for graphics which is different to all the other clients I've loaded successfully so far.

- USB mice not working instead use PS/2. If we got this working it may help get the HP T5525 working

Keyboard repeating on notebooks

- typing on some keyboards (like my notebook) causes double characters to display if you type too fast. - This is the notebook, if you go and set the KDE Accessabiltiy options and set the keyboard rate to 50ms, this fixes the problem.

USB mouse

Editing /etc/devd.conf file and searched for ums remarked out the action line.


Someone off IRC suggested that I build a GENERIC xorg.conf file which has vesa, usb mouse and ps/2 mouse configurations through it.

I reverted everything back to normal ps/2 mouse config, copying my usb config files to the following: /etc/devd.conf_usb /etc/rc.conf_usb /etc/X11/xorg.conf_usb

I think we need a seperate configuration for the HP, it uses a weird display driver.


File Examples:

PXE Information

Personal tools