Note: Wayland has solved most of the issues in this blog post by now. I now use Wayland as my daily driver, and suggest you do too. Still I will leave this up as a reference to whoever may need it.
In this article, we will be setting up an ASUS UX501VW as a daily driver running Arch Linux and attempting to take full advantage of all the fancy new (as of Sept 2016) hardware and get optimal system stability and performance.
The ASUS UX501VW Zenbook is a great little notebook that comes with a 15.6" 3840x2160 IPS UHD monitor, an Intel Skylake i7-6700HQ 2.6GHz processor, a GTX 960M graphics card with 2GB GDDR5 VRAM, 16GB DDR4 2133 MHz SDRAM, and a fast 512GB NVMe SSD HD.
Getting all that to work under Arch Linux requires a bit of config. I assume you've already installed the base system using 2016.09 or newer with GDM and GNOME 3. Arch now uses the Wayland backend for GNOME by default, but you can also log in to Gnome using the Xorg backend by clicking the gear icon next to the login button and selecting the X11 Gnome shell.
While I understand that Wayland is the future, unfortunately it is still missing some key features, which makes it necessary to switch back to X11 for a couple of important use cases:
- If you wanted to make use of that GTX 960M in a first-person shooter, or other 3D app that makes use of pointer confinement, you will be unable to control your character due to the fact that while Gnome has supported pointer confinement since version 3.20, this only works for native Wayland clients and there is no support for Xwayland clients, which is what pretty much everything uses at this point.
- If you use a color-shifting program to reduce blue light, such as Redshift, Wayland doesn't support shifting color temperature. The only solution I know of is to use Xorg. I have heard a rumor that this functionality will be built in to Gnome 3.22, so we will see.
Thus, in order to get maximum functionality out of our install, we can't forget about Xorg just yet.
Install video drivers and bumblebee
This laptop comes with two video cards: the integrated Intel graphics, and the standalone NVIDIA card. In order to conserve power, it's ideal to use the Intel graphics for everyday use and only whip out the NVIDIA when we need 3D heavy-lifting. On Windows, we can use NVIDIA Optimus technology to handle that. For Linux, there is Bumblebee. Installing it on Arch is relatively simple:
pacman -Syu bumblebee primus lib32-primus bbswitch mesa mesa-libgl nvidia lib32-virtualgl lib32-nvidia-utils lib32-mesa-libgl nvdock-bumblebee
Also, make sure
lib32-nvidia-libgl are not installed.
linux-headerspackage will be needed by the KMS system.
nvdock-bumblebee[AUR] package gives you a dockable NVIDIA control panel that works through Bumblebee.
Next make sure your user is added to the
gpasswd -a user bumblebee
/etc/bumblebee/bumblebee.conf file and make sure these lines are present:
VirtualDisplay=:8 Driver=nvidia Bridge=primus KernelDriver=nvidia PMMethod=bbswitch
Finally, enable the
As I mentioned above, make sure the
xf86-video-intel package is not installed. The reasoning behind this is that the package is really on its last limb, and you can get all its functionality and more out of the xf86-video-modesetting subpackage of Xorg. You can see more here at this reddit post.
In order to get this to work, you need to make sure to rename or remove any
/etc/X11/xorg.conf.d/20-intel.conf files. Having these files present may prevent Xorg from loading (but not Wayland). Intel graphics autoconfigure under Xorg, so there is no need for those config files.
The next thing to do is set up your
initramfs and configure your bootloader. Your
/boot/loader/entries/arch.conf file should look like this:
title Arch Linux linux /vmlinuz-linux initrd /intel-ucode.img initrd /initramfs-linux.img options acpi_osi=! acpi_osi="Windows 2009" acpi_backlight=native cryptdevice=UUID=e71f0dee-d09e-4832-af71-1d0e0562bd30:lvm i915.enable_execlists=0 intel_iommu=on resume=/dev/mapper/vg-cryptswap root=/dev/mapper/vg-cryptroot quiet rw
A couple notes about this:
I load Intel microcode updates using this line. Note that you must install the
intel-ucode package as described above for this to work.
Going through the options in order, these kernel parameters:
acpi_osi=! acpi_osi="Windows 2009" acpi_backlight=native
are critical for preventing Xorg from randomly locking up. Note: if you put
acpi_osi=, your computer will crash on boot.
These kernel parameters:
cryptdevice=UUID=e71f0dee-d09e-4832-af71-1d0e0562bd30:lvm (...) resume=/dev/mapper/vg-cryptswap root=/dev/mapper/vg-cryptroot quiet rw
Are necessary for my whole-drive encryption. If you are using LVM-on-LUKS drive encryption, you should have similar settings in your loader. Otherwise you can safely ignore them.
i915.enable_execlists=0 is critical for preventing Xorg lockups on startup.
intel_iommu=on turns on IOMMU capability for PCI passthough. It is not necessary for this tutorial and can be ignored.
/etc/mkinitcpio.conf file should contain the following lines:
MODULES="i915 nvidia nvidia_modeset nvidia_uvm nvidia_drm" HOOKS="base udev autodetect modconf block encrypt lvm2 resume filesystems keyboard fsck"
Once those lines are in place, you can now create your new initramfs with the command (assuming you are using the default linux kernel):
sudo mkinitcpio -p linux
Now reboot. When you log in, you will have a fully functional Bumblebee setup on Gnome using either Xorg or Wayland backends. If you want to use your NVIDIA card to run a graphics-intensive application or a game, just run
$application_name with the name of the executable. Thanks to Bumblebee, the remainder of the time the NVIDIA card will be switched off and your laptop will use the integrated Intel graphics to save power.
Have fun! If you have any questions, please leave them in the comments.