How to Edit Ubuntu 16.10 Grub Menu to Remove Gfxmode

grub2nvidia

My thinkpad w520 will not boot with the default Grub menu if I am using Nvidia drivers and the Nvidia card (it's an Optimus system with two video cards). However, it boots in recovery mode, and goes on to work well.

The culprit is

gfxmode $linux_gfx_mode

If I remove this line with the Grub entry, it boots fine. (This line is not present in the recovery menu option).

Is there a sane way for me to edit the grub menu to get rid of it? Must I fiddle with scripts in /etc/default/grub.d ?

Best Answer

gfxmode was probably not really the problem. There were some kernel parameters that made the experience much better. It proved to be impossible to get this laptop working with Windows 10 (using the Nvidia card always), but it does work with Linux!

So on 16.04 (but with the 4.8 kernel) and Nvidia driver v 367, this is how you can get three monitors working (via a docking station) which is only possible with Optimus. Yes ... nvidia in discrete mode will only drive two outputs; not three. If you only need one external monitor and the laptop panel, you can either use optimus or discrete Nvidia. Discrete nvidia just works, no need for any config.

  1. the machine will hang on boot unless you modify the grub cmd line entry to specify nox2apic /etc/default/grub...

    GRUB_CMDLINE_LINUX_DEFAULT="agp=off quiet splash nox2apic"

There are additional suggestions in the history of the w520 but with this kernel, only this change is needed.

  1. There are hints about adding a file to /usr/share/X11/xorg.conf.d to set up nvidia brightness. This suggestion stopped optimus from working. I don't know how, but they have a nasty effect when X is starting. The symptom of this problem is that xrandr --listproviders needs to show both the nvidia card and the intel card. The brightness tweaks to xorg.conf seemed harmless, but they actually somehow stopped the intel card and nvidia card working together. xrandr --listprovider would only list one provider, Nvidia, and it is therefore impossible for X to render anything on the laptop panel. To my amazement, removing the brightness conf fixed this very annoying problem.

In any case, the brightness keys are working for me in optimus-nvidia mode, and changing brightness via the screen control panel works too.

  1. lightdm refuses to allow me to use the laptop panel. The mouse pointer moves there, but I can't drag any windows, and there is no background (it's black). However, install xfce but keeping lightdm works. Note that if you want on-screen brightness control, you need to install the xfce power management plugin from synaptic or whatever package manager, and then add it to the panel. Clicking the battery icon gives a display changer.

Note: I follow the arch wiki instructions here:

https://wiki.archlinux.org/index.php/NVIDIA_Optimus#LightDM

and added the short script make some xrandr changes. I did this mainly to try to understand why I had only one provider, before I worked out that the nvidia brightness changes was the problem. Possibly I don't need the script, but I'm so pleased that it's all working I don't want to change a thing.

However, changing from nvidia to intel requires a reboot: merely logging out doesn't work.