Duplicate xorg session created on Ubuntu 18.04 with Nvidia Drivers
I recently did two fresh installs of Ubuntu 18.04 on similar systems. The only difference is one is running a GTX 1070 and the other GTX 1080.
Problem
After installing the Nvidia driver (390.59 from binary) a duplicate xorg session is created every time after reboot. One running on my user account (1000) and another running on user account (120, guessing a service account).
root 1038 0.0 0.1 249052 46432 tty1 Sl+ 09:09 0:01 /usr/lib/xorg/Xorg vt1 -displayfd 3 -auth /run/user/120/gdm/Xauthority -background none -noreset -keeptty -verbose 3
root 2157 0.4 0.2 358056 77424 tty2 Sl+ 09:11 0:13 /usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -background none -noreset -keeptty -verbose 3
Nvidia-smi also shows two xorg sessions running on the GPU
| 0 1038 G /usr/lib/xorg/Xorg 18MiB |
| 0 1100 G /usr/bin/gnome-shell 49MiB |
| 0 2157 G /usr/lib/xorg/Xorg 173MiB |
| 0 2298 G /usr/bin/gnome-shell 116MiB
Other then this extra process everything is running normally. It doesn't seem to interfere with anything but I would like to figure out why it is happening. On the same two systems I've run Ubuntu 16.04 and CentOS and didn't notice this duplicate xorg process. If anyone has any information that can point me in the right direction that would be great.
Solution 1:
Thanks to this questions "Why is my GDM at a different TTY than my desktop environment?" I found the reason for the two xorg sessions. The Gnome desktop manager uses two xorg session one that acts as a greeter (login) and the other as a user session. In the past one xorg session was created with root and later transformed into a user session. However for future development plans the decision to separate these sessions was decided.
Read More about it here:
https://bugzilla.gnome.org/show_bug.cgi?id=747339
Let me explain a bit more about why we did this.
Previously, we launched one X server as root, and then when you logged in, we "morphed" it into the session X server. If you went to fast user switching, we then launched a second X server on-demand.
For security reasons, and Wayland porting reasons, we now launch the X server and Wayland server within the user's session, instead of starting one as root.
The way that we do this is that we launch two X servers, one for the gdm greeter session, and for the session user.
It would be entirely possible to tear-down the greeter after we've switched to the user session, it just requires a bit more code, but unfortunately it wouldn't be possible to put both the greeter session and the user session on VT1, since we'd have to launch the user session first, and then tear down the greeter session, and we can't be in that intermediate state while there are two X servers on the same VT at the same time.
I just forgot about the resource issues around keeping around two gnome-shell instances. I'll have a chat with Ray to see if we want to tear down the greeter session and then launch it on demand for user switching / logout to save on resources.