NoMachine for Linux / Persistent screen resolution on headless EC2 / Reply To: Persistent screen resolution on headless EC2
AR10K00710 describes how to run Xvfb and Gnome together. They are launched manually and not automatically restarted at reboot.
The error “Server is already active for display 0” is issued because file /tmp.X0-lock already exists, but it could be a leftover of a crashed X server.
So as first thing I’d check if any X server is running as display :0. Try this command:
ps -ef | grep X.*:0
There are to cases.
1. If X was already running as display :0 (and Gnome is using it) you have to do nothing, you haven’t to run Xvfb even. Just run the NoMachine client and choose to connect to session on display :0.
2. In the opposite case, if you found that no X is running, you need to remove /tmp/.X0-lock. If you need to set Xvfb permanently, in order to run it at reboot, I think you could configure the lightdm scripts to run Xvfb in place of Xorg. I never tried this before, so I’m not aware of issues that could arise:
Edit /etc/lightdm/lightdm.conf to add a line to [SeatDefaults]:
[SeatDefaults]
xserver-command=/etc/X11/xserver-command
Create the script /etc/X11/xserver-command:
#!/bin/sh
display=$(echo "$@" | awk '{for (i=1;i<=NF;i++) {if ($i ~ /^:/) {print $i}}}')
auth=$(echo "$@" | awk '{for (i=1;i<=NF;i++) {if ($i ~ /^-auth/) {print $i,$(i+1)}}}')
exec Xvfb ${display} ${auth} -screen 0 1800x1200x24
Then restart lightdm and NoMachine:
/usr/NX/bin/nxserver –shutdown
service lightdm stop
service lightdm start
/usr/NX/bin/nxserver –startup
After that, Xvfb will be launched with services on boot.
