Monday, 4 June 2018

Make three-finger tap middle-click again in Ubuntu/Xubuntu 18.04 LTS

Perhaps this also affected earlier versions, such as 17.04 or 17.10, but I'm only experiencing this now. After installing 18.04 LTS, my ThinkPad's touchpad no longer registers a three-finger tap as a middle click. In fact, a three-finger tap now does nothing.

It's easy to fix this. First, let's make a xorg.conf.d directory, if you don't already have it:

$ sudo mkdir -p /etc/X11/xorg.conf.d
$

Now you're going to use your favourite editor, and edit /etc/X11/xorg.conf.d/70-synaptics.conf and put the following inside it:

Section "InputClass"
    Identifier "Touchpad"
    MatchIsTouchpad "on"
    Driver "synaptics"
    Option "TapButton3" "2"
EndSection

Now reboot, and you're done. Three-finger tap should be middle-click.

Thursday, 1 February 2018

Bumblebee on a Lenovo T440p [NVidia GT 730M] with XUbuntu/Ubuntu 17.10

In this guide, I'll help you, step by step, to set up bumblebee on a laptop with NVidia Optimus. Bumblebee is a daemon program that aims to offload programs to the discrete GPU at the user's discretion. I have tested this solution thoroughly on a Lenovo T440p, which has a GT 730M inside it; at least on some models. It is highly likely that bumblebee can be made to work in exactly the same way on other laptops, but as I have not tested this, this is experimental. I will make notes where I can to provide compatibility for other machines, hopefully from comments of readers.

Also, and I think this is important. I was working with a clean, fresh install of Ubuntu 17.10. Any tinkering you may have done previous to trying this guide may interfere with the steps presented herein. I recommend you undo them or install afresh; or you're a really advanced user and can deal with massaging this guide into your existing system. Anyway, onwards ...

1. Install a fresh copy of Ubuntu 17.10

Tada!

2. Blacklist nouveau

nouveau is the open-source NVidia graphics driver. It interferes with what we're going to try to do, which is to use the proprietary drivers, so we have to make sure the kernel doesn't auto-load it.

Create the file /etc/modprobe.d/blacklist-nouveau.conf and put this inside it:

blacklist nouveau

Now rebuild your ram-disk so that the changes are picked up and the ram-disk doesn't have the modules in it:

$ sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-4.13.0-21-generic
$


3.  Set your ACPI interface.

In earlier versions of Ubuntu, the Kernel was such that this wasn't necessary. On newer Kernels, however, this is necessary, or your card cannot be controlled by bbswitch.

Edit the /etc/default/grub file and add acpi_osi=Linux to the kernel parameters, so that it looks like this:

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="acpi_osi=Linux"

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

Note: Output above is truncated.

Note: Some people have also reported success with acpi_osi=\"!Windows 2013\", but I haven't had this succeed. In fact, it just made my laptop go funny where I could no longer shut-down correctly.

Note: u/andrewschott has noted that on Dell Inspiron 5000 series (5577, specifically), the string acpi_osi=! acpi_osi=\"Windows 2009\" is required to make bumblebee work. Please refer to his blog entry for more details.

Update the boot-loader:

$ sudo update-grub
Generating grub configuration file ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-4.13.0-21-generic
Found initrd image: /boot/initrd.img-4.13.0-21-generic
done
$

4. Activate intel drivers for your integrated GPU

I know what you're thinking: "We're trying to get the discrete GPU working, not the integrated one!" Although it doesn't work without this. If the intel driver is not driving your integrated Intel GPU, then the bumblebee method won't work. You'll get GLX errors left, right and centre.

Interestingly, for some reason, 17.10 uses the vesa driver to drive the integrated Intel GPU by default. Why? No idea; 16.04 loaded the intel driver by default. That might be something I'll puzzle out in another post. For now let's just make it use intel.

You might already have this directory, but let's make it if you don't:

$ sudo mkdir -p /etc/X11/xorg.conf.d
$

Now edit the file /etc/X11/xorg.conf.d/20-intel.conf and put this inside it:

Section "Device"
   Identifier  "Intel Graphics"
   Driver      "intel"
   Option      "AccelMethod" "sna"
   Option      "TearFree" "true"
EndSection

What this does is actually twofold. It enables intel as the driver for your integrated GPU, and also enables TearFree, which is Intel's term for V-Sync. You'll most-likely want V-Sync. I recommend it.

5. Reboot

Yes, you have to. We need the new ram-disk to be booted with the new parameters.

$ sudo reboot

6. Install bumblebee and friends

We're going to install bumblebee, but we're going to override the default driver that bumblebee wants to install. First of all, update your package list:

$ sudo apt-get update
Hit:1 http://au.archive.ubuntu.com/ubuntu artful InRelease
Get:2 http://au.archive.ubuntu.com/ubuntu artful-updates InRelease [78.6 kB]                         
Get:3 http://au.archive.ubuntu.com/ubuntu artful-backports InRelease [72.2 kB]                                  
Get:4 http://au.archive.ubuntu.com/ubuntu artful-updates/main amd64 Packages [161 kB]                             
Get:5 http://security.ubuntu.com/ubuntu artful-security InRelease [78.6 kB]      
Get:6 http://au.archive.ubuntu.com/ubuntu artful-updates/main i386 Packages [159 kB]
Get:7 http://au.archive.ubuntu.com/ubuntu artful-updates/main Translation-en [71.7 kB]
Get:8 http://au.archive.ubuntu.com/ubuntu artful-updates/main amd64 DEP-11 Metadata [68.8 kB]   
Get:9 http://au.archive.ubuntu.com/ubuntu artful-updates/main DEP-11 64x64 Icons [40.3 kB]            
Get:10 http://au.archive.ubuntu.com/ubuntu artful-updates/universe amd64 Packages [60.9 kB]        
Get:11 http://au.archive.ubuntu.com/ubuntu artful-updates/universe i386 Packages [60.4 kB]  
Get:12 http://au.archive.ubuntu.com/ubuntu artful-updates/universe Translation-en [35.8 kB]
Get:13 http://au.archive.ubuntu.com/ubuntu artful-updates/universe amd64 DEP-11 Metadata [48.4 kB]
Get:14 http://au.archive.ubuntu.com/ubuntu artful-updates/universe DEP-11 64x64 Icons [52.8 kB]         
Get:15 http://au.archive.ubuntu.com/ubuntu artful-backports/universe amd64 DEP-11 Metadata [4,712 B]   
Get:16 http://security.ubuntu.com/ubuntu artful-security/main amd64 Packages [75.2 kB]
Get:17 http://security.ubuntu.com/ubuntu artful-security/main i386 Packages [73.5 kB]
Get:18 http://security.ubuntu.com/ubuntu artful-security/main Translation-en [34.8 kB]
Get:19 http://security.ubuntu.com/ubuntu artful-security/main amd64 DEP-11 Metadata [2,920 B]
Get:20 http://security.ubuntu.com/ubuntu artful-security/universe i386 Packages [26.6 kB]
Get:21 http://security.ubuntu.com/ubuntu artful-security/universe amd64 Packages [26.7 kB]
Get:22 http://security.ubuntu.com/ubuntu artful-security/universe Translation-en [16.6 kB]
Get:23 http://security.ubuntu.com/ubuntu artful-security/universe amd64 DEP-11 Metadata [10.4 kB]
Get:24 http://security.ubuntu.com/ubuntu artful-security/universe DEP-11 64x64 Icons [10.2 kB]
Fetched 1,270 kB in 3s (406 kB/s)                                      
Reading package lists... Done
$

Install bumblebee:

$ sudo apt-get install bumblebee-nvidia nvidia-384
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following additional packages will be installed:
  bbswitch-dkms build-essential bumblebee dkms dpkg-dev fakeroot g++ g++-7 gcc gcc-7 gcc-7-base:i386 lib32gcc1 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libatomic1 libbsd0:i386 libc-dev-bin libc6 libc6:i386 libc6-dbg libc6-dev
  libc6-i386 libcilkrts5 libcuda1-384 libdrm-amdgpu1:i386 libdrm-intel1:i386 libdrm-nouveau2:i386 libdrm-radeon1:i386 libdrm2:i386 libedit2:i386 libegl1-mesa libelf1:i386 libexpat1:i386 libfakeroot libffi6:i386 libgbm1 libgcc-7-dev libgcc1:i386 libgl1-mesa-dri
  libgl1-mesa-dri:i386 libgl1-mesa-glx libgl1-mesa-glx:i386 libglapi-mesa libglapi-mesa:i386 libitm1 libllvm5.0:i386 liblsan0 libmpx2 libpciaccess0:i386 libquadmath0 libsensors4:i386 libstdc++-7-dev libstdc++6:i386 libtinfo5:i386 libtsan0 libtxc-dxtn-s2tc:i386
  libubsan0 libwayland-egl1-mesa libx11-6:i386 libx11-xcb1:i386 libxau6:i386 libxcb-dri2-0:i386 libxcb-dri3-0:i386 libxcb-glx0:i386 libxcb-present0:i386 libxcb-sync1:i386 libxcb1:i386 libxdamage1:i386 libxdmcp6:i386 libxext6:i386 libxfixes3:i386 libxnvctrl0
  libxshmfence1:i386 libxxf86vm1:i386 linux-libc-dev make manpages-dev nvidia-opencl-icd-384 nvidia-prime nvidia-settings ocl-icd-libopencl1 pkg-config primus primus-libs primus-libs:i386 primus-libs-ia32:i386 screen-resolution-extra socat zlib1g:i386
Suggested packages:
  menu debian-keyring g++-multilib g++-7-multilib gcc-7-doc libstdc++6-7-dbg gcc-multilib autoconf automake libtool flex bison gcc-doc gcc-7-multilib gcc-7-locales libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan4-dbg liblsan0-dbg libtsan0-dbg libubsan0-dbg
  libcilkrts5-dbg libmpx2-dbg libquadmath0-dbg glibc-doc glibc-doc:i386 locales:i386 lm-sensors:i386 libstdc++-7-doc make-doc
