The problem of scanning using USB multi-function printers in Linux (success at last)

After my investigations described in a couple of earlier posts ([1], [2]), I finally got Gentoo Linux to scan reliably via the USB connection to my Canon MP560 MFP (multi-function peripheral), a single USB device with three interfaces: scanner (Interface 0); printer (Interface 1); mass storage (Interface 2). Well, ninety-nine per cent reliably, if that isn’t a contradiction in terms. The formula for success? I had to do all the following:

  1. Stop the kernel from binding the usb-storage driver to the device.

  2. Create a UDEV rule to modify the ACL (access control list) of the device to give both the ‘lp‘ and ‘scanner‘ groups Read-Write access to the device.

  3. Create a UDEV rule to: a) change the owner of the device from ‘root‘ to my user account (fitzcarraldo); b) change the device’s group to ‘scanner‘ instead of ‘lp‘; c) give all users Read-Write access to the device (see my note about this at the end of this post).

  4. Disable the SANE backend from accessing the MP560 via the network.

Let’s look in more detail at each of these …

Stop the kernel from binding the usb-storage driver to the device

Originally I had built the usb-storage driver into the kernel (CONFIG_USB_STORAGE=y). During the course of my investigations into this problem I rebuilt the kernel with CONFIG_USB_STORAGE=m, i.e. I rebuilt the driver as an external module, although it should not matter either way.

The vendor ID (04a9) and product ID (173e) of the MP560 can be found using the lsusb command:

# lsusb | grep -i canon
Bus 001 Device 007: ID 04a9:173e Canon, Inc. MP560

If the usb-storage driver is built as an external module, the kernel configuration file will include the following:

# grep CONFIG_USB_STORAGE= /usr/src/linux/.config
CONFIG_USB_STORAGE=m

In this case, it is possible to stop the driver binding to the USB storage interface in the MP560 by creating a ‘quirk’ in the file /etc/modprobe.d/usb-storage.conf as shown below:

# cat /etc/modprobe.d/usb-storage.conf
options usb-storage quirks=04a9:173e:i

If the usb-storage driver is built into the kernel, the kernel configuration file will include the following:

# grep CONFIG_USB_STORAGE= /usr/src/linux/.config
CONFIG_USB_STORAGE=y

In this case, it is possible to stop the driver binding to the USB storage interface in the MP560 by adding a ‘quirk’ (usb-storage.quirks=<idVendor>:<idProduct>:i) to the kernel boot line as shown below (ignore the rest of the parameters shown below, as yours are likely to be different):

# grep usb-storage /boot/grub/grub.cfg
linux /vmlinuz-3.18.11-gentoo root=/dev/sda5 ro drm_kms_helper.edid_firmware=edid/1920x1080_Clevo_W230SS.bin i915.modeset=1 rcutree.rcu_idle_gp_delay=1 usb-storage.quirks=04a9:173e:i

If you edit the file /boot/grub/grub.cfg directly, the change will be lost if you rebuild or upgrade in future. The ‘proper’ way to add the quirk would be to add it to the list of kernel boot parameters in GRUB_CMDLINE_LINUX_DEFAULT in the file /etc/default/grub and regenerate grub.cfg using the command ‘grub2-mkconfig -o /boot/grub/grub.cfg‘.

Create a UDEV rules file to modify the device’s ACL

I created a UDEV rules file /etc/udev/rules.d/95-libsane.rules containing the following:

# ACL settings for Canon PIXMA MP560 printer MFP
ATTR{idVendor}=="04a9", ATTR{idProduct}=="173e", GOTO="canon"
GOTO="canon_end"
 
LABEL="canon"
RUN+="/bin/setfacl -m g:scanner:rw -m g:lp:rw $env{DEVNAME}"
TEST=="/var/run/ConsoleKit/database", \
        RUN+="udev-acl --action=$env{ACTION} --device=$env{DEVNAME}"
 
LABEL="canon_end"

Create a UDEV rules file to change the owner, group and permissions of the device

The file 41-libsane.rules in my installation was the only UDEV rules file in the directory /lib/udev/rules.d/ that explicitly mentions the MP560:

# grep 173e /lib/udev/rules.d/*
/lib/udev/rules.d/41-libsane.rules:ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

As the USB device was always in the ‘lp‘ group (see the output of the ‘ls -la‘ command [1]), the above UDEV rule was clearly being overridden by another rule, but which one in the long list of rules files created automatically when I installed the OS and various packages (see below)?

# ls -F1 /lib/udev/rules.d/
10-ft-rockey.rules
10-virtualbox.rules
40-gentoo.rules
40-usb-media-players.rules
41-libsane.rules
42-usb-hid-pm.rules
50-udev-default.rules
56-hpmud.rules
60-block.rules
60-cdrom_id.rules
60-drm.rules
60-evdev.rules
60-persistent-alsa.rules
60-persistent-input.rules
60-persistent-storage-tape.rules
60-persistent-storage.rules
60-persistent-v4l.rules
60-serial.rules
61-accelerometer.rules
64-btrfs.rules
69-cd-sensors.rules
70-libgphoto2.rules
70-mouse.rules
70-printers.rules
70-touchpad.rules
70-udev-acl.rules
75-net-description.rules
75-probe_mtd.rules
77-mm-cinterion-port-types.rules
77-mm-ericsson-mbm.rules
77-mm-huawei-net-port-types.rules
77-mm-longcheer-port-types.rules
77-mm-mtk-port-types.rules
77-mm-nokia-port-types.rules
77-mm-pcmcia-device-blacklist.rules
77-mm-platform-serial-whitelist.rules
77-mm-simtech-port-types.rules
77-mm-telit-port-types.rules
77-mm-usb-device-blacklist.rules
77-mm-usb-serial-adapters-greylist.rules
77-mm-x22x-port-types.rules
77-mm-zte-port-types.rules
77-nm-olpc-mesh.rules
78-sound-card.rules
80-drivers.rules
80-mm-candidate.rules
80-net-name-slot.rules
80-udisks2.rules
85-regulatory.rules
90-alsa-restore.rules
90-libgpod.rules
90-network.rules
90-pulseaudio.rules
95-cd-devices.rules
95-upower-battery-recall-dell.rules
95-upower-battery-recall-fujitsu.rules
95-upower-battery-recall-gateway.rules
95-upower-battery-recall-ibm.rules
95-upower-battery-recall-lenovo.rules
95-upower-battery-recall-toshiba.rules
95-upower-csr.rules
95-upower-hid.rules
95-upower-wup.rules
97-hid2hci.rules
99-fuse.rules
99-ntfs3g.rules
99-nvidia.rules

Anyway, I created a UDEV rules file /etc/udev/rules.d/95-libsane.rules to change the owner of the MP560 USB device from ‘root‘ to me (i.e. user name ‘fitzcarraldo‘), to put the device in the ‘scanner‘ group instead of the ‘lp‘ group, and to give all users Read-Write permission for the device:

ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173e", MODE="0666", OWNER="fitzcarraldo", GROUP="scanner", ENV{libsane_matched}="yes"

So I now have two user-created UDEV rules files:

# ls /etc/udev/rules.d/
95-libsane.rules 99-canon-mp560.rules

Note that user-created UDEV rules files should be put in the directory /etc/udev/rules.d/, not the directory /lib/udev/rules.d/ which is reserved for UDEV rules installed when you install the OS and by packages you install later. Unfortunately, there is no consistency in UDEV rules file names and their contents between Linux distributions, which makes debugging UDEV rules even more difficult. Higher numbered rules files override lower-numbered rules files.

I then switched off the MP560 and switched it on again. The two UDEV rules files I created had worked as intended. The ownership and group of the device had changed, and so had the permissions and ACL:

# ls -la /dev/bus/usb/001
total 0
drwxr-xr-x  2 root         root       200 Jul 29 10:10 .
drwxr-xr-x  4 root         root        80 Jul 29 09:56 ..
crw-rw-r--  1 root         usb     189, 0 Jul 29 11:25 001
crw-rw-r--  1 root         usb     189, 1 Jul 29 09:56 002
crw-rw-r--  1 root         usb     189, 2 Jul 29 11:25 003
crw-rw-r--  1 root         usb     189, 3 Jul 29 09:56 004
crw-rw-r--  1 root         usb     189, 4 Jul 29 11:25 005
crw-rw-r--  1 root         usb     189, 5 Jul 29 11:25 006
crw-rw-r--  1 root         usb     189, 7 Jul 29 11:25 008
crw-rw-rw-+ 1 fitzcarraldo scanner 189, 8 Jul 29 11:27 009

# getfacl /dev/bus/usb/001/009
getfacl: Removing leading '/' from absolute path names
# file: dev/bus/usb/001/009
# owner: fitzcarraldo
# group: scanner
user::rw-
user:fitzcarraldo:rw-
group::rw-
group:lp:rw-
group:scanner:rw-
mask::rw-
other::rw-

Disable the SANE backend from accessing the MP560 via the network

Although scanning via the USB connection sometimes still works if I have also specified a network connection in the file /etc/sane.d/pixma.conf, apparently the two interfaces should not normally be enabled simultaneously. See Items 2 and 3 in the post [sane-devel] Error: Canon Pixma MG7550 hangs by SANE developer Rolf Bensch:

(1) Please try different frontends, if you have problems with scanning.
Some users reported problems with scanimage, but xsane is working.

(2) If you’re checking USB scanning, always switch off | disable |
disconnect all ethernet | WiFi connections from your scanner.

(3) If you’re checking ethernet | WiFi connection, always disconnect USB
from your scanner. And don’t mix ethernet and WiFi.

Therefore, to try using SANE to access the MP560 via USB, I disabled network access to the MP560 by commenting out the URI in the relevant SANE backend configuration file, which in the case of the MP560 is the file /etc/sane.d/pixma.conf. I commented out the line ‘bjnp://192.168.1.78‘ which I had previously inserted to enable me to scan via my home network because the USB connection was unreliable.

Trying to scan

I then checked if the USB-connected scanner is detected by SANE when running as root user and when running under my user account:

# scanimage -L
device `pixma:04A9173E_1653C4' is a CANON Canon PIXMA MP560 multi-function peripheral
# sane-find-scanner -q
found USB scanner (vendor=0x04a9 [Canon], product=0x173e [MP560 series]) at libusb:001:010
# exit
exit
$ scanimage -L
device `pixma:04A9173E_1653C4' is a CANON Canon PIXMA MP560 multi-function peripheral
$ sane-find-scanner -q
found USB scanner (vendor=0x04a9 [Canon], product=0x173e [MP560 series]) at libusb:001:010

The test using the scanimage command worked:

$ scanimage -d pixma:04A9173E_1653C4 -T
scanimage: scanning image of size 638x877 pixels at 24 bits/pixel
scanimage: acquiring RGB frame, 8 bits/sample
scanimage: reading one scanline, 1914 bytes...  PASS
scanimage: reading one byte...          PASS
scanimage: stepped read, 2 bytes...     PASS
scanimage: stepped read, 4 bytes...     PASS
scanimage: stepped read, 8 bytes...     PASS
scanimage: stepped read, 16 bytes...    PASS
scanimage: stepped read, 32 bytes...    PASS
scanimage: stepped read, 64 bytes...    PASS
scanimage: stepped read, 128 bytes...   PASS
scanimage: stepped read, 256 bytes...   PASS
scanimage: stepped read, 512 bytes...   PASS
scanimage: stepped read, 1024 bytes...  PASS
scanimage: stepped read, 2048 bytes...  PASS
scanimage: stepped read, 2047 bytes...  PASS
scanimage: stepped read, 1023 bytes...  PASS
scanimage: stepped read, 511 bytes...   PASS
scanimage: stepped read, 255 bytes...   PASS
scanimage: stepped read, 127 bytes...   PASS
scanimage: stepped read, 63 bytes...    PASS
scanimage: stepped read, 31 bytes...    PASS
scanimage: stepped read, 15 bytes...    PASS
scanimage: stepped read, 7 bytes...     PASS
scanimage: stepped read, 3 bytes...     PASS

So I tried to scan an A4 page from the command line:

$ scanimage -d pixma:04A9173E_1653C4 -l 0 -t 0 -x 215 -y 297 --resolution 150 --mode Color | convert - scanned-page.png

That worked, so I launched XSane, one of the GUI scanner applications:

$ xsane

That also worked.

Sometimes either scanimage or a GUI scanner application (XSane, gscan2pdf, Simple Scan or whatever) hangs, but, more often than not, scanning now works via the USB connection. However, if either scanimage or a GUI scanner application hangs, I kill them, run them again and then they usually work.

