Tuesday 5 October 2010

Adding a framebuffer to a headless unix server


Some java software, including GWT, expects a framebuffer to be present.
This post shows how to install Xvfb (X virtual Frame Buffer) on a Ubuntu/Debian system. This assumes that you do not currently have an X server running (it is a headless server).

apt-get install xvfb xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic

(the fonts are not needed but their absense is warned about)
Place the following in /etc/init.d/xvfb
case "$1" in
start)
echo "Starting virtual X frame buffer: Xvfb"

/usr/bin/Xvfb :0 \
-auth /etc/X99.cfg -screen 0 1024x768x24 \
-fbdir /var/lib/xvfb \
-extension RANDR &

export  DISPLAY=:0

;;
stop)
echo "Stopping virtual X frame buffer: Xvfb"
echo "noop"
;;
*)
echo "Usage: /etc/init.d/xvfb {start|stop}"
exit 1
;;
esac

exit 0


then
chmod u+x /etc/init.d/xvfb 
echo localhost > /etc/X99.cfg
mkdir /var/lib/xvfb
/etc/init.d/xvfb start

should be good to go.