The following NEW packages will be installed:
  bbswitch-dkms build-essential bumblebee bumblebee-nvidia dkms dpkg-dev fakeroot g++ g++-7 gcc gcc-7 gcc-7-base:i386 lib32gcc1 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libatomic1 libbsd0:i386 libc-dev-bin libc6:i386 libc6-dev
  libc6-i386 libcilkrts5 libcuda1-384 libdrm-amdgpu1:i386 libdrm-intel1:i386 libdrm-nouveau2:i386 libdrm-radeon1:i386 libdrm2:i386 libedit2:i386 libelf1:i386 libexpat1:i386 libfakeroot libffi6:i386 libgcc-7-dev libgcc1:i386 libgl1-mesa-dri:i386 libgl1-mesa-glx:i386
  libglapi-mesa:i386 libitm1 libllvm5.0:i386 liblsan0 libmpx2 libpciaccess0:i386 libquadmath0 libsensors4:i386 libstdc++-7-dev libstdc++6:i386 libtinfo5:i386 libtsan0 libtxc-dxtn-s2tc:i386 libubsan0 libx11-6:i386 libx11-xcb1:i386 libxau6:i386 libxcb-dri2-0:i386
  libxcb-dri3-0:i386 libxcb-glx0:i386 libxcb-present0:i386 libxcb-sync1:i386 libxcb1:i386 libxdamage1:i386 libxdmcp6:i386 libxext6:i386 libxfixes3:i386 libxnvctrl0 libxshmfence1:i386 libxxf86vm1:i386 linux-libc-dev make manpages-dev nvidia-384 nvidia-opencl-icd-384
  nvidia-prime nvidia-settings ocl-icd-libopencl1 pkg-config primus primus-libs primus-libs:i386 primus-libs-ia32:i386 screen-resolution-extra socat zlib1g:i386
The following packages will be upgraded:
  libc6 libc6-dbg libegl1-mesa libgbm1 libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libwayland-egl1-mesa
