Switching between Intel and NVIDIA graphics processors on a laptop with NVIDIA Optimus hardware running Gentoo Linux

I have a Clevo W230SS laptop with an Intel HD 4600 IGP and an NVIDIA GeForce GTX 860M GPU, running KDE in Gentoo Linux. I could have installed Bumblebee in order to use the NVIDIA GPU with selected applications, but I decided instead to switch manually between the graphics processors. To achieve this I created two Desktop Configuration Files with nice icons on my Desktop, to launch two simple Bash scripts which configure my installation for the desired graphics processor, which will then be used when I next login to KDE. All the necessary files are listed below for Gentoo Linux. You would need to modify them if you are using a different distribution.

The Bash script ~/intel.sh contains the following:

echo "Your installation is currently configured to use the following graphics processor:"
GPU=`eselect opengl list | grep \* | awk '{ print $2 }'`
if [ "$GPU" = "xorg-x11" ]; then
  echo "Intel HD 4600 Integrated Graphics Processor"
  echo "You do not need to do anything. Please close this window."
elif [ "$GPU" = "nvidia" ]; then
  echo "NVIDIA GeForce GTX 860M"
  echo "This script will configure your installation to use the"
  echo "Intel HD 4600 Integrated Graphics Controller all the time."
  echo "Enter your own password."
  sudo eselect opengl set xorg-x11
  sudo cp /home/fitzcarraldo/Xsetup.intel /usr/share/config/kdm/Xsetup
  sudo cp /home/fitzcarraldo/xorg.conf.intel /etc/X11/xorg.conf
  echo "Now you should logout to restart X Windows."

The Bash script ~/nvidia.sh contains the following:

echo "Your installation is currently configured to use the following graphics processor:"
GPU=`eselect opengl list | grep \* | awk '{ print $2 }'`
if [ "$GPU" = "nvidia" ]; then
  echo "NVIDIA GeForce GTX 860M"
  echo "You do not need to do anything. Please close this window."
elif [ "$GPU" = "xorg-x11" ]; then
  echo "Intel HD 4600 Integrated Graphics Processor"
  echo "This script will configure your installation to use the NVIDIA GeForce GTX 860M GPU all the time."
  echo "Enter your own password."
  sudo eselect opengl set nvidia
  sudo cp /home/fitzcarraldo/Xsetup.nvidia /usr/share/config/kdm/Xsetup
  sudo cp /home/fitzcarraldo/xorg.conf.nvidia /etc/X11/xorg.conf
  echo "Now you should logout to restart X Windows."

I created two files, xorg.conf.intel and xorg.conf.nvidia, in my home directory. The corresponding Bash script copies the applicable file to the directory /etc/X11/ to create an xorg.conf file with the correct contents for the graphics processor.

The file ~/xorg.conf.intel contains the following:

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

The file ~/xorg.conf.nvidia contains the following:

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "nvidia" 0 0
    Inactive       "intel"

Section "Monitor"
    Identifier     "Monitor0"
    Option         "DPMS"

Section "Device"
    Identifier     "nvidia"
    Driver         "nvidia"
    BusID          "PCI:1:0:0"

Section "Device"
    Identifier     "intel"
    Driver         "modesetting"
    BusID          "PCI:0:2:0"

Section "Screen"
    Identifier     "nvidia"
    Device         "nvidia"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "UseDisplayDevice" "none"
    SubSection     "Display"
        Depth       24
#        Modes      "nvidia-auto-select"
        Virtual     1920 1080

Section "Screen"
    Identifier     "intel"
    Device         "intel"
    Monitor        "Monitor0"

I created two files, Xsetup.intel and Xsetup.nvidia, in my home directory. The corresponding Bash script copies the applicable file to the directory /usr/share/config/kdm/ to create an Xsetup file with the correct contents for the graphics processor.

The file ~/Xsetup.intel is listed below. As you can see, everything is commented out in the file.

#! /bin/sh
# Xsetup - run as root before the login dialog appears

#xconsole -geometry 480x130-0-0 -notify -verbose -fn fixed -exitOnFail -file /dev/xconsole &

The file Xsetup.nvidia is listed below. As you can see, it contains two xrandr commands.

#! /bin/sh
# Xsetup - run as root before the login dialog appears

#xconsole -geometry 480x130-0-0 -notify -verbose -fn fixed -exitOnFail -file /dev/xconsole &
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto

I downloaded nice icons from the Web for the Desktop Configuration Files and put them in the directory ~/Pictures/Icons/.

The file ~/Desktop/Select\ Intel\ HD\ Graphics.desktop is listed below.

[Desktop Entry]
Comment[en_GB]=Run a script to configure your installation to use Intel Integrated Graphics when you restart X Windows
Comment=Run a script to configure your installation to use Intel Integrated Graphics when you restart X Windows
GenericName[en_GB]=Configure your installation to use Intel HD Graphics
GenericName=Configure your installation to use Intel HD Graphics
Name[en_GB]=Intel HD Graphics
Name=Intel HD Graphics

The file ~/Desktop/Select\ NVIDIA\ GPU.desktop is listed below.

[Desktop Entry]
Comment[en_GB]=Run a script to configure your installation to use the NVIDIA GeForce GTX 860M GPU when you restart X Windows
Comment=Run a script to configure your installation to use the NVIDIA GeForce GTX 860M GPU when you restart X Windows
GenericName[en_GB]=Configure your installation to use the NVIDIA GeForce GTX 860M GPU
GenericName=Configure your installation to use the NVIDIA GeForce GTX 860M GPU

All I have to do is double-click on either icon and a Konsole window pops up and tells me what to do. Next time I log in, the graphics processor I selected will be active.

My thanks go to Gentoo Linux user arthanis for showing me the way in the Gentoo Forums thread [SOLVED] Optimus and Nvidia.

Change the mp3 bitrate for ripping in K3b

I’ve been using K3b successfully (it’s currently at version 2.0.3-r1 in Gentoo Linux) to rip Audio CDs to mp3 files, but despite changing the bitrate to 192 kbps in the ‘K3b Lame Mp3 Encoder’ plugin settings, K3b was still ripping mp3 files at 128 kbps. I found out that I needed to make another change too.

The default bitrate for ripped mp3 tracks is 128 kbps in K3b. To use a different bitrate, I needed to do the following:

1. ‘Settings’ > ‘Configure K3b…’

2. Click on ‘Plugins’

3. Click on the spanner next to ‘K3b Lame Mp3 Encoder’, and change the bitrate on the Settings tab to 192 (or whatever you want). However, this alone does not have any effect, so also click on the spanner next to ‘K3b External Audio Encoder’, click on ‘Mp3 (Lame)’ in the list of ‘Configured Encoders’, click on ‘Edit’ and insert ‘-b 192‘ (or whatever bitrate you want) in the list of lame options, like so:

lame -r --bitwidth 16 --little-endian -b 192 -s 44.1 -h --tt %t --ta %a --tl %m --ty %y --tc %c --tn %n - %f

Here’s what happens before I added the ‘-b 192‘ to the settings for ‘Mp3 (Lame)’ in ‘K3b External Audio Encoder':

$ file 01\ -\ Meu\ Bem\ Querer.mp3
01 - Meu Bem Querer.mp3: Audio file with ID3 version 2.3.0, contains: MPEG ADTS, layer III, v1, 128 kbps, 44.1 kHz, JntStereo

And after adding the ‘-b 192‘ to the settings for ‘Mp3 (Lame)’ in ‘K3b External Audio Encoder':

$ file 01\ -\ Meu\ Bem\ Querer.mp3
01 - Meu Bem Querer.mp3: Audio file with ID3 version 2.3.0, contains: MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, JntStereo

Notice the bit rate of the file has changed.

Office 2007 mime-type problem in KDE

Although Microsoft Office 2007 file types are normally opened by the correct Office 2007 application (running with WINE) in my Gentoo Linux Stable amd64 installation, KDE 4.14.3 on my new Clevo notebook opened *.xlsm (Excel 2007 macro-enabled spreadsheet) files with Ark instead of Excel 2007. For some reason the *.xlsm filetype was registed in the xdg-mime database to use the Ark application:

$ file myspreadsheet.xlsm
myspreadsheet.xlsm: Microsoft Excel 2007+

$ xdg-mime query filetype myspreadsheet.xlsm

On the other hand, as you can see below, *.docx documents are correctly registed in the xdg-mime database:

$ file myworddocument.docx
myworddocument.docx: Microsoft Word 2007+

$ xdg-mime query filetype myworddocument.docx

The Office 2007 mime types are listed on the Web page Office 2007 File Format MIME Types for HTTP Content Streaming. Notice the uppercase ‘E’ in the mime-type application/vnd.ms-excel.sheet.macroEnabled.12 for *.xlsm files.

I had already used ‘System Settings’ > ‘File Associations’ in KDE to configure the file association for *.xlsm files, but this made no difference.

I searched my installation and found the file /usr/share/mime/application/vnd.openxmlformats-officedocument.wordprocessingml.document.xml (for *.docx) and the file vnd.ms-excel.sheet.binary.macroenabled.12.xml (for *.xlsb), but the file vnd.ms-excel.sheet.macroenabled.12.xml (for *.xlsm) did not exist.

Then I found the freedesktop.org bug report ‘subclasses declared have wrong case‘ about the package shared-mime-info. One of the commenters stated the problem is in fact due to a bug in KDE.

I followed the work-around given in the bug report:

# mv /usr/share/mime/subclasses /usr/share/mime/subclasses.BAK
# sed -e 's/macroEnabled/macroenabled/' /usr/share/mime/subclasses.BAK > /usr/share/mime/subclasses

I then used KDE ‘System Settings’ > ‘File associations’ again, searched for .xlsm and removed Ark from the list of applications for application/vnd.ms-excel.sheet.macroenabled.12, then logged-out and back in to KDE. Double-clicking on *.xlsm files now opens them in Excel 2007 again, the file /usr/share/mime/application/vnd.ms-excel.sheet.macroenabled.12.xml now exists and the mime-type has been set correctly:

$ xdg-mime query filetype myspreadsheet.xlsm

(I don’t have this problem opening *.xlsm files on my Compal laptop, which also has Version 1.4 of shared-mime-info installed and is also running KDE 4.14.3, albeit under Gentoo Testing ~amd64 rather than Gentoo Stable amd64, so perhaps the KDE bug has already been fixed in the Testing branch.)

Installing PeaZip in Gentoo Linux

I like the archive file utility PeaZip. A couple of years ago I used an ebuild app-arch/peazip-bin in a local overlay to install the pre-compiled utility in Gentoo Linux. Today I wanted to install PeaZip on my new laptop but neither the ebuild for the binary package nor the ebuild for the source package in third-party overlays was able to install it, not to mention that I could not find an ebuild of either type for the latest version. PeaZip Portable, however, does not require installation, so it’s not difficult to get the latest version of PeaZip running correctly in Gentoo Linux without needing an ebuild. Here’s how I installed the latest version of 64-bit PeaZip Portable in KDE …

1. Download peazip_portable-5.6.0.LINUX.x86_64.GTK2.tar.gz from the PeaZip Portable x86-64 download page and extract it to the directory /home/fitzcarraldo/peazip_portable-5.6.0.LINUX.x86_64.GTK2/ (change ‘fitzcarraldo’ to your own user name, of course).