Importantly, printing still works, even though I have changed the USB device group from ‘lp‘ to ‘scanner‘.

So I have satisfied my curiosity and managed to get the MP560 to scan when connected to my laptop via USB, even though it already worked fine when using a network connection instead.

A note on the version of SANE

For information, I currently have Version 1.0.25_pre20150725 (daily snapshot from 25 July 2015) of the package sane-backends installed:

$ eix -I sane-backends
[I] media-gfx/sane-backends
     Available versions:  1.0.24-r5 (~)1.0.25_pre20150628 (~)1.0.25_pre20150725[1] {avahi doc gphoto2 ipv6 snmp systemd threads usb v4l xinetd ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32" SANE_BACKENDS="+abaton +agfafocus +apple +artec +artec_eplus48u +as6e +avision +bh +canon +canon630u +canon_dr -canon_pp +cardscan +coolscan +coolscan2 +coolscan3 +dc210 +dc240 +dc25 +dell1600n_net +dmc +epjitsu +epson +epson2 +fujitsu +genesys +gt68xx +hp +hp3500 +hp3900 +hp4200 +hp5400 +hp5590 +hpljm1005 -hpsj5s +hs2p +ibm +kodak +kodakaio +kvs1025 +kvs20xx kvs40xx +leo +lexmark +ma1509 +magicolor +matsushita +microtek +microtek2 +mustek -mustek_pp +mustek_usb mustek_usb2 +nec +net +niash +p5 +pie +pixma +plustek +plustek_pp -pnm +qcam +ricoh +rts8891 +s9036 +sceptre +sharp +sm3600 +sm3840 +snapscan +sp15c +st400 +stv680 +tamarack +teco1 +teco2 +teco3 +test +u12 +umax +umax1220u +umax_pp +xerox_mfp"}
     Installed versions:  1.0.25_pre20150725[1](01:39:24 25/07/15)(avahi gphoto2 ipv6 usb v4l -doc -snmp -systemd -threads -xinetd ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="32 64 -x32" SANE_BACKENDS="abaton agfafocus apple artec artec_eplus48u as6e avision bh canon canon630u canon_dr cardscan coolscan coolscan2 coolscan3 dc210 dc240 dc25 dell1600n_net dmc epjitsu epson epson2 fujitsu genesys gt68xx hp hp3500 hp3900 hp4200 hp5400 hp5590 hpljm1005 hs2p ibm kodak kodakaio kvs1025 kvs20xx leo lexmark ma1509 magicolor matsushita microtek microtek2 mustek mustek_usb nec net niash p5 pie pixma plustek plustek_pp qcam ricoh rts8891 s9036 sceptre sharp sm3600 sm3840 snapscan sp15c st400 stv680 tamarack teco1 teco2 teco3 test u12 umax umax1220u umax_pp xerox_mfp -canon_pp -hpsj5s -kvs40xx -mustek_pp -mustek_usb2 -pnm")
     Homepage:            http://www.sane-project.org/
     Description:         Scanner Access Now Easy - Backends

[1] "local_overlay" /usr/local/portage

However, the same symptoms occurred with versions 1.0.24-r5, 1.0.25_pre20150628 and 1.0.25_pre20150725 of the sane-backends package, so I believe the problem was not version-specific.

A note about scanning in Linux
An early developer’s Web site for the SANE pixma backend has the following warning:

If you grant a group a full permission to access the scanner (by using udev, hotplug, resmgr etc.), every members in the group will have full access rights not only for the scanner part but also for the other parts of the device i.e. printer, memory-card reader and fax. These users can bypass your system’s security policy and do everything with the device intentionally and unintentionally.

It is all very well to say that, but it is the only way I could get the backend to work reliably (almost). And, judging by the number of people who posted on the Web that they had to do the same with other Linux distributions, other manufacturers and models of MFPs, this is a common requirement in order to get Linux to work with MFP scanners. It’s not impressive when people have to resort to this to get something to work.

Note that the success of the approach described in this post is dependent on the contents and order of all the UDEV rules files. Just because the rules files I have posted above work in my case does not guarantee they will work in your case too. It depends what rules files your installation already has, what are their precise contents and in what order they are. In my opinion this is not a good concept.

I stand by my comments in the Conclusion of my first post regarding this problem. To have to jump through so many hoops to be able to scan using Linux on a computer connected to a MFP via USB is ridiculous in my opinion. The fact that it works reliably via a network connection does not alter that. I have been ‘scratching an itch’ as I enjoy tinkering, but I feel sorry for users who just need something that works without having to mess around for hours or days.

Background

  1. The problem of scanning using USB multi-function printers in Linux
  2. The problem of scanning using USB multi-function printers in Linux (continued)

The problem of scanning using USB multi-function printers in Linux (continued)

My previous post discussed the inability of the Linux installation on my main laptop to use the scanner of my Canon PIXMA MP560 MFP (multi-function peripheral) when they are connected via USB. Linux sees the MP560 as a single USB device with multiple interfaces: Interface 0 (scanner), Interface 1 (printer) and Interface 2 (USB mass storage). The basic problem seems to be that the usb-storage driver — whether built into the kernel or as an external module — claims the USB device and blocks access by userspace’s libusb, which is what the SANE backend (‘pixma‘, in the case of the MP560) uses to access the USB device. However, scanning works fine when using a network connection instead of the USB connection.

Attempts such as unbinding the usb-storage driver from the USB device — either manually or using a UDEV rule — in order to try and allow libusb/SANE to access the scanner, did not solve the problem. Although I can scan by connecting to the MP560 via my home network, the inability of the OS to scan via the USB interface piqued my interest, so I continued my investigations and below I discuss my latest findings.

Disabling kernel auto-binding

I learned from the interesting blog post Controlling USB device access on Linux how to stop the kernel automatically binding a driver to a USB device in the first place, as distinct from unbinding a driver after the kernel has bound it to a device. I thought this approach could be used to stop the usb-storage driver from binding to the MP560 and thus allow libusb/SANE to access Interface 0. The method using sysfs to stop the kernel binding the driver is to disable kernel USB auto-probing before launching a scanner application, by using the following command:

# echo 0 > /sys/bus/usb/drivers_autoprobe

This did indeed stop the kernel from automatically binding USB drivers to USB devices, but unfortunately libusb/SANE would still not access the MP560 scanner via USB. When drivers_autoprobe contains zero, applications such as XSane can use the network-connected MP560 as before, but still hang if the USB-connected MP560 is selected.

Unloading the usb-storage module

According to various blog and forum posts, some people have been able to use MFP scanners via USB after manually unloading the usb-storage module. I decided to try this. As I had built the kernel with the usb-storage driver internally rather than an external module, I first had to rebuild the kernel with CONFIG_USB_STORAGE=m instead of CONFIG_USB_STORAGE=y. Then I unloaded manually the usb_storage module using the command ‘rmmod usb_storage‘ and launched a scanner application, but the application still hung.

Disabling the usb-storage driver using a ‘quirk’

Then I had a thought: Perhaps there is a kernel ‘quirk’ to disable the usb-storage driver from binding to a specific USB device. Indeed there is (see Kernel Parameters or /usr/src/linux-<version>/Documentation/kernel-parameters.txt).

If the usb-storage driver is built into the kernel (CONFIG_USB_STORAGE=y), I would need to add the following kernel boot parameter to the kernel boot line:

usb-storage.quirks=04a9:173e:i

’04a9′ is the Vendor ID and ‘173e’ is the Product ID of the MP560. The ‘i‘ stands for ‘ignore’.

If the usb-storage driver is built as a kernel module (CONFIG_USB_STORAGE=m), I would need to create a file with a name such as /etc/modprobe.d/usb-storage.conf containing the following line:

options usb-storage quirks=04a9:173e:i

So I set up the quirk. Upon rebooting my laptop, the dmesg command reported the following:

usb 1-1.2.2: new high-speed USB device number 8 using ehci-pci
usb 1-1.2.2: New USB device found, idVendor=04a9, idProduct=173e
usb 1-1.2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.2.2: Product: MP560 series
usb 1-1.2.2: Manufacturer: Canon
usb 1-1.2.2: SerialNumber: 1653C4
usb-storage 1-1.2.2:1.2: USB Mass Storage device detected
usb-storage 1-1.2.2:1.2: device ignored

Notice the final line. The quirk does indeed cause the usb-storage driver to ignore the MP560.

The lsusb command still shows the device, which is a good sign:

# lsusb
Bus 002 Device 005: ID 0bc2:3300 Seagate RSS LLC
Bus 002 Device 004: ID 0411:01d9 BUFFALO INC. (formerly MelCo., Inc.)
Bus 002 Device 003: ID 05e3:0606 Genesys Logic, Inc. USB 2.0 Hub / D-Link DUB-H4 USB 2.0 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 006: ID 5986:055c Acer, Inc
Bus 001 Device 004: ID 8087:07dc Intel Corp.
Bus 001 Device 007: ID 0603:00f2 Novatek Microelectronics Corp. Keyboard (Labtec Ultra Flat Keyboard)
Bus 001 Device 008: ID 04a9:173e Canon, Inc. MP560
Bus 001 Device 005: ID 045e:00d1 Microsoft Corp. Optical Mouse with Tilt Wheel
Bus 001 Device 003: ID 05e3:0606 Genesys Logic, Inc. USB 2.0 Hub / D-Link DUB-H4 USB 2.0 Hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

# lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
        |__ Port 2: Dev 3, If 0, Class=Hub, Driver=hub/4p, 480M
            |__ Port 1: Dev 4, If 0, Class=Mass Storage, Driver=usb-storage, 480M
            |__ Port 3: Dev 5, If 0, Class=Mass Storage, Driver=usb-storage, 480M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
        |__ Port 2: Dev 3, If 0, Class=Hub, Driver=hub/4p, 480M
            |__ Port 1: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
            |__ Port 2: Dev 8, If 0, Class=Vendor Specific Class, Driver=usbfs, 480M
            |__ Port 2: Dev 8, If 1, Class=Printer, Driver=, 480M
            |__ Port 2: Dev 8, If 2, Class=Mass Storage, Driver=, 480M
            |__ Port 4: Dev 7, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
            |__ Port 4: Dev 7, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
        |__ Port 3: Dev 4, If 0, Class=Wireless, Driver=btusb, 12M
        |__ Port 3: Dev 4, If 1, Class=Wireless, Driver=btusb, 12M
        |__ Port 4: Dev 6, If 0, Class=Video, Driver=uvcvideo, 480M
        |__ Port 4: Dev 6, If 1, Class=Video, Driver=uvcvideo, 480M

The output of the lsusb -v -d 04a9:173e command applicable to the MP560 is as follows:

Bus 001 Device 008: ID 04a9:173e Canon, Inc. MP560
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x04a9 Canon, Inc.
  idProduct          0x173e MP560
  bcdDevice            0.04
  iManufacturer           1 Canon
  iProduct                2 MP560 series
  iSerial                 3 1653C4
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           85
    bNumInterfaces          3
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower                2mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0 
      bInterfaceProtocol    255 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x07  EP 7 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x88  EP 8 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x89  EP 9 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              11
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         7 Printer
      bInterfaceSubClass      1 Printer
      bInterfaceProtocol      2 Bidirectional
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk-Only
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x05  EP 5 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0001
  Self Powered

The USB device created at boot was as follows:

# ls -la /dev/bus/usb/001/008
crw-rw-r--+ 1 root lp 189, 7 Jul 24 11:01 /dev/bus/usb/001/008

Whether run by the root user or under my user account, the SANE tools detected the MP560 scanner network and USB connections:

$ scanimage -L
device `pixma:MP560_192.168.1.78' is a CANON Canon PIXMA MP560 multi-function peripheral
device `pixma:04A9173E' is a CANON Canon PIXMA MP560 multi-function peripheral

$ sane-find-scanner

  # sane-find-scanner will now attempt to detect your scanner. If the
  # result is different from what you expected, first make sure your
  # scanner is powered up and properly connected to your computer.

  # No SCSI scanners found. If you expected something different, make sure that
  # you have loaded a kernel SCSI driver for your SCSI adapter.

found USB scanner (vendor=0x04a9 [Canon], product=0x173e [MP560 series]) at libusb:001:008
  # Your USB scanner was (probably) detected. It may or may not be supported by
  # SANE. Try scanimage -L and read the backend's manpage.

  # Not checking for parallel port scanners.

  # Most Scanners connected to the parallel port or other proprietary ports
  # can't be detected by this program.

But scanner applications still hung! This time the message displayed by the dmesg command was:

usb 1-1.2.2: usbfs: interface 0 claimed by usbfs while 'scanimage' sets config #1

I unplugged the USB cable and plugged it in again. The output of the dmesg command was:

usb 1-1.2.2: USB disconnect, device number 8
usb 1-1.2.2: new high-speed USB device number 9 using ehci-pci
usb 1-1.2.2: New USB device found, idVendor=04a9, idProduct=173e
usb 1-1.2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.2.2: Product: MP560 series
usb 1-1.2.2: Manufacturer: Canon
usb 1-1.2.2: SerialNumber: 1653C4
usb-storage 1-1.2.2:1.2: USB Mass Storage device detected
usb-storage 1-1.2.2:1.2: device ignored

I then launched XSane several times and each time I was able to select either the MP560 via my home network (pixma:MP560_192.168.1.78) or via the USB cable (pixma:04A9173E_1653C4) and scan successfully.

By the way, it is possible to scan via the command line instead of using a GUI scanner application. For example, tjhe following command will scan an A4 page via the MP560’s USB connection (see man scanimage for details of the options):

$ scanimage -d pixma:04A9173E_1653C4 -l 0 -t 0 -x 215 -y 297 --resolution 150 --mode Color | convert - scanned-page.png

So the problem is solved, right? Wrong! For whatever reason, scanning via the USB interface is not guaranteed to work every time I boot the laptop. Sometimes scanner applications (and the scanimage command) hang if I select the USB interface; at other times they don’t hang and scanning works fine. If scanning using the USB device is not working, if I unplug and re-insert the USB cable a few times it becomes possible to scan using the USB interface. And once scanning via the USB interface does work, from then onwards it works consistently during that session.

I had been using Version 1.0.24-r5 of the sane-backends package in Gentoo Linux, which is the latest stable version according to the Gentoo package manager. To check if that particular version of the SANE pixma backend might be the cause of the problem I installed the latest version available in the Gentoo package manager (currently 1.0.5_pre20150625). However it made no discernable difference.

To sum up, in my case the most successful approach so far has been to use a kernel ‘quirk’ to force the usb-storage driver to ignore the device and not bind to it. However, this approach does not result in libusb/SANE being able to access the scanner during every boot session, but, if access is successful, it remains successful during the current session. Even if access via the USB interface does not work initially, sometimes I can get it to work by unplugging and re-inserting the USB cable.

UPDATE (July 30, 2015): I have now managed to get scanning to work with almost 100% reliability when connected to the MP560 via USB — see my latest post for details.

The problem of scanning using USB multi-function printers in Linux

Whilst searching the Web I have found many other people experiencing this problem, which I believe happens as a consequence of the way Linux is designed. Basically, if you have a multi-function peripheral that you connect to your computer via USB, the chances are that either scanning or printing will not work. The Web is littered with blog posts, forum threads, mailing list posts and bug reports regarding this phenomenon. There are numerous suggested fixes, usually entailing the addition or modification of udev rules. Sometimes the suggested fixes work; often they don’t. Linux can be a major hassle where peripherals are concerned.

I have a Canon Pixma MP560 MFP (multi-function printer/peripheral), which is a printer, scanner and copier. It also has memory card slots and a USB pen drive socket, to be able to store images directly from the scanner without the need to connect a computer. The MP560 provides two alternative means of connection to a computer: USB and Wi-Fi. I normally connect it via USB to my Clevo W230SS laptop running Gentoo Linux (amd64), but I can also connect it to the laptop via my home Wi-Fi network. Either connection method allows me to print, but I can scan only via the wireless connection.

The dmesg command displays the following messages after I plug a USB cable from the MP560 into my laptop:

usb 1-1.2.2: new high-speed USB device number 8 using ehci-pci
usb 1-1.2.2: New USB device found, idVendor=04a9, idProduct=173e
usb 1-1.2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.2.2: Product: MP560 series
usb 1-1.2.2: Manufacturer: Canon
usb 1-1.2.2: SerialNumber: 1653C4
usb-storage 1-1.2.2:1.2: USB Mass Storage device detected
scsi host6: usb-storage 1-1.2.2:1.2
scsi 6:0:0:0: Direct-Access     Canon    MP560 series     0104 PQ: 0 ANSI: 2
sd 6:0:0:0: Attached scsi generic sg1 type 0
sd 6:0:0:0: [sdb] Attached SCSI removable disk

Notice that the device also has some internal storage.

The lsusb command shows the device:

$ lsusb
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 006: ID 5986:055c Acer, Inc
Bus 001 Device 004: ID 8087:07dc Intel Corp.
Bus 001 Device 007: ID 0603:00f2 Novatek Microelectronics Corp. Keyboard (Labtec Ultra Flat Keyboard)
Bus 001 Device 009: ID 04a9:173e Canon, Inc. MP560
Bus 001 Device 005: ID 045e:00d1 Microsoft Corp. Optical Mouse with Tilt Wheel
Bus 001 Device 003: ID 05e3:0606 Genesys Logic, Inc. USB 2.0 Hub / D-Link DUB-H4 USB 2.0 Hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

My Linux user account is in the lp and scanner groups:

$ groups
disk lp wheel floppy uucp cron audio cdrom video games cdrw usb users plugdev crontab wireshark vboxusers scanner fitzcarraldo

The device is in the lp group and I can print without any trouble:

$ ls -la /dev/bus/usb/001/009
crw-rw-r--+ 1 root lp 189, 8 Jun 19 02:55 /dev/bus/usb/001/009

The usblp driver, a common cause of problems with USB printers, does not exist because I purposely did not set CONFIG_USB_PRINTER when I built the kernel, specifically to avoid such problems:

$ grep CONFIG_USB_PRINTER /usr/src/linux/.config
# CONFIG_USB_PRINTER is not set

so, obviously, the usblp driver is neither built into the kernel nor compiled as a module:

$ lsmod | grep usb
btusb                  22292  0
bluetooth             281605  27 bnep,hidp,btusb,rfcomm

I have the latest stable versions of the udev-related packages installed (as you can see below, I use eudev instead of udev):

$ eix -I udev
[I] dev-python/pyudev
     Available versions:  0.16.1-r1 {pygobject pyqt4 pyside test PYTHON_TARGETS="python2_7 python3_3 python3_4"}
     Installed versions:  0.16.1-r1(03:32:17 18/04/15)(pyqt4 -pygobject -pyside -test PYTHON_TARGETS="python2_7 python3_3 -python3_4")
     Homepage:            http://pyudev.readthedocs.org https://github.com/pyudev/pyudev
     Description:         Python binding to libudev

[I] sys-fs/eudev
     Available versions:  *1.3 *1.5.3-r1 1.9-r2 1.10-r2 ~2.1.1 ~3.0 3.1.2 ~3.1.2-r10 **9999 {doc gudev (+)hwdb introspection (+)keymap (+)kmod +modutils +openrc +rule-generator selinux static-libs test ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32"}
     Installed versions:  3.1.2(19:44:12 16/07/15)(gudev hwdb introspection kmod -doc -selinux -static-libs -test ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="32 64 -x32")
     Homepage:            https://github.com/gentoo/eudev
     Description:         Linux dynamic and persistent device naming support (aka userspace devfs)

[I] sys-fs/udev-init-scripts
     Available versions:  27^t [M]~29^t ~30^t **9999^t
     Installed versions:  27^t(05:29:06 09/04/15)
     Homepage:            http://www.gentoo.org
     Description:         udev startup scripts for openrc

[I] virtual/libgudev
     Available versions:  215-r1(0/0) 215-r2(0/0) 215-r3(0/0) ~230(0/0) {introspection static-libs systemd ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32"}
     Installed versions:  215-r3(10:18:16 11/06/15)(introspection -static-libs -systemd ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="64 -32 -x32")
     Description:         Virtual for libgudev providers

[I] virtual/libudev
     Available versions:  215-r1(0/1) {static-libs systemd ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32"}
     Installed versions:  215-r1(17:51:42 18/04/15)(-static-libs -systemd ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="32 64 -x32")
     Description:         Virtual for libudev providers

[I] virtual/udev
     Available versions:  215 ~217 {systemd}
     Installed versions:  215(05:28:55 09/04/15)(-systemd)
     Description:         Virtual to select between different udev daemon providers

Found 6 matches.

I have the latest stable SANE-related packages installed:

$ eix -I sane
[I] dev-perl/Sane
     Available versions:  (~)0.50.0-r1 {test}
     Installed versions:  0.50.0-r1(17:39:10 23/06/15)(-test)
     Homepage:            http://search.cpan.org/dist/Sane/
     Description:         The Sane module allows you to access SANE-compatible scanners in a Perl

[I] kde-apps/ksaneplugin
     Available versions:  (4) 4.14.3(4/4.14)
       {aqua debug}
     Installed versions:  4.14.3(4)(14:13:01 17/04/15)(-aqua -debug)
     Homepage:            http://www.kde.org/
     Description:         SANE Plugin for KDE

[I] kde-apps/libksane
     Available versions:  (4) 4.14.3(4/4.14)
       {aqua debug}
     Installed versions:  4.14.3(4)(13:55:44 17/04/15)(-aqua -debug)
     Homepage:            http://www.kde.org/
     Description:         SANE Library interface for KDE

[I] media-gfx/sane-backends
     Available versions:  1.0.24-r5 ~1.0.25_pre20150628 {avahi doc gphoto2 ipv6 snmp systemd threads usb v4l xinetd ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32" SANE_BACKENDS="+abaton +agfafocus +apple +artec +artec_eplus48u +as6e +avision +bh +canon +canon630u +canon_dr -canon_pp +cardscan +coolscan +coolscan2 +coolscan3 +dc210 +dc240 +dc25 +dell1600n_net +dmc +epjitsu +epson +epson2 +fujitsu +genesys +gt68xx +hp +hp3500 +hp3900 +hp4200 +hp5400 +hp5590 +hpljm1005 -hpsj5s +hs2p +ibm +kodak +kodakaio +kvs1025 +kvs20xx kvs40xx +leo +lexmark +ma1509 +magicolor +matsushita +microtek +microtek2 +mustek -mustek_pp +mustek_usb mustek_usb2 +nec +net +niash +p5 +pie +pixma +plustek +plustek_pp -pnm +qcam +ricoh +rts8891 +s9036 +sceptre +sharp +sm3600 +sm3840 +snapscan +sp15c +st400 +stv680 +tamarack +teco1 +teco2 +teco3 +test +u12 +umax +umax1220u +umax_pp +xerox_mfp"}
     Installed versions:  1.0.24-r5(17:55:11 18/04/15)(avahi gphoto2 ipv6 usb v4l -doc -snmp -systemd -threads -xinetd ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="32 64 -x32" SANE_BACKENDS="abaton agfafocus apple artec artec_eplus48u as6e avision bh canon canon630u canon_dr cardscan coolscan coolscan2 coolscan3 dc210 dc240 dc25 dell1600n_net dmc epjitsu epson epson2 fujitsu genesys gt68xx hp hp3500 hp3900 hp4200 hp5400 hp5590 hpljm1005 hs2p ibm kodak kodakaio kvs1025 kvs20xx leo lexmark ma1509 magicolor matsushita microtek microtek2 mustek mustek_usb nec net niash p5 pie pixma plustek plustek_pp qcam ricoh rts8891 s9036 sceptre sharp sm3600 sm3840 snapscan sp15c st400 stv680 tamarack teco1 teco2 teco3 test u12 umax umax1220u umax_pp xerox_mfp -canon_pp -hpsj5s -kvs40xx -mustek_pp -mustek_usb2 -pnm")
     Homepage:            http://www.sane-project.org/
     Description:         Scanner Access Now Easy - Backends

[I] media-gfx/sane-frontends
     Available versions:  1.0.14 {gimp}
     Installed versions:  1.0.14(19:47:50 18/06/15)(gimp)
     Homepage:            http://www.sane-project.org
     Description:         Scanner Access Now Easy

[I] media-gfx/xsane
     Available versions:  0.999-r1 {gimp jpeg lcms nls ocr png tiff}
     Installed versions:  0.999-r1(12:03:12 19/04/15)(gimp jpeg lcms nls png tiff -ocr)
     Homepage:            http://www.xsane.org/
     Description:         graphical scanning frontend

Found 6 matches.

The following SANE backends were installed when I installed SANE:

$ ls -F1 /etc/sane.d/ | columns -c 3 -w 20
abaton.conf         agfafocus.conf      apple.conf
artec.conf          artec_eplus48u.conf avision.conf
bh.conf             canon.conf          canon630u.conf
canon_dr.conf       cardscan.conf       coolscan.conf
coolscan2.conf      coolscan3.conf      dc210.conf
dc240.conf          dc25.conf           dell1600n_net.conf
dll.conf            dll.d/              dmc.conf
epjitsu.conf        epson.conf          epson2.conf
fujitsu.conf        genesys.conf        gphoto2.conf
gt68xx.conf         hp.conf             hp3900.conf
hp4200.conf         hp5400.conf         hs2p.conf
ibm.conf            kodak.conf          kodakaio.conf
leo.conf            lexmark.conf        ma1509.conf
magicolor.conf      matsushita.conf     microtek.conf
microtek2.conf      mustek.conf         mustek_usb.conf
nec.conf            net.conf            p5.conf
pie.conf            pixma.conf          plustek.conf
plustek_pp.conf     qcam.conf           ricoh.conf
rts8891.conf        s9036.conf          saned.conf
sceptre.conf        sharp.conf          sm3840.conf
smfp.conf           snapscan.conf       sp15c.conf
st400.conf          stv680.conf         tamarack.conf
teco1.conf          teco2.conf          teco3.conf
test.conf           u12.conf            umax.conf
umax1220u.conf      umax_pp.conf        v4l.conf
xerox_mfp.conf

I checked all the SANE backend configuration files, and none of them mention the MP560 (I was not expecting them to mention it, as, according to man sane-pixma, the pixma backend detects Canon PIXMA USB devices automatically):

$ grep -rnwi /etc/sane.d/ -e "173e"
$

The SANE file dll.conf does list the pixma backend configuration file which is only for declaring networked Canon PIXMA devices, as the pixma backend detects Canon USB devices automatically):

$ grep pixma /etc/sane.d/dll.conf
pixma

$ cat /etc/sane.d/pixma.conf
# pixma.conf configuration for the sane pixma backend
#
# define URI's of scanners (one per line)
# This is only used for network scanners.
# normally scanners will be detected by sending a broadcast
# if this does not work under your OS, or if the scanners
# are on a different subnet, configure your scanners URI here
#
# method must be bjnp
# port number can normally be left out, port 8612 is used as default
# Example:
# bjnp://myscanner.my.domain:8612
# bjnp://printer-1.pheasant.org
#

I don’t think it is even used these days, but the file /etc/hotplug/usb/libsane.usermap already includes the device:

# Canon PIXMA MP560
libusbscanner 0x0003 0x04a9 0x173e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000

The file /lib64/udev/rules.d/41-libsane.rules already includes the device:

# Canon PIXMA MP560
ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

However, scanning from Linux via USB is a troubled affair. Very occasionally the scanner application (XSane, Simple Scan, gscan2pdf, or whatever) will launch and the scanner works, but usually the scanner application just hangs and the dmesg command shows one or more error messages such as the following:

usb 1-1.2.2: usbfs: interface 2 claimed by usb-storage while 'xsane' sets config #1

usb 1-1.2.2: usbfs: interface 2 claimed by usb-storage while 'gscan2pdf' sets config #1

I have USB mass storage support enabled in the kernel so that my laptop can access external USB mass storage devices:

$ grep CONFIG_USB_STORAGE= /usr/src/linux/.config
CONFIG_USB_STORAGE=y

As the three interfaces (printer, scanner and internal storage) are all accessed as a single USB device (/dev/bus/usb/001/009, or whatever), there appears to be a conflict between the kernel claiming the MFP’s internal mass storage and SANE trying to access the scanner. I do not want to disable the kernel’s USB mass storage support (not even by rebuilding the kernel with CONFIG_USB_STORAGE=m and temporarily unloading manually the usb-storage module, as some people suggest), as I would not be able to access my external USB mass storage devices.

The scanimage and sane-find-scanner utilities detect the scanner correctly via USB:

$ scanimage -L
device `v4l:/dev/video0' is a Noname BisonCam, NB Pro virtual device
device `pixma:04A9173E_1653C4' is a CANON Canon PIXMA MP560 multi-function peripheral

(The BisonCam is the Webcam built into my laptop.)

$ sane-find-scanner

  # sane-find-scanner will now attempt to detect your scanner. If the
  # result is different from what you expected, first make sure your
  # scanner is powered up and properly connected to your computer.

  # No SCSI scanners found. If you expected something different, make sure that
  # you have loaded a kernel SCSI driver for your SCSI adapter.

found USB scanner (vendor=0x04a9 [Canon], product=0x173e [MP560 series]) at libusb:001:009
  # Your USB scanner was (probably) detected. It may or may not be supported by
  # SANE. Try scanimage -L and read the backend's manpage.

  # Not checking for parallel port scanners.

  # Most Scanners connected to the parallel port or other proprietary ports
  # can't be detected by this program.

  # You may want to run this program as root to find all devices. Once you
  # found the scanner devices, be sure to adjust access permissions as
  # necessary.

The scanimage test commands do not indicate any problem:

$ scanimage -d test -T
scanimage: scanning image of size 157x196 pixels at 8 bits/pixel
scanimage: acquiring gray frame, 8 bits/sample
scanimage: reading one scanline, 157 bytes...   PASS
scanimage: reading one byte...          PASS
scanimage: stepped read, 2 bytes...     PASS
scanimage: stepped read, 4 bytes...     PASS
scanimage: stepped read, 8 bytes...     PASS
scanimage: stepped read, 16 bytes...    PASS
scanimage: stepped read, 32 bytes...    PASS
scanimage: stepped read, 64 bytes...    PASS
scanimage: stepped read, 128 bytes...   PASS
scanimage: stepped read, 256 bytes...   PASS
scanimage: stepped read, 255 bytes...   PASS
scanimage: stepped read, 127 bytes...   PASS
scanimage: stepped read, 63 bytes...    PASS
scanimage: stepped read, 31 bytes...    PASS
scanimage: stepped read, 15 bytes...    PASS
scanimage: stepped read, 7 bytes...     PASS
scanimage: stepped read, 3 bytes...     PASS

$ scanimage -d pixma -T
scanimage: scanning image of size 638x877 pixels at 24 bits/pixel
scanimage: acquiring RGB frame, 8 bits/sample
scanimage: reading one scanline, 1914 bytes...  PASS
scanimage: reading one byte...          PASS
scanimage: stepped read, 2 bytes...     PASS
scanimage: stepped read, 4 bytes...     PASS
scanimage: stepped read, 8 bytes...     PASS
scanimage: stepped read, 16 bytes...    PASS
scanimage: stepped read, 32 bytes...    PASS
scanimage: stepped read, 64 bytes...    PASS
scanimage: stepped read, 128 bytes...   PASS
scanimage: stepped read, 256 bytes...   PASS
scanimage: stepped read, 512 bytes...   PASS
scanimage: stepped read, 1024 bytes...  PASS
scanimage: stepped read, 2048 bytes...  PASS
scanimage: stepped read, 2047 bytes...  PASS
scanimage: stepped read, 1023 bytes...  PASS
scanimage: stepped read, 511 bytes...   PASS
scanimage: stepped read, 255 bytes...   PASS
scanimage: stepped read, 127 bytes...   PASS
scanimage: stepped read, 63 bytes...    PASS
scanimage: stepped read, 31 bytes...    PASS
scanimage: stepped read, 15 bytes...    PASS
scanimage: stepped read, 7 bytes...     PASS
scanimage: stepped read, 3 bytes...     PASS

As mentioned earlier, the udev/eudev rules file appears to contain a valid rule for the scanner:

# Canon PIXMA MP560
ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

Notice the rule assigns the device’s group to be ‘scanner‘, not ‘lp‘, although changing the group assignment to ‘lp‘ in the rule makes no discernable difference to the scanning problem in my case. As the device’s group is actually ‘lp‘, I assume another rule overrides this rule, but I have no idea which rule it is and in which rules file it occurs.

Occasionally I am lucky and scanning does work, but, more often than not, scanner applications cannot access the scanner and just hang.

A work-around if the peripheral also has a network interface

I configured my home network router always to use the IP address 192.168.1.78 for the MP560 and I added the following line to the file /etc/sane.d/pixma.conf in order to be able to scan via Wi-Fi instead of USB (I have the package cups-bjnp installed for printing purposes, but I am not sure if that package is also needed by SANE in this case):

bjnp://192.168.1.78

With the above line added to /etc/sane.d/pixma.conf the scanimage utility detects the scanner correctly via both the Wi-Fi connection and the USB interface:

$ scanimage -L
device `v4l:/dev/video0' is a Noname BisonCam, NB Pro virtual device
device `pixma:MP560_192.168.1.78' is a CANON Canon PIXMA MP560 multi-function peripheral
device `pixma:04A9173E_1653C4' is a CANON Canon PIXMA MP560 multi-function peripheral

So, as I usually cannot get scanning to work via USB, I can scan via Wi-Fi instead. It’s a work-around, not a solution, but at least by doing that I can scan reliably as well as print. Of course you can’t use such a work-around if you have a model of MFP that only provides a USB connection.

Failed experiments

Experiment 1

I also tried unbinding the usb-storage driver from the usb device:

# ls /sys/bus/usb/drivers
btusb hub usb usb-storage usbfs usbhid uvcvideo
# ls /sys/bus/usb/drivers/btusb/
1-1.3:1.0 1-1.3:1.1 bind module new_id remove_id uevent unbind
# ls /sys/bus/usb/drivers/hub
1-0:1.0 1-1.2:1.0 1-1:1.0 2-0:1.0 2-1:1.0 bind module new_id remove_id uevent unbind
# ls /sys/bus/usb/drivers/usb
1-1 1-1.2 1-1.2.1 1-1.2.2 1-1.2.4 1-1.3 1-1.4 2-1 bind uevent unbind usb1 usb2
# ls /sys/bus/usb/drivers/usb-storage/
1-1.2.2:1.2 bind module new_id remove_id uevent unbind
# ls /sys/bus/usb/drivers/usbfs
bind module new_id remove_id uevent unbind
# ls /sys/bus/usb/drivers/usbhid
1-1.2.1:1.0 1-1.2.4:1.0 1-1.2.4:1.1 bind module new_id remove_id uevent unbind
# ls /sys/bus/usb/drivers/uvcvideo
1-1.4:1.0 1-1.4:1.1 bind module new_id remove_id uevent unbind
# tree /sys/bus/usb/drivers/usb-storage/
/sys/bus/usb/drivers/usb-storage/
├── 1-1.2.2:1.2 -> ../../../../devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.2/1-1.2.2:1.2
├── bind
├── module -> ../../../../module/usb_storage
├── new_id
├── remove_id
├── uevent
└── unbind

2 directories, 5 files
# echo -n "1-1.2.2:1.2" > /sys/bus/usb/drivers/usb-storage/unbind
# tree /sys/bus/usb/drivers/usb-storage/
/sys/bus/usb/drivers/usb-storage/
├── bind
├── module -> ../../../../module/usb_storage
├── new_id
├── remove_id
├── uevent
└── unbind

1 directory, 5 files
# tree /sys/bus/usb/devices/1-1.2.2:1.2
/sys/bus/usb/devices/1-1.2.2:1.2
├── bAlternateSetting
├── bInterfaceClass
├── bInterfaceNumber
├── bInterfaceProtocol
├── bInterfaceSubClass
├── bNumEndpoints
├── ep_05
│   ├── bEndpointAddress
│   ├── bInterval
│   ├── bLength
│   ├── bmAttributes
│   ├── direction
│   ├── interval
│   ├── power
│   ├── type
│   ├── uevent
│   └── wMaxPacketSize
├── ep_84
│   ├── bEndpointAddress
│   ├── bInterval
│   ├── bLength
│   ├── bmAttributes
│   ├── direction
│   ├── interval
│   ├── power
│   ├── type
│   ├── uevent
│   └── wMaxPacketSize
├── modalias
├── power
├── subsystem -> ../../../../../../../../bus/usb
├── supports_autosuspend
└── uevent

6 directories, 27 files

After unbinding the usb-storage driver from the USB device, no more messages such as ‘usbfs: interface 2 claimed by usb-storage while 'xsane' sets config #1‘ are added to /var/log/messages when I launch a scanner application and select the USB device, but the scanner application still hangs (e.g. the XSane windows do not appear until I switch off the MP560 or unplug the USB cable). This happens irrespective of whether the USB device permissions are:

# ls -la /dev/bus/usb/001/009
crw-rw-r--+ 1 root lp 189, 8 Jul 20 20:35 /dev/bus/usb/001/009

or:

# ls -la /dev/bus/usb/001/009
crw-rw-r--+ 1 fitzcarraldo lp 189, 8 Jul 20 20:35 /dev/bus/usb/001/009

or:

# ls -la /dev/bus/usb/001/009
crw-rw-r--+ 1 fitzcarraldo scanner 189, 8 Jul 20 20:51 /dev/bus/usb/001/009

To reiterate, neither unbinding the usb-storage driver from the USB device first nor changing the owner and group of the USB device solves the problem. So possibly the problem is not caused by udev or by a USB driver, but by the SANE software.

Experiment 2

I found a thread in the SANE developers’ mailing list about the same problem with a different model of MFP: Help needed diagnosing strange failure to scan with Samsung SCX-4500W. The same user posted the same query in the Arch Linux forums: [SOLVED] Samsung SCX4500W MFP can’t get scanner to work. Like my Canon PIXMA MP560, that MFP has more than one interface in a single USB device. Notice in the Arch Linux thread that the user never found a solution and finally adopted the same work-around I use, namely to scan via a network interface rather than via the USB interface.

Theodore Kilgore gives a good explanation in that SANE developers’ mailing list thread of why the problem occurs in Linux, and Thorsten Müller’s post suggests a udev rule that sets the permissions for the MFP so that SANE, CUPS and logged-in users can all access the USB device. All I had to do was replace references to Samsung (such as the vendor ID and product ID) with those for my Canon PIXMA MP560. I left everything else in my installation exactly the way it was (for example I did not touch /lib64/udev/rules.d/41-libsane.rules and /lib64/udev/rules.d/70-printers.rules). The only thing I did was to add a udev rules file /etc/udev/rules.d/99-canon-mp560.rules with the following contents:

# ACL settings for Canon PIXMA MP560 printer MFP
ATTR{idVendor}=="04a9", ATTR{idProduct}=="173e", GOTO="canon"
GOTO="canon_end"

LABEL="canon"
RUN+="/bin/setfacl -m g:scanner:rw -m g:lp:rw $env{DEVNAME}"
TEST=="/var/run/ConsoleKit/database", \
        RUN+="udev-acl --action=$env{ACTION} --device=$env{DEVNAME}"

LABEL="canon_end"

Both /bin/setfacl and /var/run/ConsoleKit/database exist in my installation, and, as shown earlier, my user account is a member of both the lp and scanner groups. After adding the above file, I rebooted and it appears the rule works as intended:

# getfacl /dev/bus/usb/001/009
getfacl: Removing leading '/' from absolute path names
# file: dev/bus/usb/001/009
# owner: root
# group: lp
user::rw-
user:fitzcarraldo:rw-
group::rw-
group:lp:rw-
group:scanner:rw-
mask::rw-
other::r--

However, although I was still able to print I still could not scan. Mind you, the line beginning ‘TEST==‘ in the file /etc/udev/rules.d/99-canon-mp560.rules is also in the file /lib64/udev/rules.d/70-udev-acl.rules, but I’m no expert in udev rules, which are frankly beyond the ability of most users.

Experiment 3

I found a blog post about the same problem but with a Canon MP210 MFP: Canon multifunction printer: getting the printer drivers and scanner to work in debian/ubuntu/mint. This post suggested creating a udev rule file /etc/udev/rules.d/40-scanner-permissions.rules containing the following:

# usb scanner
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE:="0666"
SUBSYSTEM=="usb_device",MODE:="0666"

but, although the rule appears to work as intended, it is still not possible to scan in my case. I then changed the file name to /etc/udev/rules.d/95-scanner-permissions.rules, but that made no difference in my case.

Experiment 4

I also tried changing MODE="0664" to MODE="0666" in the following line in the file /lib64/udev/rules.d/50-udev-default.rules but that made no difference either:

SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664"

Experiment 5

I am able to change the group of the USB device to ‘scanner‘ instead of ‘lp‘ by adding a rules file /lib64/udev/rules.d/99-canon.rules (apparently 41-libsane.rules does not work as intended because it is overruled by a higher-numbered file, but I have no idea which one, as 41-libsane.rules is the only one explicitly mentioning the MP560) containing the following:

ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

But scanning still does not work, whether or not I unbind the usb-storage driver from the USB device first and whether or not I change the owner and group of the USB device to root:lp, root:scanner, fitzcarraldo:lp or fitzcarraldo:scanner.

Conclusion

Although my installation can print via USB, scanning via USB does not work, whether or not the usb-storage driver is bound to the USB device and whoever is the owner and group of the USB device. So it could be that the problem is not caused by udev or by the kernel (a USB driver), but by the SANE software itself. However, I think it is more likely to be some sort of contention between kernel and userspace, despite unbinding the usb-storage driver from the device. Although I’m not excluding the possibility of a bug in SANE, irrespective of that it seems to me that the way GNU/Linux handles multiple interfaces of a single USB device is flawed. The udev design results in a morass of confusing and potentially conflicting rules in umpteen files in different directories, and the apparently uncoordinated independent demands on the same USB interface by the kernel and userspace are another potential source of problems. There is no standardisation in the udev rules files and their contents between the different Linux distributions, making investigation and solution of such problems even more complicated. Having to resort to work-arounds such as scanning via a network interface or scanning to a USB pen drive or memory card is a poor way of circumventing the problem, and is of no help anyway if a multi-function peripheral does not have a network interface, pen drive socket or memory card slot.

UPDATE (July 24, 2015): I have tried some other approaches, and had more success using a ‘quirk’ for the usb-storage driver — see my next post for details.

Addendum: How to stop scanning applications detecting a Webcam

By the way, to stop XSane and other scanning applications detecting my Webcam via the Video for Linux SANE backend, I commented out all the device lines in the file /etc/sane.d/v4l.conf like so:

$ cat
# In order to use the v4linux backend you have to give the device
# You can enable multiple lines if
# you really have multible v4l devices.
#
#/dev/bttv0
#/dev/video0
#/dev/video1
#/dev/video2
#/dev/video3

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:

#!/bin/bash
echo
echo "Your installation is currently configured to use the following graphics processor:"
echo
GPU=`eselect opengl list | grep \* | awk '{ print $2 }'`
if [ "$GPU" = "xorg-x11" ]; then
  echo "Intel HD 4600 Integrated Graphics Processor"
  echo
  echo "You do not need to do anything. Please close this window."
elif [ "$GPU" = "nvidia" ]; then
  echo "NVIDIA GeForce GTX 860M"
  echo
  echo "This script will configure your installation to use the"
  echo "Intel HD 4600 Integrated Graphics Controller all the time."
  echo
  echo "Enter your own password."
  echo
  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
  echo "Now you should logout to restart X Windows."
fi

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

#!/bin/bash
echo
echo "Your installation is currently configured to use the following graphics processor:"
echo
GPU=`eselect opengl list | grep \* | awk '{ print $2 }'`
if [ "$GPU" = "nvidia" ]; then
  echo "NVIDIA GeForce GTX 860M"
  echo
  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
  echo "This script will configure your installation to use the NVIDIA GeForce GTX 860M GPU all the time."
  echo
  echo "Enter your own password."
  echo
  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
  echo "Now you should logout to restart X Windows."
fi

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" 
EndSection

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

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

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

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

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

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

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

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
Exec=/home/fitzcarraldo/intel.sh
GenericName[en_GB]=Configure your installation to use Intel HD Graphics
GenericName=Configure your installation to use Intel HD Graphics
Icon=/home/fitzcarraldo/Pictures/Icons/intel_hd_graphics_icon.png
MimeType=
Name[en_GB]=Intel HD Graphics
Name=Intel HD Graphics
Path=
StartupNotify=true
Terminal=true
TerminalOptions=\s--noclose
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=fitzcarraldo

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
Exec=/home/fitzcarraldo/nvidia.sh
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
Icon=/home/fitzcarraldo/Pictures/Icons/nvidia_icon.png
MimeType=
Name[en_GB]=NVIDIA GPU
Name=NVIDIA GPU
Path=
StartupNotify=true
Terminal=true
TerminalOptions=\s--noclose
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=fitzcarraldo

Don’t forget to make all the Bash script files and .desktop files executable. All I have to do is double-click on either icon on the Desktop 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.

Computer memories

Please forgive the double entendre in the title but, for my one-hundredth post, I thought I would reminisce about the calculating and computing equipment I have used over the years, and the amazing changes there have been in my lifetime.

My late father became interested in computers in the 1960s for use in his work, and I recall him showing me magnetic core memory and explaining how it worked. His use of programmable calculators fascinated and inspired me in my teens. He had the vision and kindness to give me two early models of ‘pocket calculator’ (the HP-45 and the programmable TI-59) and an Apple II+ which he bought second-hand and brought half-way around the world to me, along with lots of early commercial software on 5.25″ floppy disks and a bundle of magazines full of Applesoft BASIC programs. These all helped me greatly during my studies and early professional life, and I will always be extremely grateful.

Anyway, in roughly chronological order, as best I can remember them …

A Multo 113 mechanical pinwheel calculator at home (my father’s, which he bought in the 1950s and which was still in use at home well into my teens).

The Olivetti Programma 101 (my father’s, for work). This was a desktop programmable calculator weighing nearly 30 kg! Actually I never used it myself, but I mention it here for interest as it was, I believe, the World’s first desktop programmable calculator. Mind you, there was not much space left on a desk for anything else when this was on it!

A slide rule (I still have my CONCISE circular slide rule) at high school. When I sat my university entrance exams we were allowed to use logarithm tables and slide rules but not one of the recently-invented ‘pocket calculators’.

An HP-45 scientific calculator in my final year at high school. Anyone remember Reverse Polish Notation?

A TI-59 programmable calculator (it had an attachable base station with a thermal printer) at university. An excellent piece of equipment that could store and retrieve programs on magnetic cards, and also had ROM modules with pre-canned programs (‘solid state software library’), although the magnetic card reader was rather unreliable. I remember the August 1978 issue of Personal Computer World magazine had an article on flowcharting using the game of NIM as an example, and I was engrossed for a couple of weeks in my summer holiday shoehorning it into the available memory of the TI-59, a real exercise in program optimisation. But possibly my most satisfying achievement was programming it during an exam to solve a problem by using the Newton-Raphson method while my fellow students resorted to recursion tables on paper.

The GEORGE 3 operating system at university, running on an ICL 1906. I initially used punched cards, but quickly moved to a 110-baud Teletype Model 33 terminal (known as a ‘TTY’ for short) with those cylindrical keys with long travel that you had to press hard and went “kerrrrchunkkk”! I also used 300-baud DEC dot-matrix printing terminals (the LA36 model, if I remember correctly).

I can’t remember the name of the OS on the CDC 7600 supercomputer at university, but I ran a lot of large FORTRAN 66 and FORTRAN 77 jobs, delivered to it as batch jobs via the ICL 1906.

Commodore BASIC on a Commodore PET 8k at work.

The RT-11 and RSX-11M operating systems on a DEC PDP-11 at work, on which I programmed in BASIC.

Applesoft BASIC, Apple DOS 3.2 & 3.3 on an Apple II+ (48k RAM, later expanded to 64k!) and, later, on an Apple //e. I programmed in Applesoft BASIC, 6502 assembler and Apple Pascal, and some years later even built an A-to-D converter card and a 240 VAC TRIAC switch card for the Apple II+ in order to control the central heating in my house.

I had VisiCalc (5.25″ floppy disk), the very first spreadsheet application, invented by two guys named Dan Bricklin and Bob Frankston. VisiCalc was the father of all spreadsheets: Lotus 1-2-3, MultiPlan, Quattro Pro and Excel. I actually used VisiCalc at work. I also had the first generation of SubLOGIC’s Flight Simulator for the Apple II, the predecessor of Microsoft Flight Simulator for the PC. It used line vector graphics, redrawn at a grindingly slow rate by today’s standards, but it was good fun.

CP/M on an Apple //e with a Microsoft Z-80 SoftCard and also the less popular Digital Research Z80 card. I programmed in Digital Research CBASIC and used various applications such as WordStar and MultiPlan.

ProDOS on an Apple //c with a whopping 128k RAM. This was my father’s machine for work, bought on my recommendation, and I used to help him sometimes with programming in BASIC.

Sharp PC-1500 pocket computer. This was another of my father’s work tools, also bought on my recommendation.

MP/M on a RAIR Black Box at work. I did some 8080 assembly language programming on it but mainly acted as a system admin (several VT100-style terminals around the office were connected to the RAIR Black Box). Also some Z80 assembly language programming on a microboard for work.

OSC245 on Ferranti Argus computers at work, programming in the real-time language CORAL 66.

VMS on a DEC VAX at work, programming (badly) in Pascal. VAX/VMS was an excellent OS.

MSDOS 3.2 on an Amstrad PC1512, for BBS (bulletin board system) access, one or two games (the first Leisure Suit Larry was fun), WordStar and WordPerfect. When WordPerfect 5.1 for DOS was released I thought it was the height of sophistication.

RISC OS 2 on an Acorn Archimedes A3000. What a brilliant microcomputer and OS. I just had to have one as soon as I saw the 3D vector graphics lander demo of the game Zarch. I also ran the Acorn PC Emulator software so that I could use MSDOS to run applications such as WordPerfect 5.1 and Quattro Pro for DOS, an excellent spreadsheet that introduced tabbed worksheets earlier than Microsoft Excel.

MSDOS 4.x, 5.x and 6.x on an IBM PC and various clones such as the ACT Apricot at work.

INTERACTIVE Unix (Intel PC, a computer manufactured by Intel having an 80386 CPU) at work, programming shell scripts, SQL procedures in Sybase SQL Server, and IEC 1131-3 (now known as 61131-3) languages.

IBM OS/2 1.3 and 2.0 on DEC PCs at work. A really nice OS, and streets ahead of the contemporary Windows 3.1.

MSDOS 3.22 on an HP 95LX palmtop. Even its RS-232 interface was useful for hardware interface testing at work, for BBS access using my Pace MicroLin fx modem, and for printing to my HP Deskjet 310 portable printer. It had built-in Lotus 1-2-3 in ROM.

Windows 3.11 on a PC clone at work, mainly for wordprocessing using Word.

Windows 95 on a tower PC and laptops. An excellent OS for its time, and streets ahead of its predecessor Windows 3.11.

Windows Me on a laptop and my family’s tower PC. This OS had a bad reputation but I never had any trouble with it on my Gateway Solo 9300 laptop and the tower PC, both of which were heavily used.

Windows NT on a desktop PC at work.

Windows 2000 on a desktop PC at work.

Windows XP on a laptop and my family’s tower PC.

At this point Linux came into the picture in my case and slowly became my OS of choice, Ubuntu 6.06 in October 2006 being replaced in March 2007 by Sabayon Linux 3.2 as my main distribution, with PCLinuxOS 2007 as a set-and-forget choice for old laptops and PCs. In 2010 I switched from Sabayon Linux to Gentoo Linux for my main distribution, although I still use Sabayon Linux on old laptops and an HTPC.

Windows Vista on my family’s tower PC (Intel Pentium Dual Core E2160 CPU). After a few years the performance of Vista became so slow, despite periodic deframenting, that I ditched Vista.

Windows 7, dual-booting with Gentoo Linux on a laptop. I hardly ever booted Windows 7, and it was only left on the laptop in case I had a work application that could not run using WINE in Linux. I dislike Windows 7, although I found it faster and more robust than Vista, which I also disliked. Mind you, the UI of Windows 8.1 on my family’s current tower PC (Intel Pentium Dual Core G2030 3.00 GHz CPU) is even worse; what an awful OS.

Other microcomputers I’ve used through the years: Grundy NewBrain (my father’s, bought for work purposes on my recommendation) at home, and a BBC Micro at work, programming in BASIC.

I remember my first modem was a 300-baud and 1200/75-baud (remember Prestel, anyone?) Minor Miracles WS-2000, and I programmed my Apple II+ to pulse-dial it so that I could access various BBSs and British Telecom’s Telecom Gold, an ASCII electronic mail service and means of sending telexes (which I sent several times). In later years I progressed to a British Telecom 9600-baud modem for BBS use with my Acorn Archimedes A3000, and a Pace MicroLin fx pocket modem for use with my HP 95LX and Acorn Archimedes.

So, in my lifetime, calculating tools for home use have changed from a mechanical pinwheel calculator to the 2.8 GHz Core i7 laptop with 16 GB RAM running Gentoo Linux that I’m typing this on now. Amazing.

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
CONFIG_PCI_MMCONFIG=y
# Supported MMC/SDIO adapters
CONFIG_MMC=y
# CONFIG_MMC_DEBUG is not set
# CONFIG_MMC_CLKGATE is not set
# MMC/SD/SDIO Card Drivers
CONFIG_MMC_BLOCK=m
CONFIG_MMC_BLOCK_MINORS=8
CONFIG_MMC_BLOCK_BOUNCE=y
# CONFIG_MMC_TEST is not set
# MMC/SD/SDIO Host Controller Drivers
CONFIG_MMC_SDHCI=m
CONFIG_MMC_SDHCI_PCI=m
CONFIG_MMC_RICOH_MMC=y
CONFIG_MMC_SDHCI_ACPI=m
CONFIG_MMC_SDHCI_PLTFM=m
CONFIG_MMC_WBSD=m
CONFIG_MMC_TIFM_SD=m
CONFIG_MMC_CB710=m
CONFIG_MMC_VIA_SDMMC=m
CONFIG_MMC_VUB300=m
CONFIG_MMC_USHC=m
CONFIG_MMC_USDHI6ROL0=m
CONFIG_MMC_REALTEK_PCI=m

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=m
# CONFIG_MEMSTICK_DEBUG is not set
# CONFIG_MEMSTICK_UNSAFE_RESUME is not set
# CONFIG_MEMSTICK_TIFM_MS is not set
# CONFIG_MEMSTICK_JMICRON_38X is not set
# CONFIG_MEMSTICK_R592 is not set
CONFIG_MEMSTICK_REALTEK_PCI=m

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

$ cat /usr/src/linux/.config | grep -i realtek
CONFIG_NET_VENDOR_REALTEK=y
# CONFIG_SND_HDA_CODEC_REALTEK is not set
# CONFIG_USB_STORAGE_REALTEK is not set
CONFIG_MMC_REALTEK_PCI=m
CONFIG_MEMSTICK_REALTEK_PCI=m

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
# CONFIG_MEMORY_HOTPLUG is not set
CONFIG_HOTPLUG_CPU=y
# CONFIG_BOOTPARAM_HOTPLUG_CPU0 is not set
# CONFIG_DEBUG_HOTPLUG_CPU0 is not set
CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
CONFIG_ACPI_HOTPLUG_CPU=y
CONFIG_HOTPLUG_PCI_PCIE=y
CONFIG_HOTPLUG_PCI=y
CONFIG_HOTPLUG_PCI_ACPI=y
# CONFIG_HOTPLUG_PCI_ACPI_IBM is not set
# CONFIG_HOTPLUG_PCI_CPCI is not set
# CONFIG_HOTPLUG_PCI_SHPC is not set
CONFIG_UEVENT_HELPER_PATH="/sbin/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
CONFIG_MMC_SDHCI=m
CONFIG_MMC_SDHCI_PCI=m
CONFIG_MMC_SDHCI_ACPI=m
CONFIG_MMC_SDHCI_PLTFM=m

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
CONFIG_RTS5208=m

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"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,-O1,--as-needed"
# 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.
CHOST="x86_64-pc-linux-gnu"
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_FILESYS="inotify"
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_BROWSER="nsplugin"
MY_COMMS="aim icq imap jabber mbox msn rss slp yahoo"
USE="${USE} ${UNWANTED} ${MY_MEDIA} ${MY_CODECS} ${MY_SYSTEM} ${MY_FILESYS} ${MY_PRINT} ${MY_XSYS} ${MY_DESKTOP} ${MY_BROWSER} ${MY_COMMS} ${MY_CPUFLAGS}"

PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
# The following line is for Layman:
source /var/lib/layman/make.conf
# The following line is for my local overlay:
PORTDIR_OVERLAY="/usr/local/portage ${PORTDIR_OVERLAY}"
LINGUAS="en en_GB pt_BR es_ES"
GRUB_PLATFORMS="pc"
MAKEOPTS="-j9"

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/"
SYNC="rsync://rsync.uk.gentoo.org/gentoo-portage"

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"
EndSection

#Section "Files"
#EndSection

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

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

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

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

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

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

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

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"
EndSection

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"
EndSection

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"
EndSection

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

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

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

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

(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.

NetworkManager

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:

[main]
plugins=keyfile
dhcp=dhcpcd
no-auto-default=*

[keyfile]
hostname=clevow230ss

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 0.9.3.4 and I believe the latest version of plasma-nm has fixed this bug, so eventually it should work correctly.

Audio

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

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.

Webcam

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, 
vid:5986 
pid:055c
driver:uvcvideo
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.

Scanners

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

to:

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 0.9.3.6 release about the last update to plasma-nm-4.* which fixes some bugs). I suppose I need to wait for plasma-nm-0.9.3.5 to become stable in the Portage main tree. Update (April 30, 2015): Done! I got fed up with the buggy ‘Stable’ plasma-nm-0.9.3.4 so I added plasma-nm-0.9.3.5 to /etc/portage/package.accept_keywords/plasma-nm and Version 0.9.3.5 is no longer crashing.
  12. Get qr-tools (QR Code application) working on the Clevo. Update (April 29, 2015): Done!

NetworkManager creating a new connection ‘eth0′ that does not work, Part 4

Further to my previous post, this is to report the result of another experiment. By doing all the following I can stop NetworkManager creating an invalid second eth0 connection:

  • Enable IPv6 system-wide in /etc/modprobe.d/aliases.conf by commenting-out ‘alias net-pf-10 off‘.
  • Disable use of IPv6 by the Avahi daemon in /etc/avahi/avahi-daemon.conf (see the four additional lines given in my previous post).
  • Use plasma-nm to edit the connection profile for ‘eth0′ that I had already created. Click on the IPv6 tab and ensure ‘Method: Ignored‘ is selected. Click on the IPv4 tab and ensure ‘Method: Automatic‘ is selected and ‘IPv4 is required for this connection‘ is ticked. Ticking ‘IPv4 is required for this connection‘ adds the line ‘may-fail=false‘ in the [ipv4] section in the file /etc/NetworkManager/system-connections/eth0 (the default value for may-fail is ‘true‘ if the box has not been ticked and may-fail has not been assigned in the file).

The various experiments I have conducted are summarised in the following table:

Laptop WiFi switch off off off off off on
IPv6 enabled in aliases.conf yes no yes yes yes yes
IPv6 enabled in avahi-daemon.conf yes yes no no yes yes
[ipv6] method= ignore ignore ignore ignore ignore ignore
[ipv4] method= auto auto auto auto auto auto
[ipv4] may-fail= true true true false false false
Invalid second eth0 created usually no usually no yes yes

As disabling IPv6 system-wide makes it impossible for NetworkManager to use IPv6, the above table can actually be written as follows:

Laptop WiFi switch off off off off off on
IPv6 enabled in aliases.conf yes no yes yes yes yes
IPv6 enabled in avahi-daemon.conf yes yes||no no no yes yes
[ipv6] method= ignore ignore ignore ignore ignore ignore
[ipv4] method= auto auto auto auto auto auto
[ipv4] may-fail= true true||false true false false false
Invalid second eth0 created usually no usually no yes yes

I still think there is a bug in NetworkManager. I would not have expected NetworkManager to create a second eth0 connection and make it an IPv6 Link-Local connection when all the following are true:

  • /etc/NetworkManager.conf has ‘no-auto-default=eth0‘ in the [main] section.
  • IPv4 is required for this connection‘ is not ticked in plasma-nm (i.e. the [ipv4] section in /etc/NetworkManager/system-connections/eth0 contains either the line ‘may-fail=true‘ or the line ‘may-fail=‘).
  • Method: Automatic‘ is selected for IPv4 (‘method=auto‘ under [ipv4] in /etc/NetworkManager/system-connections/eth0).
  • Method: Ignored‘ is selected for IPv6 (‘method=ignore‘ under [ipv6] in /etc/NetworkManager/system-connections/eth0) and the other fields on the IPv6 tab have been rendered unselectable as a result.

Anyway, I will keep IPv6 disabled in /etc/avahi/avahi-daemon.conf and IPv6 enabled system-wide. This seems to be the first thing to try if you’re experiencing the creation of an invalid additional eth0 connection with an IPv6 Link-Local address and you’re sure that none of the net.* services are running.

NetworkManager creating a new connection ‘eth0′ that does not work, Part 3

I’m even more convinced the problem discussed in my previous post is due to a bug in NetworkManager. I believe the issue with the Avahi daemon generating an IPv6 Link-Local address is a consequence of NetworkManager not always activating an interface and therefore not obtaining an IPv4 address, i.e. the IPv6 Link-Local address produced by the Avahi daemon is a side effect, not the root cause.

After my previous post I discovered that adding ‘use-ipv6=no‘ in /etc/avahi/avahi-daemon.conf (my Experiment 2) had not prevented avahi-daemon using IPv6. However, adding the following lines in /etc/avahi/avahi-daemon.conf defintely does prevent avahi-daemon from using IPv6 in my installation:

use-ipv4=yes
use-ipv6=no
publish-a-on-ipv6=no
publish-aaaa-on-ipv4=no

You can see in the message log below that the Avahi daemon is no longer generating an IPv6 Link-Local address. However, even with IPv6 disabled in avahi-daemon, an invalid second eth0 connection with an IPv6 Link-Local address still occurs in my installation. This indicates the problem is not caused by the Avahi daemon.

Mar 18 22:17:31 localhost syslog-ng[8316]: syslog-ng starting up; version='3.6.2'
Mar 18 22:17:32 localhost NetworkManager[8346]: <info>  NetworkManager (version 1.0.0) is starting...
Mar 18 22:17:32 localhost NetworkManager[8346]: <info>  Read config: /etc/NetworkManager/NetworkManager.conf
Mar 18 22:17:32 localhost NetworkManager[8346]: <info>  WEXT support is enabled
Mar 18 22:17:34 localhost kernel: fglrx_pci 0000:01:00.0: irq 34 for MSI/MSI-X
Mar 18 22:17:34 localhost kernel: <6>[fglrx] Firegl kernel thread PID: 8351
Mar 18 22:17:34 localhost kernel: <6>[fglrx] Firegl kernel thread PID: 8352
Mar 18 22:17:34 localhost kernel: <6>[fglrx] Firegl kernel thread PID: 8353
Mar 18 22:17:34 localhost kernel: <6>[fglrx] IRQ 34 Enabled
Mar 18 22:17:34 localhost kernel: <6>[fglrx] Reserved FB block: Shared offset:0, size:1000000 
Mar 18 22:17:34 localhost kernel: <6>[fglrx] Reserved FB block: Unshared offset:f7e2000, size:4000 
Mar 18 22:17:34 localhost kernel: <6>[fglrx] Reserved FB block: Unshared offset:f7e6000, size:51a000 
Mar 18 22:17:34 localhost kernel: <6>[fglrx] Reserved FB block: Unshared offset:3fff3000, size:d000 
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  Loaded plugin keyfile: (c) 2007 - 2013 Red Hat, Inc.  To report bugs please use the NetworkManager mailing list.
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  new connection /etc/NetworkManager/system-connections/Cisco00497
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  new connection /etc/NetworkManager/system-connections/eth0
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  new connection /etc/NetworkManager/system-connections/DIRECT-HeC460 Series
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  monitoring kernel firmware directory '/lib/firmware'.
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  rfkill0: found WiFi radio killswitch (at /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/ieee80211/phy0/rfkill0) (driver iwlwifi)
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  WiFi hardware radio set enabled
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  WWAN hardware radio set enabled
Mar 18 22:17:33 localhost /etc/init.d/NetworkManager[8326]: WARNING: NetworkManager has started, but is inactive
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  Loaded device plugin: /usr/lib64/NetworkManager/libnm-device-plugin-bluetooth.so
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  Loaded device plugin: /usr/lib64/NetworkManager/libnm-device-plugin-adsl.so
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  Loaded device plugin: /usr/lib64/NetworkManager/libnm-device-plugin-wwan.so
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  Loaded device plugin: /usr/lib64/NetworkManager/libnm-device-plugin-wifi.so
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  WiFi disabled by radio killswitch; enabled by state file
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  WWAN enabled by radio killswitch; enabled by state file
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  WiMAX enabled by radio killswitch; enabled by state file
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  Networking is enabled by state file
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (lo): link connected
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (lo): carrier is ON
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (lo): new Generic device (driver: 'unknown' ifindex: 1)
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (lo): exported as /org/freedesktop/NetworkManager/Devices/0
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): link connected
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): carrier is ON
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): new Ethernet device (driver: 'atl1c' ifindex: 2)
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): exported as /org/freedesktop/NetworkManager/Devices/1
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): device state change: unmanaged -> unavailable (reason 'connection-assumed') [10 20 41]
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): device state change: unavailable -> disconnected (reason 'connection-assumed') [20 30 41]
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  startup complete
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): Activation: starting connection 'eth0'
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): Activation: Stage 1 of 5 (Device Prepare) scheduled...
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (wlan0): using nl80211 for WiFi device control
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (wlan0): new 802.11 WiFi device (driver: 'iwlwifi' ifindex: 3)
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (wlan0): exported as /org/freedesktop/NetworkManager/Devices/2
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (wlan0): device state change: unmanaged -> unavailable (reason 'managed') [10 20 2]
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (wlan0): preparing device
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): Activation: Stage 1 of 5 (Device Prepare) started...
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): device state change: disconnected -> prepare (reason 'none') [30 40 0]
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): Activation: Stage 2 of 5 (Device Configure) scheduled...
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): Activation: Stage 1 of 5 (Device Prepare) complete.
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): Activation: Stage 2 of 5 (Device Configure) starting...
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): device state change: prepare -> config (reason 'none') [40 50 0]
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): Activation: Stage 2 of 5 (Device Configure) successful.
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): Activation: Stage 3 of 5 (IP Configure Start) scheduled.
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): Activation: Stage 2 of 5 (Device Configure) complete.
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): Activation: Stage 3 of 5 (IP Configure Start) started...
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): device state change: config -> ip-config (reason 'none') [50 70 0]
Mar 18 22:17:33 localhost dbus[7763]: [system] Activating service name='org.freedesktop.ModemManager1' (using servicehelper)
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): Activation: Stage 5 of 5 (IPv6 Commit) scheduled...
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): Activation: Stage 3 of 5 (IP Configure Start) complete.
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): Activation: Stage 5 of 5 (IPv6 Commit) started...
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): device state change: ip-config -> ip-check (reason 'none') [70 80 0]
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): Activation: Stage 5 of 5 (IPv6 Commit) complete.
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): device state change: ip-check -> secondaries (reason 'none') [80 90 0]
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  (eth0): device state change: secondaries -> activated (reason 'none') [90 100 0]
Mar 18 22:17:33 localhost NetworkManager[8346]: <info>  NetworkManager state is now CONNECTED_LOCAL
Mar 18 22:17:33 localhost acpid[8386]: starting up with netlink and the input layer
Mar 18 22:17:33 localhost acpid[8386]: 6 rules loaded
Mar 18 22:17:33 localhost acpid[8386]: waiting for events: event logging is off
Mar 18 22:17:34 localhost ModemManager[8385]: <info>  ModemManager (version 1.4.2) starting in system bus...
Mar 18 22:17:34 localhost NetworkManager[8346]: <info>  (eth0): Activation: successful, device activated.
Mar 18 22:17:34 localhost dbus[7763]: [system] Activating service name='org.freedesktop.nm_dispatcher' (using servicehelper)
Mar 18 22:17:34 localhost dbus[7763]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Mar 18 22:17:34 localhost nm-dispatcher[8435]: Dispatching action 'up' for eth0
Mar 18 22:17:34 localhost rpc.statd[8451]: Version 1.3.2 starting
Mar 18 22:17:34 localhost rpc.statd[8451]: Flags: TI-RPC 
Mar 18 22:17:34 localhost /etc/init.d/NetworkManager[8457]: status: inactive
Mar 18 22:17:34 localhost rpc.statd[8451]: Running as root.  chown /var/lib/nfs to choose different user
Mar 18 22:17:34 localhost /etc/init.d/NetworkManager[8469]: status: inactive
Mar 18 22:17:34 localhost dbus[7763]: [system] Successfully activated service 'org.freedesktop.ModemManager1'
Mar 18 22:17:34 localhost NetworkManager[8346]: <info>  ModemManager disappeared from bus
Mar 18 22:17:34 localhost NetworkManager[8346]: <info>  ModemManager available in the bus
Mar 18 22:17:35 localhost sm-notify[8556]: Version 1.3.2 starting
Mar 18 22:17:35 localhost avahi-daemon[8585]: Found user 'avahi' (UID 108) and group 'avahi' (GID 444).
Mar 18 22:17:35 localhost avahi-daemon[8585]: Successfully dropped root privileges.
Mar 18 22:17:35 localhost avahi-daemon[8585]: avahi-daemon 0.6.31 starting up.
Mar 18 22:17:35 localhost avahi-daemon[8585]: Successfully called chroot().
Mar 18 22:17:35 localhost avahi-daemon[8585]: Successfully dropped remaining capabilities.
Mar 18 22:17:35 localhost avahi-daemon[8585]: Loading service file /services/sftp-ssh.service.
Mar 18 22:17:35 localhost avahi-daemon[8585]: Loading service file /services/ssh.service.
Mar 18 22:17:35 localhost avahi-daemon[8585]: Network interface enumeration completed.
Mar 18 22:17:35 localhost avahi-daemon[8585]: Registering HINFO record with values 'X86_64'/'LINUX'.
Mar 18 22:17:35 localhost avahi-daemon[8585]: Server startup complete. Host name is meshedgedx.local. Local service cookie is 3778762828.
Mar 18 22:17:35 localhost avahi-daemon[8585]: Service "meshedgedx" (/services/ssh.service) successfully established.
Mar 18 22:17:35 localhost avahi-daemon[8585]: Service "meshedgedx" (/services/sftp-ssh.service) successfully established.
Mar 18 22:17:35 localhost ntpd[8645]: ntpd 4.2.8@1.3265-o Wed  4 Mar 02:23:30 UTC 2015 (1): Starting
Mar 18 22:17:35 localhost ntpd[8645]: Command line: ntpd -g -q
Mar 18 22:17:35 localhost ntpd[8645]: proto: precision = 0.061 usec (-24)
Mar 18 22:17:35 localhost ntpd[8645]: Listen and drop on 0 v6wildcard [::]:123
Mar 18 22:17:35 localhost ntpd[8645]: Listen and drop on 1 v4wildcard 0.0.0.0:123
Mar 18 22:17:35 localhost ntpd[8645]: Listen normally on 2 lo 127.0.0.1:123
Mar 18 22:17:35 localhost ntpd[8645]: Listen normally on 3 lo [::1]:123
Mar 18 22:17:35 localhost ntpd[8645]: Listen normally on 4 eth0 [fe80::725a:b6ff:fe3e:c18a%2]:123
Mar 18 22:17:35 localhost ntpd[8645]: Listening on routing socket on fd #21 for interface updates
Mar 18 22:17:36 localhost kernel: fbcondecor: console 1 using theme 'Emergance'
Mar 18 22:17:37 localhost kernel: fbcondecor: switched decor state to 'on' on console 1
Mar 18 22:17:37 localhost kernel: fbcondecor: console 2 using theme 'Emergance'
Mar 18 22:17:37 localhost kernel: fbcondecor: switched decor state to 'on' on console 2
Mar 18 22:17:37 localhost kernel: fbcondecor: console 3 using theme 'Emergance'
Mar 18 22:17:37 localhost kernel: fbcondecor: switched decor state to 'on' on console 3
Mar 18 22:17:37 localhost kernel: fbcondecor: console 4 using theme 'Emergance'
Mar 18 22:17:37 localhost kernel: fbcondecor: switched decor state to 'on' on console 4
Mar 18 22:17:37 localhost kernel: fbcondecor: console 5 using theme 'Emergance'
Mar 18 22:17:37 localhost kernel: fbcondecor: switched decor state to 'on' on console 5
Mar 18 22:17:36 localhost bluetoothd[8787]: Bluetooth daemon 5.28
Mar 18 22:17:36 localhost bluetoothd[8787]: Starting SDP server
Mar 18 22:17:37 localhost kernel: Bluetooth: Core ver 2.19
Mar 18 22:17:37 localhost kernel: NET: Registered protocol family 31
Mar 18 22:17:37 localhost kernel: Bluetooth: HCI device and connection manager initialized
Mar 18 22:17:37 localhost kernel: Bluetooth: HCI socket layer initialized
Mar 18 22:17:37 localhost kernel: Bluetooth: L2CAP socket layer initialized
Mar 18 22:17:37 localhost kernel: Bluetooth: SCO socket layer initialized
Mar 18 22:17:38 localhost kernel: Bluetooth: BNEP (Ethernet Emulation) ver 1.3
Mar 18 22:17:38 localhost kernel: Bluetooth: BNEP filters: protocol multicast
Mar 18 22:17:38 localhost kernel: Bluetooth: BNEP socket layer initialized
Mar 18 22:17:36 localhost bluetoothd[8787]: Bluetooth management interface 1.7 initialized
Mar 18 22:17:36 localhost NetworkManager[8346]: <info>  use BlueZ version 5
Mar 18 22:17:37 localhost ModemManager[8385]: <warn>  Couldn't find support for device at '/sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0': not supported by any plugin
Mar 18 22:17:37 localhost ModemManager[8385]: <warn>  Couldn't find support for device at '/sys/devices/pci0000:00/0000:00:1c.2/0000:04:00.0': not supported by any plugin
Mar 18 22:17:39 localhost dbus[7763]: [system] Activating service name='org.freedesktop.ColorManager' (using servicehelper)
Mar 18 22:17:39 localhost dbus[7763]: [system] Successfully activated service 'org.freedesktop.ColorManager'
Mar 18 22:17:41 localhost kernel: nf_conntrack: automatic helper assignment is deprecated and it will be removed soon. Use the iptables CT target to attach helpers instead.
Mar 18 22:17:43 localhost kernel: [UFW BLOCK] IN=eth0 OUT= MAC= SRC=fe80:0000:0000:0000:725a:b6ff:fe3e:c18a DST=ff02:0000:0000:0000:0000:0000:0000:0001 LEN=64 TC=0 HOPLIMIT=1 FLOWLBL=0 PROTO=UDP SPT=8612 DPT=8612 LEN=24 
Mar 18 22:17:43 localhost kernel: [UFW BLOCK] IN=eth0 OUT= MAC= SRC=fe80:0000:0000:0000:725a:b6ff:fe3e:c18a DST=ff02:0000:0000:0000:0000:0000:0000:0001 LEN=64 TC=0 HOPLIMIT=1 FLOWLBL=0 PROTO=UDP SPT=8612 DPT=8612 LEN=24 
Mar 18 22:17:43 localhost laptop-mode[8947]: Laptop mode 
Mar 18 22:17:43 localhost laptop-mode[8948]: enabled, not active
Mar 18 22:17:58 localhost kernel: Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
Mar 18 22:17:58 localhost rpc.mountd[9741]: Version 1.3.2 starting
Mar 18 22:17:59 localhost kernel: NFSD: Using /var/lib/nfs/v4recovery as the NFSv4 state recovery directory
Mar 18 22:17:59 localhost kernel: NFSD: starting 90-second grace period (net ffffffff81c3d580)
Mar 18 22:17:58 localhost sm-notify[9760]: Version 1.3.2 starting
Mar 18 22:17:58 localhost sm-notify[9760]: Already notifying clients; Exiting!
Mar 18 22:18:00 localhost sshd[9816]: Server listening on 0.0.0.0 port 22.
Mar 18 22:18:00 localhost sshd[9816]: Server listening on :: port 22.
Mar 18 22:18:00 localhost cron[9870]: (CRON) STARTUP (V5.0)
Mar 18 22:18:00 localhost su[9899]: Successful su for fitzcarraldo by root
Mar 18 22:18:00 localhost su[9899]: + /dev/console root:fitzcarraldo
Mar 18 22:18:00 localhost su[9899]: pam_unix(su:session): session opened for user fitzcarraldo by (uid=0)
Mar 18 22:18:01 localhost dbus[7763]: [system] Activating service name='org.freedesktop.RealtimeKit1' (using servicehelper)
Mar 18 22:18:01 localhost dbus[7763]: [system] Successfully activated service 'org.freedesktop.RealtimeKit1'
Mar 18 22:18:01 localhost rtkit-daemon[9906]: Successfully called chroot.
Mar 18 22:18:01 localhost rtkit-daemon[9906]: Successfully dropped privileges.
Mar 18 22:18:01 localhost rtkit-daemon[9906]: Successfully limited resources.
Mar 18 22:18:01 localhost rtkit-daemon[9906]: Running.
Mar 18 22:18:01 localhost rtkit-daemon[9906]: Watchdog thread running.
Mar 18 22:18:01 localhost rtkit-daemon[9906]: Canary thread running.
Mar 18 22:18:01 localhost kdm[8833]: :0[8833]: pam_unix(kde:session): session opened for user fitzcarraldo by (uid=0)
Mar 18 22:18:01 localhost kdm[8833]: :0[8833]: pam_ck_connector(kde:session): nox11 mode, ignoring PAM_TTY :0
Mar 18 22:18:03 localhost pulseaudio[9904]: [pulseaudio] sink.c: Default and alternate sample rates are the same.
Mar 18 22:18:03 localhost rtkit-daemon[9906]: Supervising 0 threads of 0 processes of 1 users.
Mar 18 22:18:03 localhost rtkit-daemon[9906]: Supervising 0 threads of 0 processes of 1 users.
Mar 18 22:18:03 localhost rtkit-daemon[9906]: Supervising 0 threads of 0 processes of 1 users.
Mar 18 22:18:03 localhost rtkit-daemon[9906]: Supervising 0 threads of 0 processes of 1 users.
Mar 18 22:18:03 localhost rtkit-daemon[9906]: Supervising 0 threads of 0 processes of 1 users.
Mar 18 22:18:03 localhost pulseaudio[9904]: [pulseaudio] source.c: Default and alternate sample rates are the same.
Mar 18 22:18:03 localhost rtkit-daemon[9906]: Supervising 0 threads of 0 processes of 1 users.
Mar 18 22:18:03 localhost rtkit-daemon[9906]: Supervising 0 threads of 0 processes of 1 users.
Mar 18 22:18:03 localhost rtkit-daemon[9906]: Supervising 0 threads of 0 processes of 1 users.
Mar 18 22:18:03 localhost rtkit-daemon[9906]: Supervising 0 threads of 0 processes of 1 users.
Mar 18 22:18:03 localhost rtkit-daemon[9906]: Supervising 0 threads of 0 processes of 1 users.
Mar 18 22:18:03 localhost pulseaudio[9904]: [pulseaudio] module-jackdbus-detect.c: Unable to contact D-Bus session bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Mar 18 22:18:03 localhost pulseaudio[9904]: [pulseaudio] module.c: Failed to load module "module-jackdbus-detect" (argument: "channels=2"): initialization failed.
Mar 18 22:18:04 localhost pulseaudio[9904]: [pulseaudio] main.c: Module load failed.
Mar 18 22:18:04 localhost pulseaudio[9904]: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Mar 18 22:18:04 localhost pulseaudio[9904]: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Mar 18 22:18:04 localhost su[9899]: pam_unix(su:session): session closed for user fitzcarraldo
Mar 18 22:18:04 localhost su[9964]: Successful su for fitzcarraldo by root
Mar 18 22:18:04 localhost su[9964]: + /dev/console root:fitzcarraldo
Mar 18 22:18:04 localhost su[9964]: pam_unix(su:session): session opened for user fitzcarraldo by (uid=0)
Mar 18 22:18:04 localhost su[9964]: pam_unix(su:session): session closed for user fitzcarraldo
Mar 18 22:18:04 localhost su[9966]: Successful su for fitzcarraldo by root
Mar 18 22:18:04 localhost su[9966]: + /dev/console root:fitzcarraldo
Mar 18 22:18:04 localhost su[9966]: pam_unix(su:session): session opened for user fitzcarraldo by (uid=0)
Mar 18 22:18:04 localhost su[9966]: pam_unix(su:session): session closed for user fitzcarraldo
Mar 18 22:18:04 localhost su[9968]: Successful su for fitzcarraldo by root
Mar 18 22:18:04 localhost su[9968]: + /dev/console root:fitzcarraldo
Mar 18 22:18:04 localhost su[9968]: pam_unix(su:session): session opened for user fitzcarraldo by (uid=0)
Mar 18 22:18:04 localhost su[9968]: pam_unix(su:session): session closed for user fitzcarraldo
Mar 18 22:18:15 localhost dbus[7763]: [system] Activating service name='org.freedesktop.UPower' (using servicehelper)
Mar 18 22:18:15 localhost dbus[7763]: [system] Successfully activated service 'org.freedesktop.UPower'
Mar 18 22:18:17 localhost dbus[7763]: [system] Activating service name='org.freedesktop.UDisks2' (using servicehelper)
Mar 18 22:18:17 localhost udisksd[10120]: udisks daemon version 2.1.4 starting
Mar 18 22:18:17 localhost dbus[7763]: [system] Successfully activated service 'org.freedesktop.UDisks2'
Mar 18 22:18:17 localhost udisksd[10120]: Acquired the name org.freedesktop.UDisks2 on the system message bus
Mar 18 22:18:19 localhost kernel: [UFW BLOCK] IN=eth0 OUT= MAC=01:00:5e:00:00:01:00:16:fa:25:28:01:08:00 SRC=0.0.0.0 DST=224.0.0.1 LEN=36 TOS=0x00 PREC=0xC0 TTL=1 ID=0 PROTO=2 
Mar 18 22:18:54 localhost hp-systray[10453]: hp-systray[10453]: error: option -s not recognized
Mar 18 22:18:55 localhost rtkit-daemon[9906]: Successfully made thread 10469 of process 10469 (/usr/bin/pulseaudio) owned by '1000' high priority at nice level -11.
Mar 18 22:18:55 localhost rtkit-daemon[9906]: Supervising 1 threads of 1 processes of 1 users.
Mar 18 22:18:55 localhost pulseaudio[10469]: [pulseaudio] pid.c: Daemon already running.
Mar 18 22:18:56 localhost rtkit-daemon[9906]: Successfully made thread 10485 of process 10485 (/usr/bin/pulseaudio) owned by '1000' high priority at nice level -11.
Mar 18 22:18:56 localhost rtkit-daemon[9906]: Supervising 1 threads of 1 processes of 1 users.
Mar 18 22:18:56 localhost pulseaudio[10485]: [pulseaudio] pid.c: Daemon already running.
Mar 18 22:19:04 localhost polkitd[7911]: Registered Authentication Agent for unix-session:/org/freedesktop/ConsoleKit/Session1 (system bus name :1.52 [/usr/lib64/kde4/libexec/polkit-kde-authentication-agent-1], object path /org/kde/PolicyKit1/AuthenticationAgent, locale en_GB.UTF-8)
Mar 18 22:19:10 localhost su[10569]: Successful su for root by fitzcarraldo
Mar 18 22:19:10 localhost su[10569]: + /dev/pts/0 fitzcarraldo:root
Mar 18 22:19:10 localhost su[10569]: pam_unix(su:session): session opened for user root by fitzcarraldo(uid=1000)
Mar 18 22:19:26 localhost pulseaudio[9904]: [alsa-sink-ALC272 Analog] alsa-sink.c: ALSA woke us up to write new data to the device, but there was actually nothing to write!
Mar 18 22:19:26 localhost pulseaudio[9904]: [alsa-sink-ALC272 Analog] alsa-sink.c: Most likely this is a bug in the ALSA driver 'snd_hda_intel'. Please report this issue to the ALSA developers.
Mar 18 22:19:26 localhost pulseaudio[9904]: [alsa-sink-ALC272 Analog] alsa-sink.c: We were woken up with POLLOUT set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail.
Mar 18 22:20:01 localhost cron[10670]: (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons)

In the cases when NetworkManager activates a connection correctly and there is no invalid second eth0 connection, the log contains a message like the following:

Mar 16 22:23:47 localhost NetworkManager[6688]: <info>  Auto-activating connection 'eth0'.

Notice there is no such message in the message log above.

The only way I can be sure of preventing NetworkManager creating an invalid second eth0 connection is to disable IPv6 system-wide by uncommenting the line ‘alias net-pf-10 off‘ in the file /etc/modprobe.d/aliases.conf.

So, to me, this looks like a bug in NetworkManager 1.0.0 (I have been experiencing it since Version 0.9.10.0).

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 0.9.10.0 (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 0.9.10.0 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

Follow

Get every new post delivered to your Inbox.

Join 60 other followers