8 to upgrade, 85 to newly install, 0 to remove and 42 not to upgrade.
Need to get 154 MB of archives.
After this operation, 715 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://au.archive.ubuntu.com/ubuntu artful-updates/main amd64 libc6-dbg amd64 2.26-0ubuntu2.1 [4,997 kB]
Get:2 http://au.archive.ubuntu.com/ubuntu artful-updates/main amd64 libc6 amd64 2.26-0ubuntu2.1 [2,780 kB]
Get:3 http://au.archive.ubuntu.com/ubuntu artful/main i386 gcc-7-base i386 7.2.0-8ubuntu3 [18.0 kB]
Get:4 http://au.archive.ubuntu.com/ubuntu artful/main i386 libgcc1 i386 1:7.2.0-8ubuntu3 [47.0 kB]
Get:5 http://au.archive.ubuntu.com/ubuntu artful-updates/main i386 libc6 i386 2.26-0ubuntu2.1 [2,548 kB]
Get:6 http://au.archive.ubuntu.com/ubuntu artful/main i386 libxau6 i386 1:1.0.8-1 [8,352 B]
Get:7 http://au.archive.ubuntu.com/ubuntu artful/main i386 libbsd0 i386 0.8.6-1 [45.1 kB]
Get:8 http://au.archive.ubuntu.com/ubuntu artful/main i386 libxdmcp6 i386 1:1.1.2-3 [11.1 kB]
Get:9 http://au.archive.ubuntu.com/ubuntu artful/main i386 libxcb1 i386 1.12-1ubuntu1 [49.6 kB]
Get:10 http://au.archive.ubuntu.com/ubuntu artful/main i386 libx11-6 i386 2:1.6.4-3 [594 kB]
Get:11 http://au.archive.ubuntu.com/ubuntu artful/main i386 libxext6 i386 2:1.3.3-1 [31.6 kB]
Get:12 http://au.archive.ubuntu.com/ubuntu artful/main i386 libxshmfence1 i386 1.2-1 [5,164 B]
Get:13 http://au.archive.ubuntu.com/ubuntu artful/main i386 libxxf86vm1 i386 1:1.1.4-1 [11.3 kB]
Get:14 http://au.archive.ubuntu.com/ubuntu artful/main amd64 libitm1 amd64 7.2.0-8ubuntu3 [27.6 kB]
Get:15 http://au.archive.ubuntu.com/ubuntu artful/main amd64 libatomic1 amd64 7.2.0-8ubuntu3 [8,954 B]
Get:16 http://au.archive.ubuntu.com/ubuntu artful/main amd64 libasan4 amd64 7.2.0-8ubuntu3 [360 kB]
Get:17 http://au.archive.ubuntu.com/ubuntu artful/main amd64 liblsan0 amd64 7.2.0-8ubuntu3 [133 kB]
Get:18 http://au.archive.ubuntu.com/ubuntu artful/main amd64 libtsan0 amd64 7.2.0-8ubuntu3 [282 kB]
Get:19 http://au.archive.ubuntu.com/ubuntu artful/main amd64 libubsan0 amd64 7.2.0-8ubuntu3 [126 kB]
Get:20 http://au.archive.ubuntu.com/ubuntu artful/main amd64 libcilkrts5 amd64 7.2.0-8ubuntu3 [42.5 kB]
Get:21 http://au.archive.ubuntu.com/ubuntu artful/main amd64 libmpx2 amd64 7.2.0-8ubuntu3 [11.7 kB]
Get:22 http://au.archive.ubuntu.com/ubuntu artful/main amd64 libquadmath0 amd64 7.2.0-8ubuntu3 [132 kB]
Get:23 http://au.archive.ubuntu.com/ubuntu artful/main amd64 libgcc-7-dev amd64 7.2.0-8ubuntu3 [2,378 kB]
Get:24 http://au.archive.ubuntu.com/ubuntu artful/main amd64 gcc-7 amd64 7.2.0-8ubuntu3 [7,411 kB]
Get:25 http://au.archive.ubuntu.com/ubuntu artful/main amd64 gcc amd64 4:7.2.0-1ubuntu1 [5,124 B]
Get:26 http://au.archive.ubuntu.com/ubuntu artful/main amd64 make amd64 4.1-9.1 [154 kB]
Get:27 http://au.archive.ubuntu.com/ubuntu artful-updates/main amd64 libc-dev-bin amd64 2.26-0ubuntu2.1 [69.5 kB]
Get:28 http://au.archive.ubuntu.com/ubuntu artful-updates/main amd64 linux-libc-dev amd64 4.13.0-32.35 [950 kB]
Get:29 http://au.archive.ubuntu.com/ubuntu artful-updates/main amd64 libc6-dev amd64 2.26-0ubuntu2.1 [2,526 kB]
Get:30 http://au.archive.ubuntu.com/ubuntu artful/main amd64 libstdc++-7-dev amd64 7.2.0-8ubuntu3 [1,456 kB]
Get:31 http://au.archive.ubuntu.com/ubuntu artful/main amd64 g++-7 amd64 7.2.0-8ubuntu3 [7,551 kB]
Get:32 http://au.archive.ubuntu.com/ubuntu artful/main amd64 g++ amd64 4:7.2.0-1ubuntu1 [1,482 B]
Get:33 http://au.archive.ubuntu.com/ubuntu artful/main amd64 dpkg-dev all 1.18.24ubuntu1 [608 kB]
Get:34 http://au.archive.ubuntu.com/ubuntu artful/main amd64 build-essential amd64 12.4ubuntu1 [4,758 B]
Get:35 http://au.archive.ubuntu.com/ubuntu artful/main amd64 dkms all 2.3-3ubuntu3 [68.3 kB]
Get:36 http://au.archive.ubuntu.com/ubuntu artful/main amd64 bbswitch-dkms amd64 0.8-4ubuntu1 [11.6 kB]
Get:37 http://au.archive.ubuntu.com/ubuntu artful/universe amd64 bumblebee amd64 3.2.1-16 [49.6 kB]
Get:38 http://au.archive.ubuntu.com/ubuntu artful/main i386 libtinfo5 i386 6.0+20160625-1ubuntu1 [78.0 kB]
Get:39 http://au.archive.ubuntu.com/ubuntu artful/main i386 zlib1g i386 1:1.2.11.dfsg-0ubuntu2 [58.2 kB]
Get:40 http://au.archive.ubuntu.com/ubuntu artful/main i386 libelf1 i386 0.170-0.1 [50.9 kB]
Get:41 http://au.archive.ubuntu.com/ubuntu artful/main i386 libexpat1 i386 2.2.3-1 [75.1 kB]
Get:42 http://au.archive.ubuntu.com/ubuntu artful/main i386 libffi6 i386 3.2.1-6 [16.9 kB]
Get:43 http://au.archive.ubuntu.com/ubuntu artful/main i386 libstdc++6 i386 7.2.0-8ubuntu3 [437 kB]
Get:44 http://au.archive.ubuntu.com/ubuntu artful/main i386 libdrm2 i386 2.4.83-1 [33.2 kB]
Get:45 http://au.archive.ubuntu.com/ubuntu artful/main i386 libedit2 i386 3.1-20170329-1 [80.4 kB]
Get:46 http://au.archive.ubuntu.com/ubuntu artful/main amd64 libfakeroot amd64 1.21-1ubuntu2 [25.9 kB]
Get:47 http://au.archive.ubuntu.com/ubuntu artful/main amd64 fakeroot amd64 1.21-1ubuntu2 [62.2 kB]
Get:48 http://au.archive.ubuntu.com/ubuntu artful/main amd64 libalgorithm-diff-perl all 1.19.03-1 [47.6 kB]
Get:49 http://au.archive.ubuntu.com/ubuntu artful/main amd64 libalgorithm-diff-xs-perl amd64 0.04-4build3 [11.2 kB]
Get:50 http://au.archive.ubuntu.com/ubuntu artful/main amd64 libalgorithm-merge-perl all 0.08-3 [12.0 kB]
Get:51 http://au.archive.ubuntu.com/ubuntu artful-updates/main amd64 libc6-i386 amd64 2.26-0ubuntu2.1 [2,638 kB]
Get:52 http://au.archive.ubuntu.com/ubuntu artful/main amd64 lib32gcc1 amd64 1:7.2.0-8ubuntu3 [46.8 kB]
Get:53 http://au.archive.ubuntu.com/ubuntu artful-updates/main amd64 libgl1-mesa-glx amd64 17.2.4-0ubuntu1~17.10.2 [130 kB]
Get:54 http://au.archive.ubuntu.com/ubuntu artful-updates/main amd64 libglapi-mesa amd64 17.2.4-0ubuntu1~17.10.2 [22.4 kB]
Get:55 http://au.archive.ubuntu.com/ubuntu artful-updates/main amd64 libwayland-egl1-mesa amd64 17.2.4-0ubuntu1~17.10.2 [5,780 B]
Get:56 http://au.archive.ubuntu.com/ubuntu artful-updates/main amd64 libegl1-mesa amd64 17.2.4-0ubuntu1~17.10.2 [85.1 kB]
Get:57 http://au.archive.ubuntu.com/ubuntu artful-updates/main amd64 libgbm1 amd64 17.2.4-0ubuntu1~17.10.2 [24.5 kB]
Get:58 http://au.archive.ubuntu.com/ubuntu artful-updates/main amd64 libgl1-mesa-dri amd64 17.2.4-0ubuntu1~17.10.2 [5,712 kB]
Get:59 http://au.archive.ubuntu.com/ubuntu artful-updates/restricted amd64 nvidia-384 amd64 384.111-0ubuntu0.17.10.1 [76.6 MB]
Get:60 http://au.archive.ubuntu.com/ubuntu artful-updates/restricted amd64 libcuda1-384 amd64 384.111-0ubuntu0.17.10.1 [3,709 kB]
Get:61 http://au.archive.ubuntu.com/ubuntu artful/main i386 libdrm-amdgpu1 i386 2.4.83-1 [21.8 kB]
Get:62 http://au.archive.ubuntu.com/ubuntu artful/main i386 libpciaccess0 i386 0.13.4-1ubuntu1 [20.2 kB]
Get:63 http://au.archive.ubuntu.com/ubuntu artful/main i386 libdrm-intel1 i386 2.4.83-1 [63.7 kB]
Get:64 http://au.archive.ubuntu.com/ubuntu artful/main i386 libdrm-nouveau2 i386 2.4.83-1 [18.2 kB]
Get:65 http://au.archive.ubuntu.com/ubuntu artful/main i386 libdrm-radeon1 i386 2.4.83-1 [23.0 kB]
Get:66 http://au.archive.ubuntu.com/ubuntu artful-updates/main i386 libglapi-mesa i386 17.2.4-0ubuntu1~17.10.2 [22.7 kB]
Get:67 http://au.archive.ubuntu.com/ubuntu artful/main i386 libllvm5.0 i386 1:5.0-3 [15.3 MB]
Get:68 http://au.archive.ubuntu.com/ubuntu artful/main i386 libsensors4 i386 1:3.4.0-4 [29.3 kB]
Get:69 http://au.archive.ubuntu.com/ubuntu artful-updates/main i386 libgl1-mesa-dri i386 17.2.4-0ubuntu1~17.10.2 [6,148 kB]
Get:70 http://au.archive.ubuntu.com/ubuntu artful/main i386 libx11-xcb1 i386 2:1.6.4-3 [9,596 B]
Get:71 http://au.archive.ubuntu.com/ubuntu artful/main i386 libxcb-dri2-0 i386 1.12-1ubuntu1 [7,222 B]
Get:72 http://au.archive.ubuntu.com/ubuntu artful/main i386 libxcb-dri3-0 i386 1.12-1ubuntu1 [5,288 B]
Get:73 http://au.archive.ubuntu.com/ubuntu artful/main i386 libxcb-glx0 i386 1.12-1ubuntu1 [23.9 kB]
Get:74 http://au.archive.ubuntu.com/ubuntu artful/main i386 libxcb-present0 i386 1.12-1ubuntu1 [5,596 B]
Get:75 http://au.archive.ubuntu.com/ubuntu artful/main i386 libxcb-sync1 i386 1.12-1ubuntu1 [9,094 B]
Get:76 http://au.archive.ubuntu.com/ubuntu artful/main i386 libxdamage1 i386 1:1.1.4-3 [7,090 B]
Get:77 http://au.archive.ubuntu.com/ubuntu artful/main i386 libxfixes3 i386 1:5.0.3-1 [11.2 kB]
Get:78 http://au.archive.ubuntu.com/ubuntu artful-updates/main i386 libgl1-mesa-glx i386 17.2.4-0ubuntu1~17.10.2 [138 kB]
Get:79 http://au.archive.ubuntu.com/ubuntu artful/main amd64 libxnvctrl0 amd64 384.69-0ubuntu1 [11.2 kB]
Get:80 http://au.archive.ubuntu.com/ubuntu artful/main amd64 manpages-dev all 4.13-3 [2,202 kB]
Get:81 http://au.archive.ubuntu.com/ubuntu artful/main amd64 ocl-icd-libopencl1 amd64 2.2.11-1ubuntu1 [30.3 kB]
Get:82 http://au.archive.ubuntu.com/ubuntu artful-updates/restricted amd64 nvidia-opencl-icd-384 amd64 384.111-0ubuntu0.17.10.1 [3,370 kB]
Get:83 http://au.archive.ubuntu.com/ubuntu artful/main amd64 nvidia-prime amd64 0.8.5 [11.0 kB]
Get:84 http://au.archive.ubuntu.com/ubuntu artful/main amd64 pkg-config amd64 0.29.1-0ubuntu2 [45.0 kB]
Get:85 http://au.archive.ubuntu.com/ubuntu artful/main amd64 screen-resolution-extra all 0.17.1 [11.4 kB]
Get:86 http://au.archive.ubuntu.com/ubuntu artful/main amd64 nvidia-settings amd64 384.69-0ubuntu1 [881 kB]
Get:87 http://au.archive.ubuntu.com/ubuntu artful/universe amd64 bumblebee-nvidia amd64 3.2.1-16 [2,940 B]
Get:88 http://au.archive.ubuntu.com/ubuntu artful/main i386 libtxc-dxtn-s2tc i386 1.0+git20151227-2 [47.8 kB]
Get:89 http://au.archive.ubuntu.com/ubuntu artful/universe amd64 socat amd64 1.7.3.2-1 [342 kB]
Get:90 http://au.archive.ubuntu.com/ubuntu artful/universe amd64 primus-libs amd64 0~20150328-4 [48.9 kB]
Get:91 http://au.archive.ubuntu.com/ubuntu artful/universe amd64 primus amd64 0~20150328-4 [9,730 B]
Get:92 http://au.archive.ubuntu.com/ubuntu artful/universe i386 primus-libs i386 0~20150328-4 [55.3 kB]
Get:93 http://au.archive.ubuntu.com/ubuntu artful/universe i386 primus-libs-ia32 i386 0~20150328-4 [2,176 B]
Fetched 154 MB in 3min 29s (737 kB/s)
Extracting templates from packages: 100%
Preconfiguring packages ...
(Reading database ... 139804 files and directories currently installed.)
Preparing to unpack .../libc6-dbg_2.26-0ubuntu2.1_amd64.deb ...
Unpacking libc6-dbg:amd64 (2.26-0ubuntu2.1) over (2.26-0ubuntu2) ...
Preparing to unpack .../libc6_2.26-0ubuntu2.1_amd64.deb ...
Unpacking libc6:amd64 (2.26-0ubuntu2.1) over (2.26-0ubuntu2) ...
Selecting previously unselected package libc6:i386.
Preparing to unpack .../libc6_2.26-0ubuntu2.1_i386.deb ...
Unpacking libc6:i386 (2.26-0ubuntu2.1) ...
Setting up libc6:amd64 (2.26-0ubuntu2.1) ...
Selecting previously unselected package libgcc1:i386.
(Reading database ... 140108 files and directories currently installed.)
Preparing to unpack .../libgcc1_1%3a7.2.0-8ubuntu3_i386.deb ...
Unpacking libgcc1:i386 (1:7.2.0-8ubuntu3) ...
Selecting previously unselected package gcc-7-base:i386.
Preparing to unpack .../gcc-7-base_7.2.0-8ubuntu3_i386.deb ...
Unpacking gcc-7-base:i386 (7.2.0-8ubuntu3) ...
Setting up gcc-7-base:i386 (7.2.0-8ubuntu3) ...
Setting up libgcc1:i386 (1:7.2.0-8ubuntu3) ...
Setting up libc6:i386 (2.26-0ubuntu2.1) ...
Selecting previously unselected package libxau6:i386.
(Reading database ... 140113 files and directories currently installed.)
Preparing to unpack .../00-libxau6_1%3a1.0.8-1_i386.deb ...
Unpacking libxau6:i386 (1:1.0.8-1) ...
Selecting previously unselected package libbsd0:i386.
Preparing to unpack .../01-libbsd0_0.8.6-1_i386.deb ...
Unpacking libbsd0:i386 (0.8.6-1) ...
Selecting previously unselected package libxdmcp6:i386.
Preparing to unpack .../02-libxdmcp6_1%3a1.1.2-3_i386.deb ...
Unpacking libxdmcp6:i386 (1:1.1.2-3) ...
Selecting previously unselected package libxcb1:i386.
Preparing to unpack .../03-libxcb1_1.12-1ubuntu1_i386.deb ...
Unpacking libxcb1:i386 (1.12-1ubuntu1) ...
Selecting previously unselected package libx11-6:i386.
Preparing to unpack .../04-libx11-6_2%3a1.6.4-3_i386.deb ...
Unpacking libx11-6:i386 (2:1.6.4-3) ...
Selecting previously unselected package libxext6:i386.
Preparing to unpack .../05-libxext6_2%3a1.3.3-1_i386.deb ...
Unpacking libxext6:i386 (2:1.3.3-1) ...
Selecting previously unselected package libxshmfence1:i386.
Preparing to unpack .../06-libxshmfence1_1.2-1_i386.deb ...
Unpacking libxshmfence1:i386 (1.2-1) ...
Selecting previously unselected package libxxf86vm1:i386.
Preparing to unpack .../07-libxxf86vm1_1%3a1.1.4-1_i386.deb ...
Unpacking libxxf86vm1:i386 (1:1.1.4-1) ...
Selecting previously unselected package libitm1:amd64.
Preparing to unpack .../08-libitm1_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libitm1:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libatomic1:amd64.
Preparing to unpack .../09-libatomic1_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libatomic1:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libasan4:amd64.
Preparing to unpack .../10-libasan4_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libasan4:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package liblsan0:amd64.
Preparing to unpack .../11-liblsan0_7.2.0-8ubuntu3_amd64.deb ...
Unpacking liblsan0:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libtsan0:amd64.
Preparing to unpack .../12-libtsan0_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libtsan0:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libubsan0:amd64.
Preparing to unpack .../13-libubsan0_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libubsan0:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libcilkrts5:amd64.
Preparing to unpack .../14-libcilkrts5_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libcilkrts5:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libmpx2:amd64.
Preparing to unpack .../15-libmpx2_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libmpx2:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libquadmath0:amd64.
Preparing to unpack .../16-libquadmath0_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libquadmath0:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libgcc-7-dev:amd64.
Preparing to unpack .../17-libgcc-7-dev_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libgcc-7-dev:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package gcc-7.
Preparing to unpack .../18-gcc-7_7.2.0-8ubuntu3_amd64.deb ...
Unpacking gcc-7 (7.2.0-8ubuntu3) ...
Selecting previously unselected package gcc.
Preparing to unpack .../19-gcc_4%3a7.2.0-1ubuntu1_amd64.deb ...
Unpacking gcc (4:7.2.0-1ubuntu1) ...
Selecting previously unselected package make.
Preparing to unpack .../20-make_4.1-9.1_amd64.deb ...
Unpacking make (4.1-9.1) ...
Selecting previously unselected package libc-dev-bin.
Preparing to unpack .../21-libc-dev-bin_2.26-0ubuntu2.1_amd64.deb ...
Unpacking libc-dev-bin (2.26-0ubuntu2.1) ...
Selecting previously unselected package linux-libc-dev:amd64.
Preparing to unpack .../22-linux-libc-dev_4.13.0-32.35_amd64.deb ...
Unpacking linux-libc-dev:amd64 (4.13.0-32.35) ...
Selecting previously unselected package libc6-dev:amd64.
Preparing to unpack .../23-libc6-dev_2.26-0ubuntu2.1_amd64.deb ...
Unpacking libc6-dev:amd64 (2.26-0ubuntu2.1) ...
Selecting previously unselected package libstdc++-7-dev:amd64.
Preparing to unpack .../24-libstdc++-7-dev_7.2.0-8ubuntu3_amd64.deb ...
Unpacking libstdc++-7-dev:amd64 (7.2.0-8ubuntu3) ...
Selecting previously unselected package g++-7.
Preparing to unpack .../25-g++-7_7.2.0-8ubuntu3_amd64.deb ...
Unpacking g++-7 (7.2.0-8ubuntu3) ...
Selecting previously unselected package g++.
Preparing to unpack .../26-g++_4%3a7.2.0-1ubuntu1_amd64.deb ...
Unpacking g++ (4:7.2.0-1ubuntu1) ...
Selecting previously unselected package dpkg-dev.
Preparing to unpack .../27-dpkg-dev_1.18.24ubuntu1_all.deb ...
Unpacking dpkg-dev (1.18.24ubuntu1) ...
Selecting previously unselected package build-essential.
Preparing to unpack .../28-build-essential_12.4ubuntu1_amd64.deb ...
Unpacking build-essential (12.4ubuntu1) ...
Selecting previously unselected package dkms.
Preparing to unpack .../29-dkms_2.3-3ubuntu3_all.deb ...
Unpacking dkms (2.3-3ubuntu3) ...
Selecting previously unselected package bbswitch-dkms.
Preparing to unpack .../30-bbswitch-dkms_0.8-4ubuntu1_amd64.deb ...
Unpacking bbswitch-dkms (0.8-4ubuntu1) ...
Selecting previously unselected package bumblebee.
Preparing to unpack .../31-bumblebee_3.2.1-16_amd64.deb ...
Unpacking bumblebee (3.2.1-16) ...
Selecting previously unselected package libtinfo5:i386.
Preparing to unpack .../32-libtinfo5_6.0+20160625-1ubuntu1_i386.deb ...
Unpacking libtinfo5:i386 (6.0+20160625-1ubuntu1) ...
Selecting previously unselected package zlib1g:i386.
Preparing to unpack .../33-zlib1g_1%3a1.2.11.dfsg-0ubuntu2_i386.deb ...
Unpacking zlib1g:i386 (1:1.2.11.dfsg-0ubuntu2) ...
Selecting previously unselected package libelf1:i386.
Preparing to unpack .../34-libelf1_0.170-0.1_i386.deb ...
Unpacking libelf1:i386 (0.170-0.1) ...
Selecting previously unselected package libexpat1:i386.
Preparing to unpack .../35-libexpat1_2.2.3-1_i386.deb ...
Unpacking libexpat1:i386 (2.2.3-1) ...
Selecting previously unselected package libffi6:i386.
Preparing to unpack .../36-libffi6_3.2.1-6_i386.deb ...
Unpacking libffi6:i386 (3.2.1-6) ...
Selecting previously unselected package libstdc++6:i386.
Preparing to unpack .../37-libstdc++6_7.2.0-8ubuntu3_i386.deb ...
Unpacking libstdc++6:i386 (7.2.0-8ubuntu3) ...
Selecting previously unselected package libdrm2:i386.
Preparing to unpack .../38-libdrm2_2.4.83-1_i386.deb ...
Unpacking libdrm2:i386 (2.4.83-1) ...
Selecting previously unselected package libedit2:i386.
Preparing to unpack .../39-libedit2_3.1-20170329-1_i386.deb ...
Unpacking libedit2:i386 (3.1-20170329-1) ...
Selecting previously unselected package libfakeroot:amd64.
Preparing to unpack .../40-libfakeroot_1.21-1ubuntu2_amd64.deb ...
Unpacking libfakeroot:amd64 (1.21-1ubuntu2) ...
Selecting previously unselected package fakeroot.
Preparing to unpack .../41-fakeroot_1.21-1ubuntu2_amd64.deb ...
Unpacking fakeroot (1.21-1ubuntu2) ...
Selecting previously unselected package libalgorithm-diff-perl.
Preparing to unpack .../42-libalgorithm-diff-perl_1.19.03-1_all.deb ...
Unpacking libalgorithm-diff-perl (1.19.03-1) ...
Selecting previously unselected package libalgorithm-diff-xs-perl.
Preparing to unpack .../43-libalgorithm-diff-xs-perl_0.04-4build3_amd64.deb ...
Unpacking libalgorithm-diff-xs-perl (0.04-4build3) ...
Selecting previously unselected package libalgorithm-merge-perl.
Preparing to unpack .../44-libalgorithm-merge-perl_0.08-3_all.deb ...
Unpacking libalgorithm-merge-perl (0.08-3) ...
Selecting previously unselected package libc6-i386.
Preparing to unpack .../45-libc6-i386_2.26-0ubuntu2.1_amd64.deb ...
Unpacking libc6-i386 (2.26-0ubuntu2.1) ...
Replaced by files in installed package libc6:i386 (2.26-0ubuntu2.1) ...
Selecting previously unselected package lib32gcc1.
Preparing to unpack .../46-lib32gcc1_1%3a7.2.0-8ubuntu3_amd64.deb ...
Unpacking lib32gcc1 (1:7.2.0-8ubuntu3) ...
Preparing to unpack .../47-libgl1-mesa-glx_17.2.4-0ubuntu1~17.10.2_amd64.deb ...
Unpacking libgl1-mesa-glx:amd64 (17.2.4-0ubuntu1~17.10.2) over (17.2.2-0ubuntu1) ...
Preparing to unpack .../48-libglapi-mesa_17.2.4-0ubuntu1~17.10.2_amd64.deb ...
Unpacking libglapi-mesa:amd64 (17.2.4-0ubuntu1~17.10.2) over (17.2.2-0ubuntu1) ...
Preparing to unpack .../49-libwayland-egl1-mesa_17.2.4-0ubuntu1~17.10.2_amd64.deb ...
Unpacking libwayland-egl1-mesa:amd64 (17.2.4-0ubuntu1~17.10.2) over (17.2.2-0ubuntu1) ...
Preparing to unpack .../50-libegl1-mesa_17.2.4-0ubuntu1~17.10.2_amd64.deb ...
Unpacking libegl1-mesa:amd64 (17.2.4-0ubuntu1~17.10.2) over (17.2.2-0ubuntu1) ...
Preparing to unpack .../51-libgbm1_17.2.4-0ubuntu1~17.10.2_amd64.deb ...
Unpacking libgbm1:amd64 (17.2.4-0ubuntu1~17.10.2) over (17.2.2-0ubuntu1) ...
Preparing to unpack .../52-libgl1-mesa-dri_17.2.4-0ubuntu1~17.10.2_amd64.deb ...
Unpacking libgl1-mesa-dri:amd64 (17.2.4-0ubuntu1~17.10.2) over (17.2.2-0ubuntu1) ...
Selecting previously unselected package nvidia-384.
Preparing to unpack .../53-nvidia-384_384.111-0ubuntu0.17.10.1_amd64.deb ...
Unpacking nvidia-384 (384.111-0ubuntu0.17.10.1) ...
Selecting previously unselected package libcuda1-384.
Preparing to unpack .../54-libcuda1-384_384.111-0ubuntu0.17.10.1_amd64.deb ...
Unpacking libcuda1-384 (384.111-0ubuntu0.17.10.1) ...
Selecting previously unselected package libdrm-amdgpu1:i386.
Preparing to unpack .../55-libdrm-amdgpu1_2.4.83-1_i386.deb ...
Unpacking libdrm-amdgpu1:i386 (2.4.83-1) ...
Selecting previously unselected package libpciaccess0:i386.
Preparing to unpack .../56-libpciaccess0_0.13.4-1ubuntu1_i386.deb ...
Unpacking libpciaccess0:i386 (0.13.4-1ubuntu1) ...
Selecting previously unselected package libdrm-intel1:i386.
Preparing to unpack .../57-libdrm-intel1_2.4.83-1_i386.deb ...
Unpacking libdrm-intel1:i386 (2.4.83-1) ...
Selecting previously unselected package libdrm-nouveau2:i386.
Preparing to unpack .../58-libdrm-nouveau2_2.4.83-1_i386.deb ...
Unpacking libdrm-nouveau2:i386 (2.4.83-1) ...
Selecting previously unselected package libdrm-radeon1:i386.
Preparing to unpack .../59-libdrm-radeon1_2.4.83-1_i386.deb ...
Unpacking libdrm-radeon1:i386 (2.4.83-1) ...
Selecting previously unselected package libglapi-mesa:i386.
Preparing to unpack .../60-libglapi-mesa_17.2.4-0ubuntu1~17.10.2_i386.deb ...
Unpacking libglapi-mesa:i386 (17.2.4-0ubuntu1~17.10.2) ...
Selecting previously unselected package libllvm5.0:i386.
Preparing to unpack .../61-libllvm5.0_1%3a5.0-3_i386.deb ...
Unpacking libllvm5.0:i386 (1:5.0-3) ...
Selecting previously unselected package libsensors4:i386.
Preparing to unpack .../62-libsensors4_1%3a3.4.0-4_i386.deb ...
Unpacking libsensors4:i386 (1:3.4.0-4) ...
Selecting previously unselected package libgl1-mesa-dri:i386.
Preparing to unpack .../63-libgl1-mesa-dri_17.2.4-0ubuntu1~17.10.2_i386.deb ...
Unpacking libgl1-mesa-dri:i386 (17.2.4-0ubuntu1~17.10.2) ...
Selecting previously unselected package libx11-xcb1:i386.
Preparing to unpack .../64-libx11-xcb1_2%3a1.6.4-3_i386.deb ...
Unpacking libx11-xcb1:i386 (2:1.6.4-3) ...
Selecting previously unselected package libxcb-dri2-0:i386.
Preparing to unpack .../65-libxcb-dri2-0_1.12-1ubuntu1_i386.deb ...
Unpacking libxcb-dri2-0:i386 (1.12-1ubuntu1) ...
Selecting previously unselected package libxcb-dri3-0:i386.
Preparing to unpack .../66-libxcb-dri3-0_1.12-1ubuntu1_i386.deb ...
Unpacking libxcb-dri3-0:i386 (1.12-1ubuntu1) ...
Selecting previously unselected package libxcb-glx0:i386.
Preparing to unpack .../67-libxcb-glx0_1.12-1ubuntu1_i386.deb ...
Unpacking libxcb-glx0:i386 (1.12-1ubuntu1) ...
Selecting previously unselected package libxcb-present0:i386.
Preparing to unpack .../68-libxcb-present0_1.12-1ubuntu1_i386.deb ...
Unpacking libxcb-present0:i386 (1.12-1ubuntu1) ...
Selecting previously unselected package libxcb-sync1:i386.
Preparing to unpack .../69-libxcb-sync1_1.12-1ubuntu1_i386.deb ...
Unpacking libxcb-sync1:i386 (1.12-1ubuntu1) ...
Selecting previously unselected package libxdamage1:i386.
Preparing to unpack .../70-libxdamage1_1%3a1.1.4-3_i386.deb ...
Unpacking libxdamage1:i386 (1:1.1.4-3) ...
Selecting previously unselected package libxfixes3:i386.
Preparing to unpack .../71-libxfixes3_1%3a5.0.3-1_i386.deb ...
Unpacking libxfixes3:i386 (1:5.0.3-1) ...
Selecting previously unselected package libgl1-mesa-glx:i386.
Preparing to unpack .../72-libgl1-mesa-glx_17.2.4-0ubuntu1~17.10.2_i386.deb ...
Unpacking libgl1-mesa-glx:i386 (17.2.4-0ubuntu1~17.10.2) ...
Selecting previously unselected package libxnvctrl0.
Preparing to unpack .../73-libxnvctrl0_384.69-0ubuntu1_amd64.deb ...
Unpacking libxnvctrl0 (384.69-0ubuntu1) ...
Selecting previously unselected package manpages-dev.
Preparing to unpack .../74-manpages-dev_4.13-3_all.deb ...
Unpacking manpages-dev (4.13-3) ...
Selecting previously unselected package ocl-icd-libopencl1:amd64.
Preparing to unpack .../75-ocl-icd-libopencl1_2.2.11-1ubuntu1_amd64.deb ...
Unpacking ocl-icd-libopencl1:amd64 (2.2.11-1ubuntu1) ...
Selecting previously unselected package nvidia-opencl-icd-384.
Preparing to unpack .../76-nvidia-opencl-icd-384_384.111-0ubuntu0.17.10.1_amd64.deb ...
Unpacking nvidia-opencl-icd-384 (384.111-0ubuntu0.17.10.1) ...
Selecting previously unselected package nvidia-prime.
Preparing to unpack .../77-nvidia-prime_0.8.5_amd64.deb ...
Unpacking nvidia-prime (0.8.5) ...
Selecting previously unselected package pkg-config.
Preparing to unpack .../78-pkg-config_0.29.1-0ubuntu2_amd64.deb ...
Unpacking pkg-config (0.29.1-0ubuntu2) ...
Selecting previously unselected package screen-resolution-extra.
Preparing to unpack .../79-screen-resolution-extra_0.17.1_all.deb ...
Unpacking screen-resolution-extra (0.17.1) ...
Selecting previously unselected package nvidia-settings.
Preparing to unpack .../80-nvidia-settings_384.69-0ubuntu1_amd64.deb ...
Unpacking nvidia-settings (384.69-0ubuntu1) ...
Selecting previously unselected package bumblebee-nvidia.
Preparing to unpack .../81-bumblebee-nvidia_3.2.1-16_amd64.deb ...
Unpacking bumblebee-nvidia (3.2.1-16) ...
Selecting previously unselected package libtxc-dxtn-s2tc:i386.
Preparing to unpack .../82-libtxc-dxtn-s2tc_1.0+git20151227-2_i386.deb ...
Unpacking libtxc-dxtn-s2tc:i386 (1.0+git20151227-2) ...
Selecting previously unselected package socat.
Preparing to unpack .../83-socat_1.7.3.2-1_amd64.deb ...
Unpacking socat (1.7.3.2-1) ...
Selecting previously unselected package primus-libs:amd64.
Preparing to unpack .../84-primus-libs_0~20150328-4_amd64.deb ...
Unpacking primus-libs:amd64 (0~20150328-4) ...
Selecting previously unselected package primus.
Preparing to unpack .../85-primus_0~20150328-4_amd64.deb ...
Unpacking primus (0~20150328-4) ...
Selecting previously unselected package primus-libs:i386.
Preparing to unpack .../86-primus-libs_0~20150328-4_i386.deb ...
Unpacking primus-libs:i386 (0~20150328-4) ...
Selecting previously unselected package primus-libs-ia32:i386.
Preparing to unpack .../87-primus-libs-ia32_0~20150328-4_i386.deb ...
Unpacking primus-libs-ia32:i386 (0~20150328-4) ...
Setting up libquadmath0:amd64 (7.2.0-8ubuntu3) ...
Setting up libatomic1:amd64 (7.2.0-8ubuntu3) ...
Setting up libtinfo5:i386 (6.0+20160625-1ubuntu1) ...
Setting up libexpat1:i386 (2.2.3-1) ...
Setting up make (4.1-9.1) ...
Setting up libc6-dbg:amd64 (2.26-0ubuntu2.1) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for ureadahead (0.100.0-20) ...
Setting up libasan4:amd64 (7.2.0-8ubuntu3) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3) ...
Setting up libcilkrts5:amd64 (7.2.0-8ubuntu3) ...
Setting up zlib1g:i386 (1:1.2.11.dfsg-0ubuntu2) ...
Setting up socat (1.7.3.2-1) ...
Setting up libelf1:i386 (0.170-0.1) ...
Setting up libubsan0:amd64 (7.2.0-8ubuntu3) ...
Setting up libtsan0:amd64 (7.2.0-8ubuntu3) ...
Setting up libxshmfence1:i386 (1.2-1) ...
Setting up libgbm1:amd64 (17.2.4-0ubuntu1~17.10.2) ...
Setting up linux-libc-dev:amd64 (4.13.0-32.35) ...
Setting up libtxc-dxtn-s2tc:i386 (1.0+git20151227-2) ...
update-alternatives: using /usr/lib/i386-linux-gnu/s2tc/libtxc_dxtn.so to provide /usr/lib/i386-linux-gnu/libtxc_dxtn.so (libtxc-dxtn-i386-linux-gnu) in auto mode
Processing triggers for initramfs-tools (0.125ubuntu12) ...
update-initramfs: Generating /boot/initrd.img-4.13.0-21-generic
Setting up libc6-i386 (2.26-0ubuntu2.1) ...
Setting up libglapi-mesa:amd64 (17.2.4-0ubuntu1~17.10.2) ...
Setting up libglapi-mesa:i386 (17.2.4-0ubuntu1~17.10.2) ...
Setting up libbsd0:i386 (0.8.6-1) ...
Setting up libdrm2:i386 (2.4.83-1) ...
Setting up liblsan0:amd64 (7.2.0-8ubuntu3) ...
Setting up libmpx2:amd64 (7.2.0-8ubuntu3) ...
Setting up libx11-xcb1:i386 (2:1.6.4-3) ...
Setting up dpkg-dev (1.18.24ubuntu1) ...
Processing triggers for libc-bin (2.26-0ubuntu2) ...
Processing triggers for doc-base (0.10.7) ...
Processing 31 changed doc-base files, 2 added doc-base files...
Setting up libfakeroot:amd64 (1.21-1ubuntu2) ...
Setting up screen-resolution-extra (0.17.1) ...
Processing triggers for systemd (234-2ubuntu12.1) ...
Setting up libalgorithm-diff-perl (1.19.03-1) ...
Setting up libpciaccess0:i386 (0.13.4-1ubuntu1) ...
Setting up libsensors4:i386 (1:3.4.0-4) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up libstdc++6:i386 (7.2.0-8ubuntu3) ...
Setting up libffi6:i386 (3.2.1-6) ...
Setting up libc-dev-bin (2.26-0ubuntu2.1) ...
Setting up libdrm-radeon1:i386 (2.4.83-1) ...
Processing triggers for gnome-menus (3.13.3-6ubuntu5) ...
Setting up libxdmcp6:i386 (1:1.1.2-3) ...
Setting up ocl-icd-libopencl1:amd64 (2.2.11-1ubuntu1) ...
Processing triggers for dbus (1.10.22-1ubuntu1) ...
Setting up libdrm-nouveau2:i386 (2.4.83-1) ...
Setting up manpages-dev (4.13-3) ...
Setting up libc6-dev:amd64 (2.26-0ubuntu2.1) ...
Setting up libxnvctrl0 (384.69-0ubuntu1) ...
Setting up libitm1:amd64 (7.2.0-8ubuntu3) ...
Setting up libxau6:i386 (1:1.0.8-1) ...
Setting up lib32gcc1 (1:7.2.0-8ubuntu3) ...
Setting up libedit2:i386 (3.1-20170329-1) ...
Setting up libdrm-amdgpu1:i386 (2.4.83-1) ...
Setting up libgl1-mesa-dri:amd64 (17.2.4-0ubuntu1~17.10.2) ...
Setting up libllvm5.0:i386 (1:5.0-3) ...
Setting up fakeroot (1.21-1ubuntu2) ...
update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode
Setting up libgcc-7-dev:amd64 (7.2.0-8ubuntu3) ...
Setting up libstdc++-7-dev:amd64 (7.2.0-8ubuntu3) ...
Setting up libalgorithm-merge-perl (0.08-3) ...
Setting up pkg-config (0.29.1-0ubuntu2) ...
Setting up libdrm-intel1:i386 (2.4.83-1) ...
Setting up libalgorithm-diff-xs-perl (0.04-4build3) ...
Setting up libgl1-mesa-glx:amd64 (17.2.4-0ubuntu1~17.10.2) ...
Setting up libxcb1:i386 (1.12-1ubuntu1) ...
Setting up libegl1-mesa:amd64 (17.2.4-0ubuntu1~17.10.2) ...
Setting up libxcb-present0:i386 (1.12-1ubuntu1) ...
Setting up libxcb-dri2-0:i386 (1.12-1ubuntu1) ...
Setting up libxcb-dri3-0:i386 (1.12-1ubuntu1) ...
Setting up libxcb-glx0:i386 (1.12-1ubuntu1) ...
Setting up gcc-7 (7.2.0-8ubuntu3) ...
Setting up g++-7 (7.2.0-8ubuntu3) ...
Setting up primus-libs:amd64 (0~20150328-4) ...
Setting up libx11-6:i386 (2:1.6.4-3) ...
Setting up libgl1-mesa-dri:i386 (17.2.4-0ubuntu1~17.10.2) ...
Setting up gcc (4:7.2.0-1ubuntu1) ...
Setting up nvidia-settings (384.69-0ubuntu1) ...
Setting up libxcb-sync1:i386 (1.12-1ubuntu1) ...
Setting up dkms (2.3-3ubuntu3) ...
Setting up libwayland-egl1-mesa:amd64 (17.2.4-0ubuntu1~17.10.2) ...
Setting up nvidia-384 (384.111-0ubuntu0.17.10.1) ...
update-alternatives: using /usr/lib/nvidia-384/ld.so.conf to provide /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf (x86_64-linux-gnu_gl_conf) in auto mode
update-alternatives: using /usr/lib/nvidia-384/ld.so.conf to provide /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf (x86_64-linux-gnu_egl_conf) in auto mode
update-alternatives: using /usr/lib/nvidia-384/alt_ld.so.conf to provide /etc/ld.so.conf.d/i386-linux-gnu_GL.conf (i386-linux-gnu_gl_conf) in auto mode
update-alternatives: using /usr/lib/nvidia-384/alt_ld.so.conf to provide /etc/ld.so.conf.d/i386-linux-gnu_EGL.conf (i386-linux-gnu_egl_conf) in auto mode
update-alternatives: using /usr/share/nvidia-384/glamor.conf to provide /usr/share/X11/xorg.conf.d/glamoregl.conf (glamor_conf) in auto mode
dpkg: error: version '-' has bad syntax: revision number is empty
update-initramfs: deferring update (trigger activated)
INFO:Enable nvidia-384
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/dell_latitude
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/lenovo_thinkpad
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here
Adding system user `nvidia-persistenced' (UID 121) ...
Adding new group `nvidia-persistenced' (GID 129) ...
Adding new user `nvidia-persistenced' (UID 121) with group `nvidia-persistenced' ...
Not creating home directory `/'.
Loading new nvidia-384-384.111 DKMS files...
Building for 4.13.0-21-generic
Building for architecture x86_64
Building initial module for 4.13.0-21-generic
Done.

nvidia_384:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/4.13.0-21-generic/updates/dkms/

nvidia_384_modeset.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/4.13.0-21-generic/updates/dkms/

nvidia_384_drm.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/4.13.0-21-generic/updates/dkms/

nvidia_384_uvm.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/4.13.0-21-generic/updates/dkms/

depmod....

DKMS: install completed.
Setting up g++ (4:7.2.0-1ubuntu1) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Setting up bbswitch-dkms (0.8-4ubuntu1) ...
Loading new bbswitch-0.8 DKMS files...
Building for 4.13.0-21-generic
Building initial module for 4.13.0-21-generic
Done.

bbswitch:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/4.13.0-21-generic/updates/dkms/

depmod...

DKMS: install completed.
Setting up nvidia-opencl-icd-384 (384.111-0ubuntu0.17.10.1) ...
Setting up nvidia-prime (0.8.5) ...
Setting up libxdamage1:i386 (1:1.1.4-3) ...
Setting up libxext6:i386 (2:1.3.3-1) ...
Setting up libxfixes3:i386 (1:5.0.3-1) ...
Setting up build-essential (12.4ubuntu1) ...
Setting up libcuda1-384 (384.111-0ubuntu0.17.10.1) ...
Setting up libxxf86vm1:i386 (1:1.1.4-1) ...
Setting up bumblebee (3.2.1-16) ...
Adding members from group(s) 'adm sudo admin' to 'bumblebee':
entropy syslog
Adding user entropy to group bumblebee
Adding user syslog to group bumblebee
Selecting 02:00:0 as discrete nvidia card. If this is incorrect,
edit the BusID line in /etc/bumblebee/xorg.conf.nouveau .
Created symlink /etc/systemd/system/graphical.target.wants/bumblebeed.service → /lib/systemd/system/bumblebeed.service.
Setting up libgl1-mesa-glx:i386 (17.2.4-0ubuntu1~17.10.2) ...
Setting up primus-libs:i386 (0~20150328-4) ...
Setting up primus-libs-ia32:i386 (0~20150328-4) ...
Processing triggers for initramfs-tools (0.125ubuntu12) ...
update-initramfs: Generating /boot/initrd.img-4.13.0-21-generic
Setting up bumblebee-nvidia (3.2.1-16) ...
update-alternatives: using /usr/lib/x86_64-linux-gnu/mesa/ld.so.conf to provide /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf (x86_64-linux-gnu_gl_conf) in manual mode
update-alternatives: using /usr/lib/i386-linux-gnu/mesa/ld.so.conf to provide /etc/ld.so.conf.d/i386-linux-gnu_GL.conf (i386-linux-gnu_gl_conf) in manual mode
Selecting 02:00:0 as discrete nvidia card. If this is incorrect,
edit the BusID line in /etc/bumblebee/xorg.conf.nvidia
Setting up primus (0~20150328-4) ...
Processing triggers for libc-bin (2.26-0ubuntu2) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for systemd (234-2ubuntu12.1) ...
$

7. Update the bumblebee configuration

We need to configure bumblebee to point to our new drivers. Edit /etc/bumblebee/bumblebee.conf and make the highlighted changes, such that it looks like this:

# Configuration file for Bumblebee. Values should **not** be put between quotes

## Server options. Any change made in this section will need a server restart
# to take effect.
[bumblebeed]
# The secondary Xorg server DISPLAY number
VirtualDisplay=:8
# Should the unused Xorg server be kept running? Set this to true if waiting
# for X to be ready is too long and don't need power management at all.
KeepUnusedXServer=false
# The name of the Bumbleblee server group name (GID name)
ServerGroup=bumblebee
# Card power state at exit. Set to false if the card shoud be ON when Bumblebee
# server exits.
TurnCardOffAtExit=false
# The default behavior of '-f' option on optirun. If set to "true", '-f' will
# be ignored.
NoEcoModeOverride=false
# The Driver used by Bumblebee server. If this value is not set (or empty),
# auto-detection is performed. The available drivers are nvidia and nouveau
# (See also the driver-specific sections below)
Driver=nvidia
# Directory with a dummy config file to pass as a -configdir to secondary X
XorgConfDir=/etc/bumblebee/xorg.conf.d
# Xorg binary to run
XorgBinary=/usr/lib/xorg/Xorg

## Client options. Will take effect on the next optirun executed.
[optirun]
# Acceleration/ rendering bridge, possible values are auto, virtualgl and
# primus.
Bridge=auto
# The method used for VirtualGL to transport frames between X servers.
# Possible values are proxy, jpeg, rgb, xv and yuv.
VGLTransport=proxy
# List of paths which are searched for the primus libGL.so.1 when using
# the primus bridge
PrimusLibraryPath=/usr/lib/x86_64-linux-gnu/primus:/usr/lib/i386-linux-gnu/primus
# Should the program run under optirun even if Bumblebee server or nvidia card
# is not available?
AllowFallbackToIGC=false


# Driver-specific settings are grouped under [driver-NAME]. The sections are
# parsed if the Driver setting in [bumblebeed] is set to NAME (or if auto-
# detection resolves to NAME).
# PMMethod: method to use for saving power by disabling the nvidia card, valid
# values are: auto - automatically detect which PM method to use
#         bbswitch - new in BB 3, recommended if available
#       switcheroo - vga_switcheroo method, use at your own risk
#             none - disable PM completely
# https://github.com/Bumblebee-Project/Bumblebee/wiki/Comparison-of-PM-methods

## Section with nvidia driver specific options, only parsed if Driver=nvidia
[driver-nvidia]
# Module name to load, defaults to Driver if empty or unset
KernelDriver=nvidia-384
PMMethod=auto
# colon-separated path to the nvidia libraries
LibraryPath=/usr/lib/nvidia-384:/usr/lib32/nvidia-384
# comma-separated path of the directory containing nvidia_drv.so and the
# default Xorg modules path
XorgModulePath=/usr/lib/nvidia-384/xorg,/usr/lib/xorg/modules
XorgConfFile=/etc/bumblebee/xorg.conf.nvidia

## Section with nouveau driver specific options, only parsed if Driver=nouveau
[driver-nouveau]
KernelDriver=nouveau
PMMethod=auto
XorgConfFile=/etc/bumblebee/xorg.conf.nouveau

8. Blacklist the new NVidia drivers, so that they don't get auto-loaded

Using the existing blacklist file installed by bumblebee, we're going to add a few lines to it. Edit /etc/modprobe.d/bumblebee.conf and make the following changes to it:

# This file is installed by bumblebee, do NOT edit!
# to be used by kmod / module-init-tools, and installed in /etc/modprobe.d/
# or equivalent

# do not automatically load nouveau as it may prevent nvidia from loading
blacklist nouveau
# do not automatically load nvidia as it's unloaded anyway when bumblebeed
# starts and may fail bumblebeed to disable the card in a race condition.
# Debian
blacklist nvidia
blacklist nvidia-current
blacklist nvidia-legacy-304xx
blacklist nvidia-legacy-340xx
# Ubuntu
blacklist nvidia
blacklist nvidia-current
blacklist nvidia-current-updates
# 304
blacklist nvidia-304
blacklist nvidia-304-updates
blacklist nvidia-experimental-304
# 310
blacklist nvidia-310
blacklist nvidia-310-updates
blacklist nvidia-experimental-310
# 313
blacklist nvidia-313
blacklist nvidia-313-updates
blacklist nvidia-experimental-313
# 319
blacklist nvidia-319
blacklist nvidia-319-updates
blacklist nvidia-experimental-319
# 325
blacklist nvidia-325
blacklist nvidia-325-updates
blacklist nvidia-experimental-325
# 331
blacklist nvidia-331
blacklist nvidia-331-updates
blacklist nvidia-experimental-331
# 334
blacklist nvidia-334
blacklist nvidia-334-updates
blacklist nvidia-experimental-334
# 337
blacklist nvidia-337
blacklist nvidia-337-updates
blacklist nvidia-experimental-337
# 340
blacklist nvidia-340
blacklist nvidia-340-updates
blacklist nvidia-experimental-340
# 343
blacklist nvidia-343
blacklist nvidia-343-updates
blacklist nvidia-experimental-343
# 346
blacklist nvidia-346
blacklist nvidia-346-updates
blacklist nvidia-experimental-346
# 349
blacklist nvidia-349
blacklist nvidia-349-updates
blacklist nvidia-experimental-349
# 352
blacklist nvidia-352
blacklist nvidia-352-updates
blacklist nvidia-experimental-352
# 355
blacklist nvidia-355
blacklist nvidia-355-updates
blacklist nvidia-experimental-355
# 358
blacklist nvidia-358
blacklist nvidia-358-updates
blacklist nvidia-experimental-358
# 361
blacklist nvidia-361
blacklist nvidia-361-updates
blacklist nvidia-experimental-361
# 364
blacklist nvidia-364
blacklist nvidia-364-updates
blacklist nvidia-experimental-364
# 367
blacklist nvidia-367
blacklist nvidia-367-updates
blacklist nvidia-experimental-367
# 375
blacklist nvidia-375
blacklist nvidia-375-updates
blacklist nvidia-experimental-375
# 378
blacklist nvidia-378
blacklist nvidia-378-updates
blacklist nvidia-experimental-378
# 381
blacklist nvidia-381
blacklist nvidia-381-updates
blacklist nvidia-experimental-381
# 384
blacklist nvidia-384
blacklist nvidia-384-drm
blacklist nvidia-384-modeset
blacklist nvidia-384-uvm

blacklist nvidia-384-updates
blacklist nvidia-experimental-384

Update the ram-disk so that the excluded modules don't get put into it:

sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-4.13.0-21-generic
$

Warning: The above is very important. Failing to update the ram-disk will result in an installation that doesn't enter Xorg correctly. If you've accidentally missed this step, you can enter single-mode from GRUB and recover that way.

9. Revert GL ld.so configurations to point to MESA ones

We need to use mesa by default, with bumblebee switching to NVidia at runtime if we tell it to. The nvidia-384 installer actually changes these to point to nvidia, so we need to revert this (some options may already be on the correct setting):

$ sudo update-alternatives --config i386-linux-gnu_gl_conf
There are 3 choices for the alternative i386-linux-gnu_gl_conf (providing /etc/ld.so.conf.d/i386-linux-gnu_GL.conf).

  Selection    Path                                      Priority   Status
------------------------------------------------------------
  0            /usr/lib/nvidia-384/alt_ld.so.conf         8604      auto mode
* 1            /usr/lib/i386-linux-gnu/mesa/ld.so.conf    500       manual mode
  2            /usr/lib/nvidia-384-prime/alt_ld.so.conf   8603      manual mode
  3            /usr/lib/nvidia-384/alt_ld.so.conf         8604      manual mode

Press <enter> to keep the current choice[*], or type selection number: 1
$ sudo update-alternatives --config x86_64-linux-gnu_egl_conf
There are 3 choices for the alternative x86_64-linux-gnu_egl_conf (providing /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf).

  Selection    Path                                           Priority   Status
------------------------------------------------------------
* 0            /usr/lib/nvidia-384/ld.so.conf                  8604      auto mode
  1            /usr/lib/nvidia-384-prime/ld.so.conf            8603      manual mode
  2            /usr/lib/nvidia-384/ld.so.conf                  8604      manual mode
  3            /usr/lib/x86_64-linux-gnu/mesa-egl/ld.so.conf   500       manual mode

Press <enter> to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/lib/x86_64-linux-gnu/mesa-egl/ld.so.conf to provide /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf (x86_64-linux-gnu_egl_conf) in manual mode
$ sudo update-alternatives --config x86_64-linux-gnu_gl_conf
There are 3 choices for the alternative x86_64-linux-gnu_gl_conf (providing /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf).

  Selection    Path                                       Priority   Status
------------------------------------------------------------
  0            /usr/lib/nvidia-384/ld.so.conf              8604      auto mode
  1            /usr/lib/nvidia-384-prime/ld.so.conf        8603      manual mode
  2            /usr/lib/nvidia-384/ld.so.conf              8604      manual mode
* 3            /usr/lib/x86_64-linux-gnu/mesa/ld.so.conf   500       manual mode

Press <enter> to keep the current choice[*], or type selection number: 3
$

Make our new selections active:

$ sudo ldconfig
$

10. Reboot

Yes, again.

$ sudo reboot

11. Test 

Right, onto the testing. First of all, out integrated Intel card should still be the default vendor:

$ glxinfo | grep 'OpenGL vendor'
OpenGL vendor string: Intel Open Source Technology Center
$

Test rendering on the integrated Intel card:

$ glxgears
Running synchronized to the vertical refresh.  The framerate should be
approximately the same as the monitor refresh rate.
303 frames in 5.0 seconds = 60.478 FPS
301 frames in 5.0 seconds = 60.050 FPS
XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0"
      after 2661 requests (2661 known processed) with 0 events remaining.
$


All good!

Let's now do the same, but with the discrete NVidia card. Check the vendor for GL:

$ primusrun glxinfo | grep 'OpenGL vendor'
/usr/bin/primusrun: line 41: warning: command substitution: ignored null byte in input
OpenGL vendor string: NVIDIA Corporation
$

Cool, and let's try rendering on the NVidia card:

$ primusrun glxgears
/usr/bin/primusrun: line 41: warning: command substitution: ignored null byte in input
290 frames in 5.0 seconds = 57.944 FPS
300 frames in 5.0 seconds = 59.903 FPS
X Error of failed request:  BadDrawable (invalid Pixmap or Window parameter)
  Major opcode of failed request:  153 (DRI2)
  Minor opcode of failed request:  7 (DRI2GetBuffersWithFormat    )
  Resource id in failed request:  0x3c00002,
  Serial number of failed request:  2330
  Current serial number in output stream:  2330
primus: warning: dropping a frame to avoid deadlock
primus: warning: timeout waiting for display worker
XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0"
      after 31 requests (31 known processed) with 0 events remaining.
$


Note: Don't worry about the errors in there. They do not affect the application and are some sort of a bug. I do not claim to understand the nature of this.

Everything works! Hopefully it does for you as well. Enjoy.

Monday, 22 January 2018

T440p, Haswell CPUs, bad battery life and CPU frequency-scaling

You have yourself a Haswell CPU (mine is a 4710MQ, but 4600, 4700, 4800 {MQ,HQ} et. al. will probably also apply), and you're running the latest LTS release (16.04) of Ubuntu (I'm actually running Xubuntu), and what you've found is that your batter life is terrible. I should be getting around 4h30m on this (6-cell) battery, but I get more like 1h50m. The reason? CPU frequency scaling.

The problem is that the kernel shipped with *some* 16.04 installations (depends on whether you've installed the refreshed 16.04.[123] LTS or not) have a bug in them that completely ruins the power saving of your laptop.

This is a plot of 70 seconds worth of data from scaling_cur_freq while my laptop is completely idle on the desktop (not a single core goes above 0.3% during this time):

X-axis: second, Y-axis: clock in khz

You can see all the makings of a screwy frequency-scaling algorithm. This is actually a well-known bug, but let's just cut to the chase. The problem is with the intel_pstate frequency-scaling driver. In some kernel versions that were shipped with 16.04 LTS, the intel_pstate actually pushes the CPU into turbo clocks from the most minor of activity.

The solution? Disable intel_pstate. Add intel_pstate=disable to /etc/default/grub.conf such that it looks something like this:

$ cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="intel_pstate=disable"

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
$

Then update grub:

$ sudo update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.0-109-generic
Found initrd image: /boot/initrd.img-4.4.0-109-generic
Found linux image: /boot/vmlinuz-4.4.0-101-generic
Found initrd image: /boot/initrd.img-4.4.0-101-generic
Found linux image: /boot/vmlinuz-4.4.0-87-generic
Found initrd image: /boot/initrd.img-4.4.0-87-generic
Found linux image: /boot/vmlinuz-4.4.0-36-generic
Found initrd image: /boot/initrd.img-4.4.0-36-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done
$


Now reboot.


Your scaling driver will now be the acpi-cpufreq one. This one does a much better job of scaling the CPU frequencies than the buggy intel_pstate. You should get significant battery savings out of this change just by itself. If you're happy with what you have now, then feel free to quit reading now.

Who wants a slightly more tuned solution? Read on.

By default Ubuntu puts us into the ondemand governor:

$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
ondemand
ondemand
ondemand
ondemand
ondemand
ondemand
ondemand
ondemand
$

Disable it:

$ sudo systemctl disable ondemand
ondemand.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install disable ondemand
insserv: warning: current start runlevel(s) (empty) of script `ondemand' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (2 3 4 5) of script `ondemand' overrides LSB defaults (empty).
$