2. Open a Konsole window and enter the following commands:

# ln -s /home/fitzcarraldo/peazip_portable-5.6.0.LINUX.x86_64.GTK2/peazip /usr/local/bin/peazip
# cp /home/fitzcarraldo/peazip_portable-5.6.0.LINUX.x86_64.GTK2/FreeDesktop_integration/peazip.desktop /usr/share/applications/kde4/
# cp /home/fitzcarraldo/peazip_portable-5.6.0.LINUX.x86_64.GTK2/FreeDesktop_integration/kde4-dolphin/usr/share/kde4/services/ServiceMenus/*.desktop /usr/share/kde4/services/ServiceMenus/

The command given below is an alternative to the last command above, and the menu items would then only appear in the right-click menu of my user account and I would be able to edit them using the KDE 4 Service Menu Editor.

$ cp /home/fitzcarraldo/peazip_portable-5.6.0.LINUX.x86_64.GTK2/FreeDesktop_integration/kde4-dolphin/usr/share/kde4/services/ServiceMenus/*.desktop /home/fitzcarraldo/.kde4/share/kde4/services/ServiceMenus/

3. Download a nice Peazip PNG icon that you find using Google Images (e.g. the 256×256 PNG icon at http://market.milouz.com/data/icon190.png).

4. Copy the icon to the PeaZip Portable directory:

$ cp /home/fitzcarraldo/Downloads/peazip.png /home/fitzcarraldo/peazip_portable-5.6.0.LINUX.x86_64.GTK2/

5. Use the KDE Menu Editor to specify the icon for the PeaZip menu entry.

6. Finally, use e.g. Gwenview to create a PNG copy of the icon resized to 16×16, and copy it to the icon folder used by the KDE Service Menu:

# cp /home/fitzcarraldo/peazip_portable-5.6.0.LINUX.x86_64.GTK2/peazip16x16.png /usr/share/icons/hicolor/16x16/apps/peazip.png

That’s it!

Realtek 5287 PCIe controller for memory card reader

Well, I finally got the memory card reader in my new Clevo W230SS laptop working, but, as is often the case with Linux, I’m not sure precisely which kernel configuration parameter or parameters are responsible.

By googling the device number given in the output from the lspci command, I deduced that the memory card controller is the following PCIe device:

04:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. Device 5287 (rev 01)

The vendor ID for Realtek is 10ec and the device ID is 5287. By the way, PCIDatabase.com is a good resource if you need to research PCI devices.

I then rebuilt the kernel several times, changing various configuration parameters each time. One or more of them finally did the trick, but probably several are irrelevant. Anyway, below I summarise the current configuration.

$ uname -a
Linux clevow230ss 3.18.11-gentoo #20 SMP Tue Apr 28 05:48:42 BST 2015 x86_64 Intel(R) Core(TM) i7-4810MQ CPU @ 2.80GHz GenuineIntel GNU/Linux

$ cat /usr/src/linux/.config | grep -i mmc
# Supported MMC/SDIO adapters
# CONFIG_MMC_DEBUG is not set
# MMC/SD/SDIO Card Drivers
# CONFIG_MMC_TEST is not set
# MMC/SD/SDIO Host Controller Drivers

As can be seen more clearly via menuconfig (see below), several of the Host Controller Drivers listed above are irrelevant because they are for other manufacturers’ controllers, not Realtek, but I have left them configured for the time being and will tidy up the configuration later.

--- MMC/SD/SDIO card support
[ ]   MMC debugging
[ ]   MMC host clock gating
*** MMC/SD/SDIO Card Drivers ***
<M>   MMC block device driver
(8)     Number of minors per block device
[*]     Use bounce buffer for simple hosts
< >   SDIO UART/GPS class support
< >   MMC host test driver
*** MMC/SD/SDIO Host Controller Drivers ***
<M>   Secure Digital Host Controller Interface support
<M>   SDHCI support on PCI bus
[*]     Ricoh MMC Controller Disabler
<M>   SDHCI support for ACPI enumerated SDHCI controllers
<M>   SDHCI platform and OF driver helper
<M>   Winbond W83L51xD SD/MMC Card Interface support
<M>   TI Flash Media MMC/SD Interface support
<M>   ENE CB710 MMC/SD Interface support
<M>   VIA SD/MMC Card Reader Driver
<M>   VUB300 USB to SDIO/SD/MMC Host Controller support
<M>   USB SD Host Controller (USHC) support
<M>   Renesas USDHI6ROL0 SD/SDIO Host Controller support
<M>   Realtek PCI-E SD/MMC Card Interface Driver

The card reader does not support the Sony Memory Stick format, so the configuration parameters mentioning ‘MEMSTICK‘ that I selected may be irrelevant:

$ cat /usr/src/linux/.config | grep -i memstick
# CONFIG_MEMSTICK_R592 is not set

I’m almost certain that CONFIG_MMC_REALTEK_PCI needs to be selected, though:

$ cat /usr/src/linux/.config | grep -i realtek

I enabled some of the configuration parameters that mention ‘HOTPLUG‘ because I came across an article regarding the Realtek RTS5209 PCIe card reader that enabled them:

$ cat /usr/src/linux/.config | grep -i hotplug

I have no idea if the ‘Secure Digital Host Controller Interface’ is needed for the Realtek 5287, but I read some blogs and posts claiming it is needed for memory cards, so I selected it in the kernel configuration and included the module in /etc/conf.d/modules:

$ cat /usr/src/linux/.config | grep -i sdhci

I built the rts5208 module but, as that module is not loaded in my case (see the output of lsmod further on), I assume it is actually irrelevant:

Device Drivers
    ---> Staging Drivers
       ---> Realtek PCI-E Card Reader RTS5208/5288 Support

$ cat /usr/src/linux/.config | grep -i rts5208

Below is the current output of the lsmod command, showing which modules are actually loaded currently:

$ lsmod
Module                  Size  Used by
nf_conntrack_ipv6       6211  4 
nf_defrag_ipv6         22518  1 nf_conntrack_ipv6
nf_conntrack_ipv4      11296  8 
nf_defrag_ipv4          1283  1 nf_conntrack_ipv4
xt_conntrack            3081  12 
nf_conntrack_netbios_ns     1021  0 
nf_conntrack_broadcast     1133  1 nf_conntrack_netbios_ns
nf_nat_ftp              1676  0 
nf_nat                 10540  1 nf_nat_ftp
nf_conntrack_ftp        6751  1 nf_nat_ftp
nf_conntrack           59239  8 nf_nat_ftp,nf_conntrack_netbios_ns,nf_nat,xt_conntrack,nf_conntrack_broadcast,nf_conntrack_ftp,nf_conntrack_ipv4,nf_conntrack_ipv6
sdhci_pci              10641  0 
sdhci                  22004  1 sdhci_pci
cifs                  438492  0 
mmc_block              25911  2 
hidp                   14125  0 
rfcomm                 32181  12 
bnep                   10116  2 
fuse                   76386  4 
nvidia               8385213  33 
ecb                     1921  1 
iwlmvm                143855  0 
btusb                  22292  0 
bluetooth             281605  33 bnep,hidp,btusb,rfcomm
uvcvideo               71061  0 
rtsx_pci_ms             5122  0 
memstick                6256  1 rtsx_pci_ms
iwlwifi                75755  1 iwlmvm
r8169                  67544  0 
mii                     3875  1 r8169
rtsx_pci_sdmmc          9905  0 
rtsx_pci               26695  2 rtsx_pci_ms,rtsx_pci_sdmmc
videobuf2_vmalloc       2800  1 uvcvideo
videobuf2_memops        1799  1 videobuf2_vmalloc
videobuf2_core         34587  1 uvcvideo
mfd_core                3193  1 rtsx_pci
x86_pkg_temp_thermal     4567  0

And, finally, below you can see which modules I have explicitly specified to be loaded so far:

$ cat /etc/conf.d/modules
modules="r8169 nvidia agpgart fuse bnep rfcomm hidp uvcvideo cifs mmc_block sdhci-pci rtsx_pci"

Anyway, the important thing is that the laptop’s card reader is now working.

A new laptop

At the beginning of this month my trusty Compal NBLB2 laptop completed five years of heavy use. The HDD was almost full (mostly with my work files) and the laptop’s size and weight were starting to become troublesome on my frequent work trips. So I decided to bite the bullet and buy a new laptop. As Compal is an OEM and I was able to specify various components when buying the NBLB2, I decided to buy an OEM laptop again this time. In the end I decided on the Clevo W230SS, which I ordered from pcspecialist. The configuration I specified is listed below:

  • 13.3″ matte full HD LED IPS widescreen (1920×1080).
  • Intel Core i7 quad-core mobile processor i7-4810MQ (2.80GHz) 6MB.
  • 16GB Kingston SODIMM DDR3 1600MHz (2 x 8GB).
  • NVIDIA GeForce GTX 860M – 2.0GB DDR5, 640 CUDA cores.
  • 750GB WD Scorpio Black WD7500BPKX, SATA 6 Gb/s, 16MB cache (7200 rpm).
  • 8x Samsung slim USB 2.0 external DVD-RW.
  • Integrated 6-in-1 memory card reader (SD/MiniSD/SDHC/SDXC/MMC/RSMMC).
  • Arctic MX-4 Extreme thermal conductivity compound.
  • Intel 2-channel High Definition Audio + mic & headphone jacks.
  • Gigabit LAN & Wireless Intel AC-7260 HMC (867Mbps, 802.11AC) + Bluetooth.
  • 3 USB 3.0 ports + 1 USB 2.0 port.
  • Backlit UK keyboard.
  • 2-button touchpad.
  • 2.0 megapixel Webcam.
  • 6-cell lithium ion battery (62.16WH).
  • Power lead & 120W AC adaptor.
  • 3-year warranty (1 year collect & return; 1 year parts; 3 years labour).
  • 1-year dead pixel guarantee inc. labour & carriage.
  • No operating system required.

The laptop has both a VGA port and an HDMI port. The VGA port is important to me because I need to connect to various models of legacy monitors and projectors in the various offices where I work.

The time from ordering the laptop to its delivery was nine days, and I was impressed with the service by pcspecialist; I received e-mails at each stage of building, testing and delivery (including the option to change the delivery date), and was informed of the name of the courier company, the time of delivery and even the name of the van driver!

My two previous laptops were configured to dual-boot Linux and Windows, but this time I decided not to bother with Windows and install only Gentoo Linux. I virtually never use Windows on the Compal anyway, opting instead to run Microsoft Office 2007 with WINE in Linux, so I decided to save some money this time. I followed the Gentoo AMD64 Handbook to install the operating system and, with one exception which I will mention further on, the Handbook is a very accurate guide.

I have the Testing branch of Gentoo (‘~amd64′) installed on the Compal, but decided to install the Stable branch of Gentoo (‘amd64′) on the Clevo. Since several of the packages I wanted to install are in the Testing branch, I would declare them in /etc/portage/package.accept_keywords/ in order to be able to install them regardless.

Below are some rough notes on what I did, in case they are of any interest to others contemplating installing Gentoo on a laptop with a similar specification. I have to say I like the Clevo W230SS very much so far, although I find the NVIDIA Optimus hardware and driver more complicated to configure than the AMD ATI GPUs on my previous two laptops, and the NVIDIA driver does not work as well with the xrandr command as does the AMD FGLRX driver for ATI GPUs.

When I pressed F2 at boot to check the configuration of the American Megatrends BIOS, I found that UEFI was turned off, and I left it that way. The HDD was apparently MBR not GPT. I was happy to use PC BIOS and MBR rather than UEFI and GPT as that meant I would not have to fiddle with new technology with which I am unfamiliar, and GPT is not necessary as the HDD capacity is less than 2 TiB.

I then booted the HDD for the first time to check if pcspecialist had left anything on it after testing, and the Windows 7 Home Premium ‘Setup is preparing your computer for first use’ screen was displayed. As I had not ordered Windows and therefore had no Microsoft key, and as I did not want Windows on the laptop in any case, I used GParted on a SystemRescueCD Live pen drive to repartition and format the HDD.

I followed the Gentoo AMD64 Handbook but used SystemRescueCd rather than a Gentoo LiveCD or LiveDVD, and therefore I did not have to perform the installation procedure from the very beginning of the Handbook. After downloading the latest SystemRescueCd ISO and installing it to a pen drive (see the instructions on the SystemRescueCd Web site), I booted SystemRescueCd from the pen drive and connected the SystemRescueCd Xfce Live environment to the Web via WiFi. I did not bother to connect an Ethernet cable to the laptop and performed the entire installation of Gentoo to the HDD under WiFi.

I did not need to use the method given in the Gentoo Handbook for creating partitions; I used GParted on SystemRescueCD instead of fdisk or parted on the command line. I was therefore able to ignore the first few pages and started following the Handbook in earnest from Activating the swap partion onwards.

The Handbook recommends creating a ‘BIOS boot partition’ as well as a ‘boot partition’. This is really only necessary for UEFI machines or if the GRUB Embedding Area on the HDD is too small (the GNU Grub Manual 2.00 says the space reserved for the GRUB Embedding Area has to be at least 31 KiB). I did not need to create a ‘BIOS boot partition’, as GParted would only let me create the first partition starting 1 MiB from the beginning of the HDD. Actually, GParted will not let you create /dev/sda1 right at the beginning of the disk; it always seems to want the partition to start 1 MiB from the beginning of the HDD, so I don’t understand why the Handbook wants you to create a ‘BIOS boot partition’ before the Boot partition in the case of MBR HDDs, as there would still be 1 MiB of empty space before the ‘BIOS boot partition’, rendering the latter a waste of space and effort. (As I understand it, the situation is different in the case of GPT because the EFI boot partition must be FAT32, so you have no choice but to create a ‘BIOS boot partition’ if you’re using a GPT HDD.) Perhaps if you are using fdisk or parted on the command line then the situation is different and those commands do allow you to put the first partition right at the beginning of the HDD. So I created the following partitions by using GParted:

/dev/sda1 /boot (Primary Partition)
/dev/sda2 swap (Primary Partition)
/dev/sda3 (Extended Partition)
/dev/sda5 / (Logical Partition)
/dev/sda6 /home (Logical Partition)
/dev/sda7 NTFS partition (Logical Partition)

I specified the ext2 file system for /boot, and ext4 for / and /home. I have used these file systems for many years on previous laptops, and they are very reliable. I decided to add an NTFS partition to store my work files separately from my home files, and in case I ever want to access the laptop using Windows from e.g. a bootable external USB drive or whatever.

When creating the logical partitions sda5, sda6 and sda7, GParted always left 1 MiB unallocated before each logical partition. And I don’t know why GParted would not create a partition named /dev/sda4.

The precise partition configuration is listed below:

# fdisk -l

Disk /dev/sda: 698.7 GiB, 750156374016 bytes, 1465149168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x291ba0e7

Device     Boot     Start        End    Sectors   Size Id Type
/dev/sda1            2048     264191     262144   128M 83 Linux
/dev/sda2          264192   33822719   33558528    16G 82 Linux swap / Solaris
/dev/sda3        33822720 1465147391 1431324672 682.5G  5 Extended
/dev/sda5        33824768  302260223  268435456   128G 83 Linux
/dev/sda6       302262272  839133183  536870912   256G 83 Linux
/dev/sda7       839135232 1465147391  626012160 298.5G  7 HPFS/NTFS/exFAT

# blkid
/dev/sda1: LABEL="BOOT" UUID="f6ffc085-66fe-4bbe-b080-cec355749f85" TYPE="ext2" PARTUUID="291ba0e7-01"
/dev/sda2: UUID="c49e011a-bb8b-4ade-8fda-6c11ca53d660" TYPE="swap" PARTUUID="291ba0e7-02"
/dev/sda5: LABEL="ROOT" UUID="525a90f1-8ad2-44a3-ade3-20f18a0a9595" TYPE="ext4" PARTUUID="291ba0e7-05"
/dev/sda6: LABEL="HOME" UUID="5b60d470-a92a-45b3-9607-3ff3ab483b97" TYPE="ext4" PARTUUID="291ba0e7-06"
/dev/sda7: LABEL="NTFS" UUID="16F4D9B04A85A7E5" TYPE="ntfs" PARTUUID="291ba0e7-07"

The output from the lspci command in SystemRescueCd was as follows:

# lspci
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor DRAM Controller (rev 06)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor PCI Express x16 Controller (rev 06)
00:02.0 VGA compatible controller: Intel Corporation 4th Gen Core Processor Integrated Graphics Controller (rev 06)
00:03.0 Audio device: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller (rev 06)
00:14.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI (rev 05)
00:16.0 Communication controller: Intel Corporation 8 Series/C220 Series Chipset Family MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2 (rev 05)
00:1b.0 Audio device: Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller (rev 05)
00:1c.0 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #1 (rev d5)
00:1c.2 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #3 (rev d5)
00:1c.3 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #4 (rev d5)
00:1d.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1 (rev 05)
00:1f.0 ISA bridge: Intel Corporation HM87 Express LPC Controller (rev 05)
00:1f.2 SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode] (rev 05)
00:1f.3 SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller (rev 05)
01:00.0 3D controller: NVIDIA Corporation GM107M [GeForce GTX 860M] (rev a2)
03:00.0 Network controller: Intel Corporation Wireless 7260 (rev bb)
04:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. Device 5287 (rev 01)
04:00.1 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 12)

The output from the lsusb command in SystemRescueCd was as follows:

# lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 5986:055c Acer, Inc <-- The Webcam!
Bus 003 Device 003: ID 8087:07dc Intel Corp.
Bus 003 Device 002: ID 0dd8:17c0 Netac Technology Co., Ltd
Bus 003 Device 005: ID 090c:3261 Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.)
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The output from the lsmod command in SystemRescueCd was as follows:

# lsmod
Module                  Size  Used by
nilfs2                117674  0 
ccm                    16515  2 
arc4                   12390  2 
iwlmvm                149978  0 
mac80211              421465  1 iwlmvm
btusb                  24725  0 
iwlwifi                88602  1 iwlmvm
bluetooth             258391  2 btusb
cfg80211              320349  3 iwlwifi,mac80211,iwlmvm
x86_pkg_temp_thermal    12390  0 
6lowpan_iphc           16649  1 bluetooth
coretemp               12390  0 
iTCO_wdt               12390  0 
mei_me                 12576  0 
iTCO_vendor_support    12938  1 iTCO_wdt
crct10dif_pclmul       12479  0 
crc32_pclmul           12483  0 
crc32c_intel           16568  0 
i2c_i801               16533  0 
ghash_clmulni_intel    12523  0 
mei                    58244  1 mei_me
tpm_infineon           12437  0 
joydev                 16535  0 
tpm_tis                16533  0 
rfkill                 18094  3 cfg80211,bluetooth
serio_raw              12439  0 
tpm                    26448  2 tpm_tis,tpm_infineon
lpc_ich                20629  0 
shpchp                 29571  0 
microcode              41719  0 
raid10                 37123  0 
raid456                57671  0 
async_raid6_recov      12621  1 raid456
async_pq               12640  2 raid456,async_raid6_recov
async_xor              12573  3 async_pq,raid456,async_raid6_recov
async_memcpy           12464  2 raid456,async_raid6_recov
async_tx               12840  5 async_pq,raid456,async_xor,async_memcpy,async_raid6_recov
raid1                  28900  0 
raid0                  16515  0 
multipath              12390  0 
linear                 12390  0 
usb_storage            52365  2 
nouveau               793903  0 
i915                  586099  2 
ttm                    66567  1 nouveau
drm_kms_helper         37632  2 i915,nouveau
drm                   216971  5 ttm,i915,drm_kms_helper,nouveau
i2c_algo_bit           12633  2 i915,nouveau
i2c_core               28421  6 drm,i915,i2c_i801,drm_kms_helper,i2c_algo_bit,nouveau
rtsx_pci_sdmmc         16538  0 
mmc_core               80530  1 rtsx_pci_sdmmc
rtsx_pci_ms            12442  0 
memstick               13784  1 rtsx_pci_ms
mxm_wmi                12672  1 nouveau
r8169                  49390  0 
rtsx_pci               35470  2 rtsx_pci_ms,rtsx_pci_sdmmc
mii                    13085  1 r8169
mfd_core               12807  2 lpc_ich,rtsx_pci
wmi                    13114  2 mxm_wmi,nouveau
video                  16832  2 i915,nouveau

The output from the SystemRescueCd lsmod command told me that the nouveau driver works with this laptop, that the iwlwifi driver works too, and that the r8169 driver was the likely driver I would need for the wired Ethernet connection (I did not bother to connect an Ethernet cable whilst using SystemRescueCd).

The output from the SystemRescueCd ifconfig command told me the new names of the eth0 and wlan0 interfaces: enp4s0f1 and wlp3s0. I force udev/eudev to use interface names eth0 and wlan0 on my Compal laptop (by adding the parameter net.ifnames=0 to the kernel boot line and by using the command ‘ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules‘). However, although I dislike freedesktop.org’s so-called ‘predictable network interface names‘, I decided to stick with the new interface naming scheme on the Clevo.

As shown in the Handbook, make sure you cd into the directory /mnt/gentoo/ before downloading the Gentoo Stage 3 tarball, otherwise you will end up with the tarball in the wrong directory.

I stuck with the CPU FLAGS specified in the default make.conf file to start with, then, as soon as it was possible during the installation process, I installed app-portage/cpuinfo2cpuflags, ran it to obtain the correct CPU flags and modified /etc/portage/make.conf accordingly (I duplicated the CPU flags in USE="..." and CPU_FLAGS_X86="..." as recommended in Gentoo news item 2015-01-28-cpu_flags_x86-introduction).

I found configuring make.conf for USE flags confusing (see Configuring the USE variable). Although the KDE profile I eselected already contained quite a few of the global USE flags I thought I wanted/needed, I ended up duplicating several of them in make.conf rather than going through the output from the emerge --info command to see which USE flags are already included. I will clean up make.conf sometime in the future. The way to check which USE flags are provided by the profile is to temporarily comment out the USE variable lines in make.conf (and presumably any in /etc/portage/package.use/*) then run the emerge --info command. Anyway, here is what make.conf looked like after I had edited it:

CFLAGS="-O2 -march=native -pipe"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
MY_CPUFLAGS="aes avx avx2 fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3"
CPU_FLAGS_X86="aes avx avx2 fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3"

UNWANTED="-apm -branding -eds -evo -kerberos -gnome -gtk -libav -mono -nepomuk -oss -qt5 -systemd"
MY_MEDIA="alsa audiofile cdda cddb cdr dri dvb dvd dvdr dvdread jack ipod musicbrainz pulseaudio sdl v4l wmf xine"
MY_CODECS="a52 aac dts dv ffmpeg flac gsm lame matroska mp3 musepack ogg openal speex theora x264 xvid"
MY_SYSTEM="acl acpi avahi bash-completion bidi bluetooth bzip2 cjk dbus gcj gnutls icu lm_sensors lzo networkmanager nptl pam policykit udev unicode usb wifi xcb zeroconf"
MY_PRINT="cups foomaticdb gimp ppds scanner"
MY_XSYS="cairo dga gphoto2 gtk openexr opengl png qt4 svg tiff X xinerama"
MY_DESKTOP="gmp kde libnotify pda rdesktop semantic-desktop startup-notification"
MY_COMMS="aim icq imap jabber mbox msn rss slp yahoo"

# The following line is for Layman:
source /var/lib/layman/make.conf
# The following line is for my local overlay:
LINGUAS="en en_GB pt_BR es_ES"

INPUT_DEVICES="evdev synaptics"
VIDEO_CARDS="intel modesetting nvidia"

GENTOO_MIRRORS="rsync://mirror.bytemark.co.uk/gentoo/ http://mirror.qubenet.net/mirror/gentoo/ rsync://rsync.mirrorservice.org/distfiles.gentoo.org/"

I don’t have the ‘source’ line and ‘SYNC’ line in my ~amd64 installation on the Compal because they are running later versions of Portage and Layman, for which the method has changed.

When following the Gentoo Handbook and merging some packages, sometimes messages about required USE flags were displayed. In some of those cases, after studying the messages carefully I repeated the merge command but included the --autounmask-write option, then used the etc-update command to apply the edits to the /etc/portage/package.use/* files, then repeated the merge command. In some cases, e.g. if only one or two USE flag changes needed, I created the new file /etc/portage/package.use/* and performed the edit manually. For example, /etc/portage/package.use/networkmanager containing:

net-misc/networkmanager nss -dhclient dhcpcd -gnutls modemmanager

I am not sure which modules to declare in /etc/conf.d/modules, since the only ones I have to declare in that file in my Compal laptop installation are VirtualBox modules and other modules are loaded automatically. Anyway, I added the r8169, nvidia and fuse modules to that file to start with. Later I added some more and it currently looks like this:

modules="r8169 nvidia fuse agpgart bnep rfcomm hidp mmc_block uvcvideo cifs"

I added ‘agpgart‘ because of what user Arthanis wrote in his post in the Gentoo Forums thread [SOLVED] Optimus and Nvidia but there is no module named agpgart in my installation, so I am not sure to what he was referring.

The modules loaded so far are listed below:

# lsmod
Module                  Size  Used by
cifs                  438492  0 
mmc_block              25911  0 
mmc_core               85695  1 mmc_block
hidp                   14125  0 
rfcomm                 32181  12 
bnep                   10116  2 
fuse                   76386  2 
nvidia               8385213  33 
ecb                     1921  1 
iwlmvm                143855  0 
r8169                  67544  0 
btusb                  22292  0 
bluetooth             281605  33 bnep,hidp,btusb,rfcomm
uvcvideo               71061  0 
videobuf2_vmalloc       2800  1 uvcvideo
videobuf2_memops        1799  1 videobuf2_vmalloc
videobuf2_core         34587  1 uvcvideo
mii                     3875  1 r8169
iwlwifi                75755  1 iwlmvm
x86_pkg_temp_thermal     4567  0

The rest of the drivers are in-kernel.

Version 216 of sys-fs/udev was installed, which predates the change in udev to stop loading firmware (see the Gentoo Forums thread udev-217 stalls booting) so I may have trouble with loading CPU microcode and WiFi firmware (and video firmware? — see further on) in future when sys-fs/udev-217 becomes stable in the Gentoo Portage tree.

I configured netifrc for enp4s0f1 only (I didn’t bother with WiFi) for DHCP, as per Gentoo Handbook section Configuring the system, as I only wanted to be sure of a network connection after rebooting until I could get NetworkManager working, at which I point I would ditch the netifrc stuff completely. As I have to travel frequently because of my work, I find NetworkManager more convenient.

Apart from configuring the kernel (I lost count of how many times I had to rebuild it), the only problem was when I installed GRUB 2 (Gentoo Handbook section Configuring the bootloader). There appears to be an error in the Gentoo Handbook; see Gentoo Forums thread grub2 install for the fix.

X Windows and NVIDIA Optimus

However, getting X Windows working was a major hassle. First I followed the Gentoo Wiki article X server to install the packages xorg-server and xorg-drivers, then I followed the Gentoo Wiki article NVIDIA Driver with Optimus Laptops to try and get the closed-source NVIDIA driver working, but X Windows could not find a screen. (I have no idea what sys-apps/qingy is or whether it is needed, but, as the Wiki article mentions it, I installed it anyway but did not add the xrandr commands to the end of the /etc/X11/Sessions/KDE-4 file, but I did add the xrandr commands to the /usr/share/config/kdm/Xsetup file.) Then I followed Gentoo user Arthanis‘ Gentoo Forums post [SOLVED] Optimus and Nvidia (changing the edid_firmware name to suit). I was confused by his reference to rcu_idle_delay, by which he meant CONFIG_RCU_FAST_NO_HZ (see Understanding RCU when Configuring the Linux Kernel). Thank goodness for his post, though, as I would never have worked it out myself. All my main laptops since 2000 have had ATI GPUs, and they were easier to set up than this NVIDIA Optimus stuff. Although the laptop has both Intel and NVIDIA graphics hardware, I think the laptop is muxless (i.e. does not have hybrid graphics/NVIDIA HybridPower), so I left CONFIG_VGASWITCHERROO=n in the kernel, but I have no idea if that is correct. This whole dual GPU/APU switching thing confuses me.

After I followed Arthanis‘ post and rebooted, the KDM screen consisted of tiled ‘mini-screens’, with the KDM log-in window in the top left mini-screen. I solved this by adding a Virtual command in xorg.conf — see the Gentoo Forums post XOrg refusing to start after a fresh build by user qweb.ric.

Below are the current contents of xorg.conf:

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "nvidia" 0 0
    Inactive       "intel"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"

#Section "Files"

Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol"
    Option         "Device" "/dev/input/mice"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"

Section "InputDevice"
    Identifier     "Keyboard0"
    Driver         "kbd"

Section "Monitor"
    Identifier     "Monitor0"
    Option         "DPMS"

Section "Device"
    Identifier     "nvidia"
    Driver         "nvidia"
    BusID          "PCI:1:0:0"

Section "Device"
    Identifier     "intel"
    Driver         "modesetting"
    BusID          "PCI:0:2:0"

Section "Screen"
    Identifier     "nvidia"
    Device         "nvidia"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "UseDisplayDevice" "none"
    SubSection     "Display"
        Depth       24
#        Modes      "nvidia-auto-select"
        Virtual     1920 1080

Section "Screen"
    Identifier     "intel"
    Device         "intel"
    Monitor        "Monitor0"

To get tapping to work on the touchpad I had to create the file /etc/X11/xorg.conf.d/50-synaptics.conf as usual:

Section "InputClass"
    Identifier "touchpad catchall"
    Driver "synaptics"
    MatchIsTouchpad "on"
    MatchDevicePath "/dev/input/event*"
    Option "TapButton1" "1"
    Option "TapButton2" "2"
    Option "TapButton3" "3"
    Option "VertEdgeScroll" "on"
    Option "VertTwoFingerScroll" "on"
    Option "HorizEdgeScroll" "on"
    Option "HorizTwoFingerScroll" "on"
    Option "CircularScrolling" "on"
    Option "CircScrollTrigger" "0"
    Option "EmulateTwoFingerMinZ" "40"
    Option "EmulateTwoFingerMinW" "8"
    Option "CoastingSpeed" "0"
    Option "FingerLow" "35"
    Option "FingerHigh" "40"

Section "InputClass"
    Identifier "touchpad ignore duplicates"
    MatchIsTouchpad "on"
    MatchDevicePath "/dev/input/mouse*"
    Option "Ignore" "on"

And I also created the file /etc/X11/xorg.conf.d/30-keyboard.conf:

Section "InputClass"
    Identifier "keyboard"
    # See /usr/share/X11/xkb/rules/base.lst for Options.
    MatchIsKeyboard "yes"
    Option "XkbLayout" "gb,us,br,es"
    Option "XkbModel" "pc104"
    Option "XkbVariant" ""
    Option "XkbOptions" "grp:alt_shift_toggle"

and the file /etc/X11/xorg.conf.d/10-evdev.conf:

Section "InputClass"
        Identifier "evdev pointer catchall"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"

Section "InputClass"
        Identifier "evdev keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"

#Section "InputClass"
#        Identifier "evdev touchpad catchall"
#        MatchIsTouchpad "on"
#        MatchDevicePath "/dev/input/event*"
#        Driver "evdev"

Section "InputClass"
        Identifier "evdev tablet catchall"
        MatchIsTablet "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"

Section "InputClass"
        Identifier "evdev touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"

(See my post about xorg.conf for a later version (not Stable in the Portage tree yet) of X Windows on the Compal, Fixing unperceived errors in my X Windows configuration.)

I forgot to do the following:

# rc-update add dbus default
# rc-update add consolekit default

See the Gentoo Forums thread [ConsoleKit session] Failed to connect to socket (resolved) for the error message I was getting when the KDE Desktop appeared. In addition to the aforementioned error message, a window with a KDE Daemon crash message popped-up at log-in and KDE Plasma would crash when I dragged the System Tray widget to the Panel. Once the dbus and consolekit services were added to the default runlevel, all was good.


After I merged NetworkManager I forgot to do:

# rc-update add NetworkManager default

but once I did that and the following:

# rc-update del net.enp4s0f1 default

then NetworkManager worked.

There was no /etc/NetworkManager/NetworkManager.conf, so I created that manually:



KDE plasma-nm crashes most times I try to create or edit a connection, so sometimes I have to edit the file /etc/NetworkManager/system-connections/* using nano. The current Stable version of plasma-nm in Gentoo is and I believe the latest version of plasma-nm has fixed this bug, so eventually it should work correctly.


I followed Gentoo Wiki article ALSA and compiled ALSA into the kernel rather than modules. Card 0 is HDMI and Card 1 is HDA (the opposite to what is usually expected). KDE Multimedia settings worked when I selected Analogue Audio, but I had to install pavucontrol in order to be able to switch off HDMI and get audio in the Web browser etc. to be played via the laptop speakers/headphones. Later I will try the Gentoo Wiki ALSA article’s suggestion of adding snd-hda-intel.index=1,0 to the kernel boot line to switch the order of the cards.

Although I set what I think are the relevant MMC parameters in the kernel configration, the Memory Card slot does not work. Perhaps some kernel configuration settings remain to be set. I will have a look later. Gentoo Forums thread SD card under Gentoo Linux may help.


Bluetooth is working after I made some kernel configuration settings and loaded the modules bnep, rfcomm and hidp via /etc/conf.d/modules (lsmod showed that btusb and bluetooth were already loaded automatically, but I added them anyway to /etc/conf.d/modules). I also had to do:

# rc-update bluetooth add default

The external portable USB portable CD/DVD writer (Samsung SE-208GB/RSBD) I bought from pcspecialist works well. I have tried it so far with an Audio CD, a data DVD and burning data to a CD-R.


The built-in Webcam does not work. Update (April 29, 2015): I discovered today that the Webcam works fine; the problem was a bug in the version of the guvcview application I tried. So all is good. According to lsusb the Webcam is:

Bus 001 Device 010: ID 5986:055c Acer, Inc

The lsmod command shows the uvcvideo module is loaded. When I ‘rmmod uvcvideo‘ then ‘modprobe uvcvideo‘ the dmesg command shows the following:

[ 6508.624505] uvcvideo: Found UVC 1.00 device BisonCam, NB Pro (5986:055c)
[ 6508.627349] input: BisonCam, NB Pro as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/input/input43
[ 6508.627425] usbcore: registered new interface driver uvcvideo
[ 6508.627427] USB Video Class driver (1.1.1)

The application guvcview displays a black window, and the Konsole from which guvcview was launched displays repeated ‘Ignoring empty buffer ...‘ messages:

$ guvcview
guvcview 1.6.1
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.28/work/alsa-lib-1.0.28/src/pcm/pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.28/work/alsa-lib-1.0.28/src/pcm/pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.28/work/alsa-lib-1.0.28/src/pcm/pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.28/work/alsa-lib-1.0.28/src/pcm/pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.28/work/alsa-lib-1.0.28/src/pcm/pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.28/work/alsa-lib-1.0.28/src/pcm/pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
video device: /dev/video0
Init. BisonCam, NB Pro (location: usb-0000:00:1a.0-1.4)
{ pixelformat = 'MJPG', description = 'MJPEG' }
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 
{ discrete: width = 160, height = 120 }
        Time interval between frame: 1/30, 
{ discrete: width = 176, height = 144 }
        Time interval between frame: 1/30, 
{ discrete: width = 320, height = 240 }
        Time interval between frame: 1/30, 
{ discrete: width = 352, height = 288 }
        Time interval between frame: 1/30, 
{ discrete: width = 640, height = 360 }
        Time interval between frame: 1/30, 
{ discrete: width = 1280, height = 720 }
        Time interval between frame: 1/30, 
{ discrete: width = 1280, height = 1024 }
        Time interval between frame: 1/30, 
{ discrete: width = 1920, height = 1080 }
        Time interval between frame: 1/30, 
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 
{ pixelformat = 'YUYV', description = 'YUV 4:2:2 (YUYV)' }
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 160, height = 120 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 176, height = 144 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 320, height = 240 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 352, height = 288 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 640, height = 360 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 1280, height = 720 }
        Time interval between frame: 1/10, 
{ discrete: width = 1280, height = 1024 }
        Time interval between frame: 1/5, 
{ discrete: width = 1920, height = 1080 }
        Time interval between frame: 1/5, 
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 1/15, 
{ pixelformat = 'RGB3', description = 'RGB3' }
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 160, height = 120 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 176, height = 144 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 320, height = 240 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 352, height = 288 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 640, height = 360 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 1280, height = 720 }
        Time interval between frame: 1/30, 
{ discrete: width = 1280, height = 1024 }
        Time interval between frame: 1/30, 
{ discrete: width = 1920, height = 1080 }
        Time interval between frame: 1/30, 
{ pixelformat = 'BGR3', description = 'BGR3' }
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 160, height = 120 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 176, height = 144 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 320, height = 240 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 352, height = 288 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 640, height = 360 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 1280, height = 720 }
        Time interval between frame: 1/30, 
{ discrete: width = 1280, height = 1024 }
        Time interval between frame: 1/30, 
{ discrete: width = 1920, height = 1080 }
        Time interval between frame: 1/30, 
{ pixelformat = 'YU12', description = 'YU12' }
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 160, height = 120 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 176, height = 144 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 320, height = 240 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 352, height = 288 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 640, height = 360 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 1280, height = 720 }
        Time interval between frame: 1/30, 
{ discrete: width = 1280, height = 1024 }
        Time interval between frame: 1/30, 
{ discrete: width = 1920, height = 1080 }
        Time interval between frame: 1/30, 
{ pixelformat = 'YV12', description = 'YV12' }
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 160, height = 120 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 176, height = 144 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 320, height = 240 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 352, height = 288 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 640, height = 360 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 1280, height = 720 }
        Time interval between frame: 1/30, 
{ discrete: width = 1280, height = 1024 }
        Time interval between frame: 1/30, 
{ discrete: width = 1920, height = 1080 }
        Time interval between frame: 1/30, 
checking format: 1196444237
VIDIOC_G_COMP:: Inappropriate ioctl for device
fps is set to 1/30
drawing controls

fps is set to 1/30
Checking video mode 640x480@32bpp : OK
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
< Here I pressed Ctrl-C >
write /home/fitzcarraldo/.guvcviewrc OK
free controls
cleaned allocations - 100%
Closing portaudio ...OK
Closing GTK... OK

I tried all the available uvcvideo quirks (see Linux UVC driver and tools – FAQ: What are quirks and how do I use them?) but the result was always the same.

# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000200
# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000100
# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000080
# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000020
# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000010
# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000008
# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000004
# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000002
# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000001

There is possibly a bug in the uvcvideo driver (see [Kernel-packages] [Bug 1362358] Re: uvcvideo doesn’t work with USB webcam with linux 3.16), so I will have to try a later kernel at some point.

Update (April 29, 2015): I discovered today that nothing is wrong with the uvcvideo driver or the Webcam. The problem I described above was caused by a bug in the guvcview application itself. The Gentoo Stable version is guvcview-1.6.1, so I specified Gentoo Testing version guvcview-2.0.1 in /etc/portage/package.accept_keywords/guvcview and installed it, and now guvcview displays the Webcam output perfectly.

Transferring Thunderbird account settings and e-mails

My Compal laptop dual-boots Gentoo and Windows 7. Thunderbird is installed in both OSs, and both Windows Thunderbird and Linux Thunderbird use the same Mail folder on the NTFS Windows partition, but with different prefs.js files (i.e. Windows Thunderbird uses a prefs.js file on the Windows partition, and Linux Thunderbird uses a prefs.js file in the /home partition). In order to port my Thunderbird e-mails from the Windows partition on the Compal to the /home partition on the Clevo, I did the following:

  1. Installed Thunderbird on the Clevo.
  2. Launched Thunderbird and cancelled the Thunderbird wizard for creating a new account.
  3. Closed Thunderbird.
  4. Copied the Mail folder from the Compal’s Windows Thunderbird folder into the new Linux Thunderbird profile folder on the Clevo.
  5. Copied the prefs.js file from the Windows Thunderbird folder into the new Linux Thunderbird profile folder on the Clevo.
  6. Edited the prefs.js file to change all the Windows paths to Linux paths.

I also copied the three Address Book files abook.mab, history.mab and impab.mab across, but the first e-mail address in the Address Book differed between the two laptops so I exported the address books from Thunderbird in Linux (‘Address Book’ > ‘Tools’ > ‘Export…’ to create .ldif files) on the Compal and imported them into Thunderbird on the Clevo, but the result was no different to copying the .mab files, so it looks correct (the number of entries in the address books on each laptop was the same). Looking at a fresh installation of Thunderbird, I notice there is no impab.mab file, only the other two, and also the impab.mab file on the Compal has a 2011 date whereas the abook.mab and history.mab have current dates, so I wonder if the impab.mab file is redundant in the latest versions of Thunderbird.

A few panics (mine and the kernel’s!)

I had a couple of panic moments when rebooting after making changes to the kernel: if I had left a USB pen drive or a USB HDD plugged into the Clevo when I rebooted, the kernel would oops during boot-up. I initially thought these kernel panics were due to my mis-configuration of the kernel, but finally realised what was causing the oops when one of the error messages referred to a partition sdc1 on a pen drive. Actually, I had enabled too many kernel options in my first kernel build so it was probably better that I restarted the Gentoo installation anyway (I only restarted the installation from scratch once). The Compal boots normally if it has USB storage devices plugged in when it boots, so I’m not sure why it happens on the Clevo. Both laptops have the HDD first in the boot order, so I don’t know why the Clevo complains.

External monitor

I used xrandr commands to get my external monitor (an Acer AL1916W with a max resolution of 1440×900) to display the Clevo’s desktop correctly. I used the following command to view the available monitors and modes:

$ xrandr -q
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 16384 x 16384
eDP-1-0 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 282mm x 165mm
   1920x1080     60.00*+  40.00  
   1400x1050     59.98  
   1280x1024     60.02  
   1280x960      60.00  
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   800x600       60.00    60.32    56.25  
   700x525       59.98  
   640x512       60.02  
   640x480       60.00    59.94  
   512x384       60.00  
   400x300       60.32    56.34  
   320x240       60.05  
VGA-1-0 disconnected (normal left inverted right x axis y axis)
DisplayPort-1-0 connected (normal left inverted right x axis y axis)
   1920x1080     60.00 +  40.00  
HDMI-1-0 disconnected (normal left inverted right x axis y axis)

I don’t know why the connected AL1916W monitor is shown as having only one display mode, and why that mode is 1920×1080. The AL1916W supports several modes up to 1440×900, and these are all displayed by the xrandr command on the Compal. It seems the NVIDIA driver is unable to read the external monitor’s EDID whereas the AMD ATI FGLRX driver is able to do so. Anyway I did the following to force the NVIDIA driver to display the Desktop correctly, which I later automated in a Bash script launched from a Desktop Configuration File:

$ xrandr --output DisplayPort-1-0 --off
$ xrandr --newmode "1440x900" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync # Only need to add new mode once per X session.
$ xrandr --addmode DisplayPort-1-0 1440x900
$ xrandr --output eDP-1-0 --off && xrandr --output DisplayPort-1-0 --mode 1440x900

I pressed the AL1916W monitor’s MENU button and selected AUTO to make sure the monitor’s display is as sharp as possible.


I have an HP ScanJet 3400C scanner and my Canon PIXMA MP560 MFP also has a scanner. I had to install hplip in order to be able to use XSane, gscan2pdf and Simple Scan with the HP ScanJet 3400C scanner. I also found that the HP ScanJet 3400C must be switched off in order to be able to use the Canon MP560 scanner, whereas I don’t need to switch off the Canon MP560 in order to be able to use the HP ScanJet 3400C!

Skype and PulseAudio

As Qt 4.8.5 has not yet been marked stable in Gentoo, and therefore there is not a stable version of Qt with the abi_x86_32 USE flag, I installed Skype using the hack given by Gentoo user pablo_supertux in his Gentoo Forums post [SOLVED] Skype and the new multilib, which works well.

The laptop’s volume settings jumped to 100% periodically, and this is another of PulseAudio’s irritating quirks. To stop this happening I edited the file /etc/pulse/daemon.conf and changed:

; flat-volumes = yes


flat-volumes = no

i.e. I uncommented the line and changed ‘yes‘ to ‘no‘.

I had disabled Skype from automatically adjusting audio settings. If I still find that PulseAudio is causing volume levels to change at start-up (see my earlier posts), I will create a script in /etc/local.d/ to set them automatically for me.

Things left for me to do:

  1. Get the Webcam working. Update (April 29, 2015): Done! It turned out there was nothing wrong with the uvcvideo driver or the hardware; the guvcview application had a bug. I installed a newer version of guvcview and it works correctly. So all is good.
  2. Get the Memory Card slot working. Boot SystemRescueCd and see if SDHC and/or SDXC memory cards are accessible. Update (April 28, 2015): Done! See my next post Realtek 5287 PCIe controller for memory card reader for the changes I made to the kernel configuration.
  3. Check the Bash backup scripts I created for the Compal and edit them if necessary so that they work on the Clevo. Update (April 29, 2015): Done!
  4. When Qt 4.8.6 is made Stable in the Portage tree, install Skype using Portage. Update (May 16, 2015): Done!
  5. Check which other applications and utilities I installed on the Compal need to be installed on the Clevo. Update (April 29, 2015): Done!
  6. Install the Samsung Unified Printer driver and get it working with the Samsung printers in the office. Update (April 29, 2015): Done!
  7. Investigate why the Clevo cannot print to my Canon PIXMA MP560 via WiFi. Update (May 15, 2015): Done! The problem was with the printer, not the Clevo. The printer was not always connecting to my home WiFi network.
  8. Install UFW and either a) the KDE KControl Module for UFW or b) UFW Frontends, and add firewall rules for Samba/CIFS and KDE Connect. Update (June 30, 2015): Done! Finally got around to doing it. ufw was giving an error message for IPv6, though, but I fixed that by rebuilding the kernel with some more parameters selected: CONFIG_NETFILTER_XT_TARGET_HL=m, CONFIG_IP6_NF_MATCH_RT=m and CONFIG_IP6_NF_TARGET_HL=m.
  9. Investigate why Samba cannot access the family Acer Aspire XC600 running Windows 8.1. The Samba service is running on the Clevo, and both Samba 3 and Samba 4 on the Compal can access shares on the Aspire XC600 and on the Clevo, so something must be wrong with the installation on the Clevo. Update (May 17, 2015): Done! The problem was that I had not merged kde-base/kdebase-kioslaves with the samba USE flag. Once I did that, Dolphin could browse Samba shares on the family PC running Windows 8.1.
  10. Find out the manual commands for switching between the Intel APU and NVIDIA GPU that Gentoo user Arthanis mentioned in his post [SOLVED] Optimus and Nvidia. Update (June 30, 2015): Done! See the latest post in the aformentioned Gentoo Forums thread. Sometime in the next month or so I’ll post in this blog the full details of my solution.
  11. Investigate why the KDE Network widget plasma-nm is crashing when I add/edit connections (see a recent KDE blog post Plasma-nm release about the last update to plasma-nm-4.* which fixes some bugs). I suppose I need to wait for plasma-nm- to become stable in the Portage main tree. Update (April 30, 2015): Done! I got fed up with the buggy ‘Stable’ plasma-nm- so I added plasma-nm- to /etc/portage/package.accept_keywords/plasma-nm and Version is no longer crashing.
  12. Get qr-tools (QR Code application) working on the Clevo. Update (April 29, 2015): Done!

More tools for creating QR Codes in Linux

In my previous post I showed how to install CuterCode and Qreator, two simple GUI applications for producing QR Codes, in Gentoo Linux. I have now found a couple of other GUI applications, both of which offer more features than the aforementioned two, such as allowing you to specify the amount of error correction to be incorporated into the QR Code. QR Code codewords are 8 bits long and use the Reed–Solomon error correction algorithm, with four error correction levels possible in the case of QR Codes:

Level L (Low): 7% of codewords can be restored.
Level M (Medium): 15% of codewords can be restored.
Level Q (Quartile): 25% of codewords can be restored.
Level H (High): 30% of codewords can be restored.

The higher the level of error correction, the lower the storage capacity of the QR Code.

And now to the two applications …

Portable QR-Code Generator

This is a Java application, so first make sure you have installed a Java run-time environment (or Java Development Toolkit, which will include the JRE) via Portage.

Download to your home directory the archive qrcodegen_1.14.2.zip containing the compiled Java application, not the archive qrcodegen_1.14.2_src.zip with the source code (‘quellcode’ in German), from the application’s Web site. Unzip it to the directory ~/qrcodegen_1.14.2/ then enter the directory and launch the Java application from the command line as shown below:

$ cd ~/qrcodegen_1.14.2/qrcodegen
$ java -jar QRCodeGen.jar

Alternatively you can create a Desktop Configuration file QRCodeGen.desktop containing the following (change ‘fitzcarraldo’ to your own user name, of course):

[Desktop Entry]
Comment[en_GB]=QR Code Generator is a program that lets you generate and print QR Codes easily.
Comment=QR Code Generator is a program that lets you generate and print QR Codes easily.
Exec=java -jar /home/fitzcarraldo/qrcodegen_1.14.2/qrcodegen/QRCodeGen.jar

and make it executable:

$ chmod +x QRCodeGen.desktop

You can choose a nice PNG icon by using Google Images to search for ‘qr code icon png’ and save the image with the file name icon.png in the same directory. Then you can launch QR code Generator by double-clicking on the Desktop Configuration file.

QtQR – QR Code Generator

Download the tarball qr-tools-1.2.tar.gz from the application’s Web site, unpack it to the directory ~/qr-tools-1.2/ and make the Python scripts executable:

$ cd ~/qr-tools-1.2/qr-tools
$ chmod +x qtqr.py
$ chmod +x qrtools.py

Make sure you have installed the package media-gfx/zbar with the python USE flag set, so that the Python zbar module is also installed:

# USE="python" emerge zbar

(You may as well add the python USE flag in the line for media-gfx/zbar in the Portage package.use file so that ZBar’s Python module is installed if you upgrade or re-install ZBar via Portage in future).

Check if the Python Imaging Library (fork) dev-python/pillow is already installed:

# emerge --search pillow

If it is not already installed, install it:

# emerge pillow

Now you can launch QtQR from the command line as follows:

$ cd ~/qr-tools-1.2/qr-tools
$ LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so PYTHONPATH=/usr/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages/PIL ./qtqr.py

Alternatively, you can create a Desktop Configuration file qtqr.desktop with the following contents (change ‘fitzcarraldo’ to your own user name, of course):

[Desktop Entry]
Comment[en_GB]=QtQR is a Qt based software that lets you generate QR Codes easily, scan an image file for a QR Code and decode it or use your webcam to scan a printed one.
Comment=QtQR is a Qt based software that lets you generate QR Codes easily, scan an image file for a QR Code and decode it or use your webcam to scan a printed one.
Exec=LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so PYTHONPATH=/usr/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages/PIL /home/fitzcarraldo/qr-tools-1.2/qr-tools/qtqr.py

and make it executable:

$ chmod +x qtqr.desktop

Then you can launch QtQR by double-clicking on the Desktop Configuration file.

The QtQR GUI has a feature for decoding a QR Code in an image file and for decoding a printed QR Code held in front of a Webcam. If I select ‘Decode’ > ‘Decode from Webcam’, QtQR launches ZBar and, although it is a bit fiddly, I can successfully decode a printed QR Code. However, I cannot get QtQR to decode a QR Code in an image file that QtQR itself created (or to decode a QR Code in a file created by any other application, for that matter), so there is a bug in QtQR. Looking at the application’s bug reports this appears to be Bug No. 811576. It’s not a big deal, though, because the zbarimg command provided by ZBar can be used to decode QR Codes (see my post Installing and using ZBar in Linux to scan bar codes with your Webcam).

$ cd ~/qr-tools-1.2/qr-tools
$ LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so PYTHONPATH=/usr/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages/PIL ./qtqr.py
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py:127: RuntimeWarning: PyOS_InputHook is not available for interactive use of PyGTK
Object::connect: No such signal org::freedesktop::UPower::DeviceAdded(QDBusObjectPath)
Object::connect: No such signal org::freedesktop::UPower::DeviceRemoved(QDBusObjectPath)
kfilemodule(32309) KSambaSharePrivate::testparmParamValue: Running testparm ("-d0", "-s", "--parameter-name", "usershare path")
Traceback (most recent call last):
  File "./qtqr.py", line 481, in decodeFile
    if qr.decode():
  File "/home/fitzcarraldo/qr-tools-1.2/qr-tools/qrtools.py", line 147, in decode
    pil = Image.open(self.filename).convert('L')
  File "/usr/lib/python2.7/site-packages/PIL/Image.py", line 2256, in open
    % (filename if filename else fp))
IOError: cannot identify image file u'/home/fitzcarraldo/qr-tools-1.2/qr-tools/test.png'

Linux Magazine has a good article on these and other QR Code tools: Generating QR Codes in Linux.

UPDATE (March 30, 2015): You can download an updated working revision (Revision 20) of the Python script qrtools.py, and an updated working revision (Revision 21) of the Python script qtqr.py, from the QtQR and QR Tools developers’ repository where they have been working on an as-yet unreleased Version 1.4 of QtQR and QR Tools:


I have briefly tested qrtools.py Revision 20 and qtqr.py Revision 21 with the other QR Tools Version 1.2 files I downloaded earlier. I simply downloaded the Revison 20 qrtools.py file and the Revision 21 qtqr.py file and overwrote the qrtools.py and qtqr.py files I had extracted earlier from qr-tools-1.2.tar.gz into the directory /home/fitzcarraldo/qr-tools-1.2/qr-tools/ (and made them executable). With the new qrtools.py and new qtqr.py it is now possible for QtQR to decode QR Codes in image files as well as QR Codes scanned via a Webcam, so the bug I mentioned above should be fixed in the next official release of QtQR/QR Tools. So you may as well skip the official Version 1.2 and download all the files from the above-mentioned developers’ repository for the future Version 1.4.

How to create QR Codes easily in Gentoo Linux

QR Codes are two-dimensional bar codes that can store a surprising amount of information. CuterCode and Qreator are two applications that are easy to install and use to produce QR Codes that can be saved as image files for use on labels, posters, Web sites, business cards, documents, etc. Here is how to install CuterCode and Qreator in Gentoo Linux.

Example of a QR Code

A QR Code created using Qreator. You can read it using the Android app Barcode Scanner by ZXing Team and several other Android apps, and also using a Linux app (see my post on ZBar).


This is a Python script and simple GUI.


First download the script itself:

$ wget https://raw.githubusercontent.com/mnagel/cutercode/master/cutercode
$ wget https://raw.githubusercontent.com/mnagel/cutercode/master/cutercode.ui

Make the Python script exectuable:

$ chmod +x cutercode

Then install the package media-gfx/qrencode-python (it will pull-in the package media-gfx/qrencode) on which it depends:

# emerge qrencode-python

To launch the application:

$ ./cutercode

Use the Print Scrn key on your keyboard to launch KSnapshot (or whatever screen capture tool it is you use) and capture the QR Code to a JPG or PNG file for use in you documents. That’s it!


The UI of Qreator is more polished than CuterCode, and you have the options to save the QR Code as a PNG file, copy it to the clipboard, print it or edit its appearance.


Either merge it from Portage overlay dev-zero using layman:

# layman -S
# layman -a dev-zero
# emerge qreator

or download the dev-zero files into your local overlay and install it from there:

# mkdir -p /usr/local/portage/app-office/qreator/files
# cd /usr/local/portage/app-office/qreator
# wget http://data.gpo.zugaina.org/dev-zero/app-office/qreator/qreator-13.05.3.ebuild
# cd files
# wget http://data.gpo.zugaina.org/dev-zero/app-office/qreator/files/13.05.3-python-imaging.patch
# cd ..
# ebuild qreator-13.05.3.ebuild manifest
# emerge qreator

If you happen to be a KDE user, you will find a menu entry for Qreator is installed under ‘Applications’ > ‘Graphics’ in the KDE launcher, or you can launch it from the command line:

$ qreator

Background reading

QR Code – Wikipedia
QRcode.com – Answers to your questions about the QR Code

More on NetworkManager creating a new connection ‘eth0′ that does not work

In a previous post I described a problem I have been experiencing with NetworkManager since Version (I am now using Version 1.0.0): sometimes, but not always, there is an invalid second eth0 connection when my laptop boots. This invalid second eth0 connection has only IPv6 Link-Local enabled (i.e. IPv4 and IPv6 are disabled) and is Active. As a result the existing eth0 connection for IPv4 I previously created is Available but unable to connect.

While on a work trip and using my laptop on an office network and an hotel network I made some changes to my installation (see the above-mentioned previous post) that seemed to fix this problem on those networks. However, on returning home and connecting my laptop to my home network, I found the problem still exists. This makes me wonder if a race condition is occurring, as network latency can differ between networks. Could it be that my home network takes longer to assign an IPv4 address than the office and hotel networks I used, which results in NetworkManager creating a second eth0 connection with IPv4 and IPv6 disabled? Or perhaps there is a race condition between services but network latency has nothing to do with it. In retrospect, I should have checked the contents of the log file /var/log/messages while on my work trip to see if those networks were providing my laptop with an IPv6 address in addition to an IPv4 address, i.e. check if the IPv6 address was not just a Link-Local address.

But why is NetworkManager creating any additional connection at all when NetworkManager.conf in my installation currently contains ‘no-auto-default=eth0‘? Surely this must be a bug in NetworkManager?

I have found virtually no mention of this behaviour on the Web. Debian bug report no. 755202 appears to describe the same problem. I started experiencing the problem in Gentoo Linux (~amd64 installation using OpenRC) after I upgraded NetworkManager to Version too, and it has continued occurring up to the current version of NetworkManager (1.0.0). Fellow Gentoo Linux user Keivan Moradi’s fix (Message #79 in the aforementioned Debian bug report) did not cure the problem for me, and, anyway, my wired NIC uses a different driver (atl1c module) which appears to be stable in my installation.

CentOS bug report no. 0007435 also appears to report the same behaviour, but I’m not sure.

NetworkManager usually (but not always) creates an invalid second eth0 connection when my laptop boots and an Ethernet cable is connected to my home network. The second eth0 connection is shown as Active in plasma-nm (the KDE front-end for NetworkManager) but only has an IPv6 Link-Local connection configured (i.e. IPv4 is shown as Disabled). If I click on Disconnect in plasma-nm then this ‘rogue’ eth0 connection disappears from plasma-nm. Once the invalid IPv6 Link-Local connection has been disconnected, the valid IPv4 eth0 available connection can connect to the network and access the Internet.

I examined /var/log/messages when the invalid second eth0 connection occurs and when it doesn’t, and the invalid eth0 connection only seems to occur when NetworkManager appears to have first started earlier than syslog-ng began logging. When NetworkManager first starts after syslog-ng began logging, I can see it launches dhcpcd and acquires an IPv4 address. avahi-daemon does not seem to be the cause of the problem if I understand the log file correctly. Anyway, my experiments described below seem to exonerate the Avahi daemon. I could be misinterpreting what is going on, but that’s how it looks to my inexpert eyes. In Debian bug report no. 755202 some commenters refer to extra interfaces with names such as ‘eth0:avahi’ being listed by the ifconfig command when the problem occurs, but I wonder if that is just a side effect. Anyway, the ifconfig command does not list such interfaces in my case.

I tried the following experiments:

1. I commented out the entire contents of the file /etc/conf.d/net (the configuration file for initscripts /etc/init.d/net.*) — which I think is analogous to Debian’s /etc/network/interfaces file — but it did not stop the invalid second eth0 connection occurring.

2. I added ‘use-ipv6=no‘ and, later, ‘use-ipv4=no‘ in the file /etc/avahi/avahi-daemon.conf but they did not stop the invalid second eth0 connection occurring.

3. I added ‘deny-interfaces=eth0‘ in the file /etc/avahi/avahi-daemon.conf but it did not stop the invalid second eth0 connection occurring.

4. In my installation, the ‘local‘ service (launched by initscript /etc/init.d/local) has always been allocated to two runlevels: ‘default‘ and ‘nonetwork‘. I de-allocated the ‘local‘ service from the ‘nonetwork‘ runlevel but this did not stop the invalid second eth0 connection occurring.

5. In my installation, the ‘net.lo‘ service (launched by initscript /etc/init.d/net.lo) has always been allocated to the ‘boot‘ runlevel (the other net.* services, such as ‘net.eth0‘ and ‘net.wlan0‘, have never been allocated to a runlevel in my installation). I de-allocated ‘net.lo‘ from the ‘boot‘ runlevel but it did not stop the invalid eth0 connection occurring.

As experiments 4 and 5 did not stop the laptop accessing the Internet once I had deleted the invalid second eth0 connection, I have left the ‘local‘ service in the ‘default‘ runlevel only, and I have left the ‘net.lo‘ service unallocated to a runlevel.

6. Since the invalid eth0 connection is allocated an IPv6 Link-Local address rather than an IPv4 address on my home network, I tried a work-around: I disabled IPv6 system-wide by un-commenting the line ‘alias net-pf-10 off‘ in the file /etc/modprobe.d/aliases.conf. Now a second eth0 connection is no longer created, and the valid eth0 IPv4 connection I created previously connects automatically. I have not rebooted many times yet, so I don’t know if this work-around has eliminated the problem for good, but it looks promising.

Nevertheless I would like to find the root cause of the problem, rather than settling for a work-around of disabling IPv6 system-wide. Given that, when IPv6 is enabled, a second eth0 connection is sometimes not created and the ‘good’ IPv4 eth0 connection I created previously can connect, hopefully it should be possible somehow to have both IPv6 and IPv4 enabled system-wide without an invalid eth0 connection ever being created. Could NetworkManager be modified so that it does not create a connection if the DHCP client launched by NetworkManager does not obtain an IP address, for example?

This is not the end of the story, I’m sure.

For information, the services currently used are shown below:

meshedgedx fitzcarraldo # rc-status --all
Runlevel: nonetwork
Runlevel: shutdown
 killprocs                               [  stopped  ]
 savecache                               [  stopped  ]
 mount-ro                                [  stopped  ]
Runlevel: sysinit
 devfs                                   [  started  ]
 tmpfiles.dev                            [  started  ]
 sysfs                                   [  started  ]
 dmesg                                   [  started  ]
 udev                                    [  started  ]
Runlevel: boot
 hwclock                                 [  started  ]
 modules                                 [  started  ]
 device-mapper                           [  started  ]
 fsck                                    [  started  ]
 root                                    [  started  ]
 mtab                                    [  started  ]
 localmount                              [  started  ]
 sysctl                                  [  started  ]
 bootmisc                                [  started  ]
 termencoding                            [  started  ]
 keymaps                                 [  started  ]
 swapfiles                               [  started  ]
 ufw                                     [  started  ]
 procfs                                  [  started  ]
 dbus                                    [  started  ]
 tmpfiles.setup                          [  started  ]
 serial                                  [  started  ]
 hostname                                [  started  ]
 consolekit                              [  started  ]
 consolefont                             [  started  ]
 xdm                                     [  started  ]
 loopback                                [  started  ]
Runlevel: single
Runlevel: default
 swap                                    [  started  ]
 bluetooth                               [  started  ]
 syslog-ng                               [  started  ]
 sshd                                    [  started  ]
 fbcondecor                              [  started  ]
 atd                                     [  started  ]
 NetworkManager                          [  started  ]
 avahi-daemon                            [  started  ]
 cupsd                                   [  started  ]
 mdadm                                   [  started  ]
 acpid                                   [  started  ]
 nfsclient                               [  started  ]
 netmount                                [  started  ]
 alsasound                               [  started  ]
 laptop_mode                             [  started  ]
 cups-browsed                            [  started  ]
 hddtemp                                 [  started  ]
 mysql                                   [  started  ]
 nfs                                     [  started  ]
 samba                                   [  started  ]
 urandom                                 [  started  ]
 vixie-cron                              [  started  ]
 local                                   [  started  ]
Dynamic Runlevel: hotplugged
Dynamic Runlevel: needed
 rpcbind                                 [  started  ]
 rpc.statd                               [  started  ]
 rpc.pipefs                              [  started  ]
 rpc.idmapd                              [  started  ]
 xdm-setup                               [  started  ]
Dynamic Runlevel: manual
meshedgedx fitzcarraldo #

The allocations of services to runlevels are shown below:

meshedgedx fitzcarraldo # rc-update show -v
           NetworkManager |      default
 NetworkManagerDispatcher |
                    acpid |      default
                alsasound |      default
                  apache2 |
                      atd |      default
               atieventsd |
             avahi-daemon |      default
           avahi-dnsconfd |
                bluetooth |      default
                 bootmisc | boot
                   brltty |
             busybox-ntpd |
         busybox-watchdog |
                 cgconfig |
                    cgred |
                  cgroups |
                    clamd |
              consolefont | boot
               consolekit | boot
          courier-authlib |
                 cpupower |
             cups-browsed |      default
                    cupsd |      default
                     dbus | boot
                  deluged |
                    devfs |                                        sysinit
            device-mapper | boot
                      dgc |
                   dhcpcd |
                  dmcrypt |
                    dmesg |                                        sysinit
                 dmeventd |
                  dropbox |
                    eposd |
               fancontrol |
               fbcondecor |      default
                     fsck | boot
                     fuse |
               git-daemon |
                 gkrellmd |
                      gpm |
                     gpsd |
                  hddtemp |      default
                   hdparm |
          heimdal-kadmind |
              heimdal-kcm |
              heimdal-kdc |
         heimdal-kpasswdd |
                 hostname | boot
                   hsqldb |
                  hwclock | boot
                ip6tables |
                 iptables |
                   irexec |
                  keymaps | boot
                killprocs |                        shutdown
        kmod-static-nodes |
              laptop_mode |      default
                    lircd |
                   lircmd |
               lm_sensors |
                    local |      default
               localmount | boot
                 loopback | boot
                      lvm |
           lvm-monitoring |
                  lvmetad |
                    mdadm |      default
                   mdraid |
            microcode_ctl |
                  modules | boot
                 mount-ro |                        shutdown
                     mtab | boot
                multipath |
               multipathd |
                    mysql |      default
                      nas |
                  net.aol |
                 net.ath0 |
                 net.ath1 |
                 net.ath2 |
                 net.ath3 |
                 net.ath4 |
                 net.eth0 |
                 net.eth1 |
                 net.eth2 |
                 net.eth3 |
                 net.eth4 |
                 net.eth5 |
                 net.eth6 |
                 net.eth7 |
                 net.eth8 |
                   net.lo |
                 net.ppp0 |
                 net.ppp1 |
                 net.ppp2 |
                 net.ppp3 |
                  net.ra0 |
                  net.ra1 |
                  net.ra2 |
                  net.ra3 |
                  net.ra4 |
                  net.ra5 |
                net.wlan0 |
                net.wlan1 |
                net.wlan2 |
                net.wlan3 |
                 netmount |      default
                      nfs |      default
                nfsclient |      default
                 nfsmount |
               ntp-client |
  ntp-client.bak.20141013 |
                     ntpd |
                  numlock |
                  pciparm |
                  pktcdvd |
                   polipo |
                   procfs | boot
                  pwcheck |
                pydoc-2.7 |
                pydoc-3.2 |
                pydoc-3.3 |
                pydoc-3.4 |
              rename_ethX |
                   rfcomm |
                     root | boot
               rpc.idmapd |
               rpc.pipefs |
                rpc.statd |
                  rpcbind |
                rrdcached |
                   rsyncd |
                    samba |      default
                    saned |
                saslauthd |
                savecache |                        shutdown
                   serial | boot
                     slpd |
                   smartd |
                    snmpd |
                snmptrapd |
                     sntp |
                     sshd |      default
                 svnserve |
                     swap |      default
                swapfiles | boot
                  swclock |
                   sysctl | boot
                    sysfs |                                        sysinit
                syslog-ng |      default
    system-tools-backends |
             termencoding | boot
                 timidity |
             tmpfiles.dev |                                        sysinit
           tmpfiles.setup | boot
                      tor |
                   twistd |
                     udev |                                        sysinit
                      ufw | boot
                  urandom |      default
               vboxwebsrv |
               vixie-cron |      default
                     vpnc |
           wpa_supplicant |
                      xdm | boot
                xdm-setup |
                   xinetd |
meshedgedx fitzcarraldo #

My installation has the following six runlevels:

meshedgedx fitzcarraldo # ls /etc/runlevels
boot default nonetwork shutdown single sysinit

Getting Google Earth in Gentoo Linux to display Panoramio photos

Well, I decided to get Panoramio photos working in Google Earth installed using the hacked ebuild I posted in April 2014 (see my post Work-around if 64-bit Google Earth crashes in Gentoo Linux).

The modification devised by user amirpli (see Comment #9 in Gentoo Bugzilla Bug Report No. 490066) does not work in my case, as explained in detail in the above-mentioned April 2014 post. I believe this is because I am using the FGLRX video driver, as I have successfully applied amirpli‘s modification in an installation on a PC that has an Intel GPU.

Here is how I got Panoramio photos to display on my main laptop running the FGLRX driver, although my fix is yet another hack: I use 32-bit libraries downloaded from the Web. It works for me, though!


I am running Google Earth installed from a local overlay (see my above-mentioned April 2014 post) in KDE 4.14.3 under Gentoo Linux ~amd64 with the 3.17.1-gentoo-r1 kernel and FGLRX driver:

# eix ati-drivers
[I] x11-drivers/ati-drivers
     Available versions:
     (legacy) 13.1_pre897^td
     (1)    13.4^td 13.9^td 13.12^td 14.4_p1^td (~)14.6_beta2^td (~)14.9-r2^ftd (~)14.12-r2^td 14.12-r3^td
       {debug disable-watermark +modules multilib pax_kernel qt4 static-libs ABI_X86="32 64" KERNEL="linux"}
     Installed versions:  14.12-r3(1)^td(20:22:04 13/02/15)(modules qt4 -debug -pax_kernel -static-libs ABI_X86="32 64" KERNEL="linux")
     Homepage:            http://www.amd.com
     Description:         Ati precompiled drivers for Radeon Evergreen (HD5000 Series) and newer chipsets


1. Download into ~/Downloads/ the following Ubuntu 32-bit packages from http://packages.ubuntu.com/utopic/i386/libs/

$ ls -la *.deb
-rw-r--r-- 1 fitzcarraldo users  24060 Mar  1 23:59 libecore-imf1_1.8.6-2ubuntu1_i386.deb
-rw-r--r-- 1 fitzcarraldo users 274206 Mar  1 22:59 libfreeimage3_3.15.4-3build1_i386.deb
-rw-r--r-- 1 fitzcarraldo users  52154 Mar  1 23:45 libilmbase6_1.0.1-6.1_i386.deb
-rw-r--r-- 1 fitzcarraldo users 135300 Mar  2 00:28 libjasper1_1.900.1-debian1-2ubuntu0.2_i386.deb
-rw-r--r-- 1 fitzcarraldo users 106868 Mar  1 23:00 libjpeg-turbo8_1.3.0-0ubuntu2_i386.deb
-rw-r--r-- 1 fitzcarraldo users  98500 Mar  1 23:39 libopenjpeg5_1.5.2-2_i386.deb
-rw-r--r-- 1 fitzcarraldo users 189420 Mar  2 00:21 libraw10_0.16.0-6_i386.deb

2. Download into ~/Downloads/ the following 32-bit packages from http://rpmfind.net/linux/rpm2html/search.php and http://pkgs.org/

$ ls -la *.rpm
-rw-r--r-- 1 fitzcarraldo users  57976 Mar  2 00:13 libilmbase6-1.0.2-11.1.2.i586.rpm
-rw-r--r-- 1 fitzcarraldo users 148379 Mar  2 00:03 libilmimf6-1.6.1-alt9.i586.rpm

3. Extract into ~/Downloads/ the following 32-bit libraries from the above-mentioned .deb and .rpm packages:

$ ls -la lib*.so*
-rw-r--r-- 1 fitzcarraldo users 644568 Apr 27  2014 libfreeimage-3.15.4.so
-rw-r--r-- 1 fitzcarraldo users 677340 Apr 27  2014 libfreeimageplus-3.15.4.so
-rwxr-xr-x 1 fitzcarraldo users 271780 Jul 15  2012 libHalf.so.6.0.0
-rwxr-xr-x 1 fitzcarraldo users 104044 Jul 15  2012 libIex.so.6.0.0
-rw-r--r-- 1 fitzcarraldo users 671896 Dec  3 15:06 libIlmImf.so.6.0.0
-rwxr-xr-x 1 fitzcarraldo users  22260 Jul 15  2012 libIlmThread.so.6.0.0
-rw-r--r-- 1 fitzcarraldo users 342116 Jan 22 18:46 libjasper.so.1.0.0
-rw-r--r-- 1 fitzcarraldo users 300776 Dec 19  2013 libjpeg.so.8.0.2
-rw-r--r-- 1 fitzcarraldo users 142604 Apr 26  2014 libopenjpeg.so.1.5.2
-rw-r--r-- 1 fitzcarraldo users 657336 Jul 22  2014 libraw.so.10.0.0

4. Merge the 32-bit Google Earth package from a local overlay, using the ebuild listed in my above-mentioned April 2014 post:

# emerge -C googleearth
# rm -rf /opt/googleearth/
# emerge googleearth::local_overlay

5. Delete the four bundled Qt libs, compile the shim devised by user amirpli (see Comment #9 in Gentoo Bugzilla Bug Report No. 490066) but compile it for 32 bits (‘-m32‘), and edit the googleearth script to use the 32-bit libfreeimage.so.3 that you will copy into /opt/googleearth/ later:

# cd /opt/googleearth
# rm libQt*
# touch baifaao.cpp
# nano baifaao.cpp
# cat baifaao.cpp
/* amirpli 2013/11/28 */
#include <QtCore/QAtomicInt>
extern "C" {
        int _Z34QBasicAtomicInt_fetchAndAddOrderedPVii(QAtomicInt* a, int b) {
                return a->fetchAndAddOrdered(b);
# gcc -I/usr/include/qt4 -O3 -m32 -fPIC --shared baifaao.cpp -o baifaao.so
# nano googleearth
# tail googleearth

script_path=$(FindPath $0);

cd $script_path;

export LD_PRELOAD=/opt/googleearth/libfreeimage.so.3:/opt/googleearth/baifaao.so
export LC_NUMERIC=en_US.UTF-8 # Must do this if you are using non-US locale.

LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH ./googleearth-bin "$@"

6. Copy into the Google Earth directory all the libraries downloaded and extracted in Steps 1 to 3 above, and create the necessary symlinks and permissions:

# cd /opt/googleearth
# cp /home/fitzcarraldo/Downloads/libfreeimage-3.15.4.so .
# cp /home/fitzcarraldo/Downloads/libfreeimageplus-3.15.4.so .
# ln -s libfreeimage-3.15.4.so libfreeimage.so.3
# ln -s libfreeimage.so.3 libfreeimage.so
# ln -s libfreeimageplus-3.15.4.so libfreeimageplus.so.3
# ln -s libfreeimageplus.so.3 libfreeimageplus.so
# chmod +x libfreeimage-3.15.4.so
# chmod +x libfreeimageplus-3.15.4.so
# cp /home/fitzcarraldo/Downloads/libjpeg.so.8.0.2 .
# ln -s libjpeg.so.8.0.2 libjpeg.so
# ln -s libjpeg.so libjpeg.so.8
# chmod +x libjpeg.so.8.0.2
# cp /home/fitzcarraldo/Downloads/libopenjpeg.so.1.5.2 .
# ln -s libopenjpeg.so.1.5.2 libopenjpeg.so
# ln -s libopenjpeg.so libopenjpeg.so.5
# chmod +x libopenjpeg.so.1.5.2
# cp /home/fitzcarraldo/Downloads/libIlmImf.so.6.0.0 .
# ln -s libIlmImf.so.6.0.0 libIlmImf.so
# ln -s libIlmImf.so libIlmImf.so.6
# chmod +x libIlmImf.so.6.0.0
# cp /home/fitzcarraldo/Downloads/libHalf.so.6.0.0 .
# ln -s libHalf.so.6.0.0 libHalf.so
# ln -s libHalf.so libHalf.so.6
# chmod +x libHalf.so.6.0.0
# cp /home/fitzcarraldo/Downloads/libIex.so.6.0.0 .
# ln -s libIex.so.6.0.0 libIex.so
# ln -s libIex.so libIex.so.6
# chmod +x libIex.so.6.0.0
# cp /home/fitzcarraldo/Downloads/libraw.so.10.0.0 .
# ln -s libraw.so.10.0.0 libraw.so
# ln -s libraw.so libraw.so.10
# chmod +x libraw.so.10.0.0
# cp /home/fitzcarraldo/Downloads/libIlmThread.so.6.0.0 .
# ln -s libIlmThread.so.6.0.0 libIlmThread.so
# ln -s libIlmThread.so libIlmThread.so.6
# chmod +x libIlmThread.so.6.0.0
# cp /home/fitzcarraldo/Downloads/libjasper.so.1.0.0 .
# ln -s libjasper.so.1.0.0 libjasper.so
# ln -s libjasper.so libjasper.so.1
# chmod +x libjasper.so.1.0.0

Finally, launch Google Earth from your user account, not the root user’s account:

$ googleearth

Clicking on any photo icon in Google Earth should now display Panoramio photos.

If you click on a photo icon and the frame that opens displays several thumbnails, clicking on a thumbnail may result in a white Panoramio frame without any photo and thumbnails displayed. According to user amirpli this problem occurs in KDE but not GNOME. If it does happen in your case, to view the other photos right-click on a thumbnail and select ‘Open in New Window’. This way you will be able to view any of the photos.

It’s nice to be able to see the Panoramio photos again in Linux with the FGLRX driver.


Get every new post delivered to your Inbox.

Join 58 other followers