5

What is the easiest way to make ubuntu boot on both native computer with NVIDIA card installed and as a VMware guest. After installing nvidia-304 driver package I can't load it in VMware. It stuck in login loop with this error in .xsession-errors:

Xlib: extension "GLX" missing on display ":0".

The only relevant answer I found is this but it doesn't work for me. There is no switchlibglx in NVIDIA drivers.

EDIT: My investigation results. NVIDIA spoilt the system with their OpenGL module through the symbolic link in system directory libglx.so. Their module can only work with NVIDIA driver which is not loaded if you start the system with a different video adapter obviously. There is no default and easy way to choose which OpenGL module to use depending on the driver loaded. It's a classic unix logic. In any difficult situation don't bother to invent API and options, just overwrite the default symbolic link in global directory and let a user deal with this mess. NVIDIA just use the standard crutch to install their driver and module. There are three possible workaround:

1) install and uninstall nvidia drivers every time you use it in VMware

2) make a complicated config file that run a script and overwrite symbolic links during boot depending on the adapter present (See the answer below)

3) somehow disable the use of GLX extensions in X server to load it in VMware

  • Did you install the nvidia drivers using their own installer or using ELRepo's packages? – Murali Manohar Jul 7 '16 at 7:22
  • I suggest running the OS off of a virtual disk for VMWare, but mount your home directory from your normal boot. VMWare video drivers pass through hardware acceleration to your host graphics card. – John Hall Jul 9 '16 at 21:16
  • I added a script which I believe will work to update the symlink via the proper update-alternatives method this would be better than trying to overwrite the symlink yourself if you wanted to go with that method as it is consistent with the method the system uses to handle conflicting versions of files installed simultaneously. Do note the caveats noted in my answer though also the script would need to run before lightdm is started and it will need to be executed as root though system startup scripts are. – MttJocy Jul 12 '16 at 4:12
2

You are having this problem because your X configuration is trying to load the nvidia driver which is then looking for a compatible nvidia device. Such a device does not exist in the guest environment instead a VMware virtual graphics device is presented instead and thus the nvidia driver is not the correct driver in the guest OS.

The correct driver for the vmware virtual graphics interface is the one provided by the xserver-xorg-video-vmware package not the ones provided by the nvidia-* packages which are only suitable for direct access to the GPU. You can install the correct driver using the following command on the guest:

sudo apt-get install xserver-xorg-video-vmware

Also make sure that 3D acceleration is enabled on the virtual machine configuration and that you have installed the vmware guest additions correctly. You should also make sure that you don't have an xorg.conf file which is explicitly selecting the nvidia driver since this will fail.

If you wanted a script you could set to run at boot time before lightdm is started you could try something like this:

#!/bin/bash
# Vendor identifiers
nvidia=\"10de\"
vmware=\"15ad\"

# Detect NVIDIA driver
nvidia_driver=`dpkg --get-selections | awk '/nvidia-[0-9]+\t+install/ { print $1 }'`

# Detect PCI bus ID
vga_bus_id=`lspci | awk '/VGA/ { print $1 }'`

# Detect VGA vendor identifier
vga_vendor=$(lspci -nm | awk "/$vga_bus_id/ { print \$3 }")

if [ $vga_vendor == $nvidia ]; then
   # Configure for nvidia GLX via update-alternatives
   update-alternatives --set i386-linux-gnu_gl_conf /usr/lib/${nvidia_driver}/alt_ld.so.conf
   update-alternatives --set i386-linux-gnu_egl_conf /usr/lib/${nvidia_driver}/alt_ld.so.conf
   update-alternatives --set x86_64-linux-gnu_gl_conf /usr/lib/${nvidia_driver}/ld.so.conf
   update-alternatives --set x86_64-linux-gnu_egl_conf /usr/lib/${nvidia_driver}/ld.so.conf
elif [ $vga_vendor == $vmware ]; then
   # Configure for mesa GLX via update-alternatives
   update-alternatives --set i386-linux-gnu_gl_conf /usr/lib/i386-linux-gnu/mesa/ld.so.conf
   update-alternatives --set i386-linux-gnu_egl_conf /usr/lib/i386-linux-gnu/mesa-egl/ld.so.conf
   update-alternatives --set x86_64-linux-gnu_gl_conf /usr/lib/x86_64-linux-gnu/mesa/ld.so.conf
   update-alternatives --set x86_64-linux-gnu_egl_conf /usr/lib/x86_64-linux-gnu/mesa-egl/ld.so.conf
else
   # Configure for mesa GLX via update-alternatives
   update-alternatives --set i386-linux-gnu_gl_conf /usr/lib/i386-linux-gnu/mesa/ld.so.conf
   update-alternatives --set i386-linux-gnu_egl_conf /usr/lib/i386-linux-gnu/mesa-egl/ld.so.conf
   update-alternatives --set x86_64-linux-gnu_gl_conf /usr/lib/x86_64-linux-gnu/mesa/ld.so.conf
   update-alternatives --set x86_64-linux-gnu_egl_conf /usr/lib/x86_64-linux-gnu/mesa-egl/ld.so.conf
fi

The script checks which vendor identifier is detected for the graphics card, if nvidia it will configure ld to use the nvidia provided opengl libraries however if the vmware device is detected it will configure for mesa, mesa being the default if neither vendor string is recognised.

A number of assumptions are being made here the script wont work correctly if these are not the case:

  1. Multilib install is assumed thus the settings for both i386 and x86_64
  2. It is assumed that the ubuntu provided nvidia driver is installed this will not work if you installed the nvidia driver manually without using apt.

I do not however have vmware installed so I am only able to test and be sure that it works correctly when the nvidia device is detected and the ubuntu provided nvidia drivers are installed.

| improve this answer | |
  • Not sure for OP, but in my case, the vmware conf is already installed and I don't have a xorg.conf, it's auto configured on driver install. Problem is to switch between drivers. – Laurent Jul 11 '16 at 9:01
  • The script seems to work. It should be substr(\$3,1,4) but I prefer to use -m switch of lspci as a less hacky solution. Where is the best place to run it? Should it be in ~/.xinitrc or better put it in /etc/init with start on starting lightdm as in this answer? – ZAB Jul 12 '16 at 16:23
  • @ZAB Hmm yeah didn't think of lspci -m that's a better idea, as for when to run it then start on starting lightdm would be the better option I think since I believe that ~/.xinitrc is started after the X server is started which is too late as it's the X server itself which is loading the opengl libraries so the dynamic linker configuration would need to be in place before the X server binary is loaded. – MttJocy Jul 13 '16 at 14:38
  • @MttJocy I added it to .xinitrc/.xsession and it works fine so far. Where did you find all those alternatives and .conf's? Especially the i386 ones. Where is it documented? – ZAB Jul 13 '16 at 20:06
  • @ZAB "update-alternatives --get-selections | grep gl_conf" shows the names and the current file that the symlink points to for the various gl_conf settings then use "update-alternatives --list [name]" to see the alternative options for each setting. See the manpage for update-alternatives for more information "man update-alternatives" or manpages.ubuntu.com/manpages/precise/man8/… for the online version. – MttJocy Jul 14 '16 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.