Let's discover what ACPI events are generated when you unplug and re-plug your AC power supply:

$ acpi_listen
ac_adapter ACPI0003:00 00000080 00000000
ac_adapter ACPI0003:00 00000080 00000001
^C
$

So we see that we have the AC events. We're not actually going to use them for anything other than a trigger.

Create /etc/acpi/cpufreq-governor.sh and put this inside it:

/bin/sh
# Update cpufreq scaling-governor based on AC state.

( if [ $(cat /sys/class/power_supply/AC/online) -eq 1 ]; then
echo performance;
else
echo powersave;
fi ) | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

Make sure to add execute permissions to it (chmod a+x).

Create an ACPI event /etc/acpi/events/ac-adapter and put this inside it:

# /etc/acpi/events/ac-adapter
#
# Switch CPU frequency-scaling governor depending on AC state.

event=ac_adapter ACPI0003:00 00000080 0000000[01]
action=/etc/acpi/cpufreq-governor.sh


This will run the scaling-governor-selection script any time there is a change in the state of the AC power supply. But what about boot? The AC state won't change at boot and we need to have the right governor selected then, too! So we'll create a service for that.

Create a SystemD service /etc/systemd/system/cpufreq-governor.service and put this inside it:

[Unit]
Description=Set the CPU Frequency Scaling governor to powersave/performance, depending on AC state.

