High resolution TTY with the nvidia proprietary driver

My laptop is a ThinkPad T430 with discrete NVIDIA graphics. It can switch between integrated graphics (Intel) and discrete.

You may know that graphics switching is hard on laptops with NVIDIA discrete graphics. I wish I could use integrated graphics by default and just use NVIDIA for video acceleration, but I can’t. Bumblebee doesn’t work. Also, I’m using my laptop mainly with mouse, keyboard and monitor plugged in, making it a full-fledged PC. The external monitor is full-HD, it looks horrible connected through VGA, forcing me to use the DisplayPort connection. The problem is that the DisplayPort is hardwired to the NVIDIA card (according to xrandr I have 6 DP connections??). Because the monitor is connected to the discrete card, it doesn’t output anything, only the GRUB prompt (how does that even work?). Luckily, I can switch between the two graphics modes from the UEFI/BIOS menu.

The problem is that I get low resolution in the TTY. I solved this problem with a GRUB trick and pure luck.

GRUB can be configured to use a specific video mode and then transfer the graphics payload to the Linux kernel. That means that the TTY will use the same video mode and the same resolution. GRUB can also automatically select the best video mode available. The problem is that the NVIDIA card doesn’t report all video modes available, making GRUB, and implicitly the kernel, use a low resolution video mode.

The hack I discovered is that I can supply the resolution of the laptop display as my preferable video mode and it will just work. I got native resolution in the TTY (yay).

Here is how it works:

The video mode is set in the GRUB_GFXMODE variable from the /etc/default/grub configuration file. To keep the video mode after Linux boots, set GRUB_GFXPAYLOAD_LINUX to keep.

To get native resolution, just set GRUB_GFXMODE to your native resolution and append x32 to it (that’s 32 bit color depth). My setting is GRUB_GFXMODE=1600x900x32.

Run grub-mkconfig to generate the configuration file, reboot and you’re done!

# grub-mkconfig -o /boot/grub/grub.cfg