[Service]
Type=oneshot
ExecStart=/etc/acpi/cpufreq-governor.sh

[Install]
WantedBy=multi-user.target

Enable it:

$ sudo systemctl daemon-reload
$ sudo systemctl enable cpufreq-governor
Created symlink from /etc/systemd/system/multi-user.target.wants/cpufreq-governor.service to /etc/systemd/system/cpufreq-governor.service.
$


Reboot.

Now your PC will use the right scaling governor when you boot and whenever the AC power supply state changes.

Thursday, 18 January 2018

Nouveau and constant power-state cycling/loop in (X)Ubuntu 16.04/XFCE with Optimus

You've got yourself an Optimus machine, you've installed nouveau, and one thing that caught your eye is this:

entropy@symplex:~$ sudo cat /sys/kernel/debug/vgaswitcheroo/switch
0:DIS: :DynPwr:0000:02:00.0
1:IGD:+:Pwr:0000:00:02.0
entropy@symplex:~$ sudo cat /sys/kernel/debug/vgaswitcheroo/switch
0:DIS: :DynPwr:0000:02:00.0
1:IGD:+:Pwr:0000:00:02.0
entropy@symplex:~$ sudo cat /sys/kernel/debug/vgaswitcheroo/switch
0:DIS: :DynPwr:0000:02:00.0
1:IGD:+:Pwr:0000:00:02.0
entropy@symplex:~$ sudo cat /sys/kernel/debug/vgaswitcheroo/switch
0:DIS: :DynOff:0000:02:00.0
1:IGD:+:Pwr:0000:00:02.0
entropy@symplex:~$ sudo cat /sys/kernel/debug/vgaswitcheroo/switch
0:DIS: :DynOff:0000:02:00.0
1:IGD:+:Pwr:0000:00:02.0
entropy@symplex:~$ sudo cat /sys/kernel/debug/vgaswitcheroo/switch
0:DIS: :DynOff:0000:02:00.0
1:IGD:+:Pwr:0000:00:02.0
entropy@symplex:~$ sudo cat /sys/kernel/debug/vgaswitcheroo/switch
0:DIS: :DynPwr:0000:02:00.0
1:IGD:+:Pwr:0000:00:02.0
entropy@symplex:~$ sudo cat /sys/kernel/debug/vgaswitcheroo/switch
0:DIS: :DynPwr:0000:02:00.0
1:IGD:+:Pwr:0000:00:02.0
entropy@symplex:~$


Your card is cycling between the Dynamic power-on (DynPwr) and Dynamic power-off (DynOff) state. It's wasting your battery and you want it to stay off when it's not being used.

You'll also notice that dmesg shows you this:

[ 1096.319606] nouveau 0000:02:00.0: DRM: resuming kernel object tree...
[ 1096.362341] nouveau 0000:02:00.0: priv: HUB0: 10ecc0 ffffffff (1f70822c)
[ 1096.362355] nouveau 0000:02:00.0: priv: GPC0: 4188ac 00000001 (1a70822e)
[ 1096.434465] nouveau 0000:02:00.0: DRM: resuming client object trees...
[ 1101.536496] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150930/nsarguments-95)
[ 1101.537262] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150930/nsarguments-95)
[ 1101.537955] nouveau 0000:02:00.0: DRM: evicting buffers...
[ 1101.537962] nouveau 0000:02:00.0: DRM: waiting for kernel channels to go idle...
[ 1101.537988] nouveau 0000:02:00.0: DRM: suspending client object trees...
[ 1101.539366] nouveau 0000:02:00.0: DRM: suspending kernel object tree...
[ 1106.758460] nouveau 0000:02:00.0: DRM: resuming kernel object tree...
[ 1106.801176] nouveau 0000:02:00.0: priv: HUB0: 10ecc0 ffffffff (1b70822c)
[ 1106.801187] nouveau 0000:02:00.0: priv: GPC0: 4188ac 00000001 (1c70822e)
[ 1106.860253] nouveau 0000:02:00.0: DRM: resuming client object trees...
[ 1112.528066] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150930/nsarguments-95)
[ 1112.528321] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150930/nsarguments-95)
[ 1112.528545] nouveau 0000:02:00.0: DRM: evicting buffers...
[ 1112.528548] nouveau 0000:02:00.0: DRM: waiting for kernel channels to go idle...
[ 1112.528566] nouveau 0000:02:00.0: DRM: suspending client object trees...
[ 1112.529810] nouveau 0000:02:00.0: DRM: suspending kernel object tree...
[ 1117.593058] nouveau 0000:02:00.0: DRM: resuming kernel object tree...
[ 1117.635657] nouveau 0000:02:00.0: priv: HUB0: 10ecc0 ffffffff (1870822c)
[ 1117.635664] nouveau 0000:02:00.0: priv: GPC0: 4188ac 00000001 (1e70822e)
[ 1117.680262] nouveau 0000:02:00.0: DRM: resuming client object trees...

Over and over again. Suspending, resuming, suspending, resuming ...

Well, it turns out that it's a Window Manager tweak in XFCE(xfwm4) . This is what you're looking for:


Untick/unselect/disable the "Synchronise drawing to the vertical blank" and you will find that the problem disappears. The card will now stay in DynOff mode while it's not being used.

Tuesday, 16 January 2018

No ALSA devices in Bitwig Studio 1.3.6 on Ubuntu

This is entirely the fault of the Bitwig developers, and after all of this time they have still not fixed the fault. I cannot take credit for this, please see the original thread where this was found.

Here is how the problem manifests itself: You'll go into Options > Preferences > Audio, select ALSA, and find that there are no compatible ALSA devices in the devices list.


The problem is that the Bitwig .deb package does not list libxcb-icccm4 as a dependency; presumably they assumed you'd have it installed. Simply install it:

$ sudo apt-get install libxcb-icccm4

ALSA devices should now be visible in the device selector. Now! If you get a message about the audio device being busy or that it could not be opened for some reason, remember that there is a high chance you're using a sound daemon of some sort. I'm going to assume you're using PulseAudio, because this is a post specific to Ubuntu, but if you're on some other distribution that uses a different sound daemon, then just look up what the equivalent for that daemon is.

To fix this, you need to run Bitwig studio like this:

$ pasuspender -- bitwig-studio

This suspends the PulseAudio sound daemon while Bitwig runs, so that Bitwig can have exclusive access to the underlying sound-card without going through PulseAudio, and then un-suspends it when you exit Bitwig.

Thursday, 13 April 2017

Steam Streaming on Linux and Tearing/VSync Issues

So I gave in. It's true. I have given up on the idea that Lenovo will, in any foreseeable future, make a T4N0p laptop that has an awesome graphics card. I have since put some money in to building a small Mini-ITX rig that has a GTX 1070 inside it and planned on using steam streaming.

Now! I was really hyped up to play Fallout 4 by Steam-In-Home-Streaming it from my ITX rig. I did the download and I streamed it and... tearing. I tried VSync on the host-side, I tried hardware/software encoding on both sides ... nothing. Still tearing while streaming Fallout 4.

Here's where the eureka moment was, for me. I was actually browsing some Steam forums, trying to see if people have experienced the same issues, but I happened to notice that, while scrolling down the page, there was ever-so-slight, visible tearing in my Chrome session that I never noticed before.

I connected a monitor to the ITX rig directly and it confirmed my belief. There is no tearing on the server-side of the streaming, it must be my T440p.

XFCE's compositor has the following option in the "Window Manager Tweaks" settings:


This option does ABSOLUTELY NOTHING. It's either broken or has never worked. It doesn't VSync at all. After ticking the "Synchronise drawing to the vertical blank", tearing was still visible in Steam-streaming and in my Chrome session.

I later found this in by Xorg.0.log file:

[     3.612] (--) intel(0): Output DP2-2 using initial mode 1920x1200 on pipe 1
[     3.612] (==) intel(0): TearFree disabled
[     3.612] (==) intel(0): DPI set to (96, 96)

Now, TearFree is Intel's code-word for VSync. We need to enable this to fix the tearing.

There's a lot of discussion in the community about VSync and whether or not it's a good thing. It limits your framerates, so for those who want a GPU to pump out 300FPS on a monitor that only refreshes at 60Hz, you won't want to enable TearFree. For the rest of us who are interested not so much in raw frame counts but more in picture quality and not having tearing when playing games, you'll want to enable it.

Here's how you do it. If you don't already have an xorg.conf.d directory, you'll want to create it:

$ mkdir /etc/X11/xorg.conf.d

After that, use your favourite editor to edit /etc/X11/xorg.conf.d/20-intel.conf and put the following inside it:

$ cat /etc/X11/xorg.conf.d/20-intel.conf 
Section "Device"
   Identifier  "Intel Graphics"
   Driver      "intel"
   Option      "AccelMethod" "sna"
   Option      "TearFree" "true"
EndSection

After this, you reboot. Checking your /var/log/Xorg.0.log again, you should see this:

[     3.459] (**) intel(0): Option "AccelMethod" "sna"
[     3.459] (**) intel(0): Option "TearFree" "true"
[     3.461] (II) intel(0): Output eDP1 has no monitor section

Now your Steam-streaming games should be tear-free. Enjoy.

Monday, 27 February 2017

Preferentially using an external USB Audio Interface as a primary/default pulseaudio sink when available.

On my Lenovo laptop, there is an internal Intel HDA sound card, but a far superior TASCAM audio interface is plugged into my dock, which is in turn wired up to my speakers. When docked, I want the laptop to use the TASCAM sound card, but when roaming, I want it to switch to the internal.


entropy@symplex:~$ pactl list short cards
0 alsa_card.pci-0000_00_03.0 module-alsa-card.c
1 alsa_card.usb-TEAC_Corporation_US-2x2-00 module-alsa-card.c
2 alsa_card.pci-0000_00_1b.0 module-alsa-card.c
entropy@symplex:~$

I'm talking about the TEAC one, of course; TASCAM is a TEAC offshoot. The third one you see is just HDMI, and we'll ignore it for now.

In your modules list, you should see a module called module-default-device-restore. This is the module that will do the magic, but it doesn't do what we want out of the box. The module is meant to save your configured default-sink and restore it on boot. What happens is that when you boot with the laptop undocked, the module sees that the default-saved-sink is not available, and goes back to the internal one (what we want), but when you shut down, it saves the current default-sink as the new default-saved-sink, which means that the next time you boot-up docked, the internal card will still be the active default sink.


entropy@symplex:~$ pactl list short modules 0 module-device-restore
1 module-stream-restore
2 module-card-restore
3 module-augment-properties
4 module-switch-on-port-available
5 module-udev-detect
6 module-alsa-card device_id="0" name="pci-0000_00_03.0" card_name="alsa_card.pci-0000_00_03.0" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes card_properties="module-udev-detect.discovered=1"
7 module-alsa-card device_id="2" name="usb-TEAC_Corporation_US-2x2-00" card_name="alsa_card.usb-TEAC_Corporation_US-2x2-00" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes card_properties="module-udev-detect.discovered=1"
9 module-alsa-card device_id="1" name="pci-0000_00_1b.0" card_name="alsa_card.pci-0000_00_1b.0" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes card_properties="module-udev-detect.discovered=1"
10 module-bluetooth-policy
11 module-bluetooth-discover
12 module-bluez5-discover
13 module-native-protocol-unix
14 module-default-device-restore
15 module-rescue-streams
16 module-always-sink
17 module-intended-roles
18 module-suspend-on-idle
19 module-systemd-login
20 module-position-event-sounds
21 module-filter-heuristics
22 module-filter-apply
23 module-x11-publish display=:0.0
24 module-x11-bell display=:0.0 sample=bell.ogg
25 module-x11-cork-request display=:0.0
26 module-x11-xsmp display=:0.0 session_manager=local/symplex:@/tmp/.ICE-unix/1407,unix/symplex:/tmp/.ICE-unix/1407
entropy@symplex:~$

The way to do this is to simply remove write permissions from the file to which the module saves the default-sink to. This is in the pulse configuration directory. If you have many of the *-default-sink files, then check their timestamps and perform the procedure on the latest one. The hash is a machine ID that pulse uses to associate configurations to machines. The one with the latest timestamp is most likely your current machine ID hash.

entropy@symplex:~$ ls ~/.config/pulse/
cookie
ffdf15cb76974ed4aaa951b2d3564f7b-card-database.tdb
ffdf15cb76974ed4aaa951b2d3564f7b-default-sink
ffdf15cb76974ed4aaa951b2d3564f7b-default-source
ffdf15cb76974ed4aaa951b2d3564f7b-device-volumes.tdb
ffdf15cb76974ed4aaa951b2d3564f7b-stream-volumes.tdb
entropy@symplex:~$ cat ~/.config/pulse/ffdf15cb76974ed4aaa951b2d3564f7b-default-sink
alsa_output.usb-TEAC_Corporation_US-2x2-00.analog-stereo
entropy@symplex:~$ 

First make sure that the you are docked and the external card is the currently-saved card as the default-sink (as in the above example), then remove the permissions.


entropy@symplex:~$ chmod a-w ~/.config/pulse/ffdf15cb76974ed4aaa951b2d3564f7b-default-sink
entropy@symplex:~$ 

Done.

Pulse will always try to restore the external card as the default-sink, and failing that revert to the internal card.