Difference between revisions of "Installing Gentoo on a ThinkPad X220"

From ThinkWiki
Jump to: navigation, search
(Format the partitions)
(Grub with EFI support installation)
 
(109 intermediate revisions by 4 users not shown)
Line 1: Line 1:
= DRAFT! Installing Gentoo on a Lenovo X220 DRAFT! =
+
= Installing Gentoo on a Lenovo X220 with UEFI and GPT =
  
== Model Specs ==
+
The goal is a working {{Gentoo}} installation utilizing UEFI and GPT on an SSD. I work on improving the page step-by-step, but at the moment it's more or less for the advanced gentoo user. Anyways, you can always ask me for clarification. :)
  
=== General Specs ===
+
== Model specs ==
X220 - 4290-W1B, i5-2520M, 4GB RAM
 
  
replaced internal HD with SSD Intel 320 Series 120GB, 2.5", SATA II (SSDSA2CW120G310)
+
=== General specs ===
 +
{{X220}} - 4290-W1B, i5-2520M, 4GB RAM
 +
 
 +
Replaced internal HDD with SSD Intel 320 Series 120GB, 2.5", SATA II (SSDSA2CW120G310). It's a SSD with 7.5mm height, so it fits nicely in the X220. 2.5" 9mm SSDs fit too, but you have to remove parts of the SSDs case.
 +
 
 +
{{WARN|Some Intel 320 Series SSDs are affected by a [http://communities.intel.com/message/133505 firmware bug]}}
 +
{{WARN| The mSATA Intel 310 Serices SSD requires UEFI BIOS 1.19 (proved with X220 4290-W4H)}}
  
 
=== cpuinfo ===
 
=== cpuinfo ===
Line 14: Line 19:
 
cpu family      : 6
 
cpu family      : 6
 
model          : 42
 
model          : 42
model name      : Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
+
model name      : Intel® Core™ i5-2520M CPU 2.50GHz
 
stepping        : 7
 
stepping        : 7
 
cpu MHz        : 2501.000
 
cpu MHz        : 2501.000
cache size      : 3072 KB
+
cache size      : 3072 KiB
 
physical id    : 0
 
physical id    : 0
 
siblings        : 4
 
siblings        : 4
Line 38: Line 43:
 
=== lspci ===
 
=== lspci ===
 
<pre>
 
<pre>
00:00.0 Host bridge: Intel Corporation Device 0104 (rev 09)
+
00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09)
00:02.0 VGA compatible controller: Intel Corporation Device 0126 (rev 09)
+
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
00:16.0 Communication controller: Intel Corporation Cougar Point HECI Controller #1 (rev 04)
+
00:16.0 Communication controller: Intel Corporation 6 Series/C200 Series Chipset Family HECI Controller #1 (rev 04)
00:16.3 Serial controller: Intel Corporation Cougar Point KT Controller (rev 04)
+
00:16.3 Serial controller: Intel Corporation 6 Series/C200 Series Chipset Family KT Controller (rev 04)
00:19.0 Ethernet controller: Intel Corporation Device 1502 (rev 04)
+
00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit Network Connection (rev 04)
00:1a.0 USB Controller: Intel Corporation Cougar Point USB Enhanced Host Controller #2 (rev 04)
+
00:1a.0 USB Controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation Cougar Point High Definition Audio Controller (rev 04)
+
00:1b.0 Audio device: Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation Cougar Point PCI Express Root Port 1 (rev b4)
+
00:1c.0 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 1 (rev b4)
00:1c.1 PCI bridge: Intel Corporation Cougar Point PCI Express Root Port 2 (rev b4)
+
00:1c.1 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 2 (rev b4)
00:1c.3 PCI bridge: Intel Corporation Cougar Point PCI Express Root Port 4 (rev b4)
+
00:1c.3 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 4 (rev b4)
00:1c.4 PCI bridge: Intel Corporation Cougar Point PCI Express Root Port 5 (rev b4)
+
00:1c.4 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 5 (rev b4)
00:1d.0 USB Controller: Intel Corporation Cougar Point USB Enhanced Host Controller #1 (rev 04)
+
00:1d.0 USB Controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation Device 1c4f (rev 04)
+
00:1f.0 ISA bridge: Intel Corporation QM67 Express Chipset Family LPC Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation Cougar Point 6 port SATA AHCI Controller (rev 04)
+
00:1f.2 SATA controller: Intel Corporation 6 Series/C200 Series Chipset Family 6 port SATA AHCI Controller (rev 04)
00:1f.3 SMBus: Intel Corporation Cougar Point SMBus Controller (rev 04)
+
00:1f.3 SMBus: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller (rev 04)
03:00.0 Network controller: Intel Corporation Device 0085 (rev 34)
+
03:00.0 Network controller: Intel Corporation Centrino Advanced-N 6205 (rev 34)
 
0d:00.0 System peripheral: Ricoh Co Ltd Device e823 (rev 04)
 
0d:00.0 System peripheral: Ricoh Co Ltd Device e823 (rev 04)
 
</pre>
 
</pre>
Line 59: Line 64:
 
=== lsusb ===
 
=== lsusb ===
 
<pre>
 
<pre>
 
 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Line 68: Line 72:
 
</pre>
 
</pre>
  
=== Required Kernel modules for the X220 hardware ===
+
=== Required kernel modules for the X220 hardware ===
* Intel Gigabit Ethernet: e1000e
+
* Intel Gigabit Ethernet: {{kernelconf|CONFIG_E1000EI||||||}}
 +
* Intel WLAN: {{kernelconf|CONFIG_IWLAGNI||||||}}
 +
* Intel HD Graphic: {{kernelconf|CONFIG_DRM_I915I||||||}}
 +
* TPM Chip {{kernelconf|CONFIG_TCG_TIS||||||}}
 +
 
 +
There are still no correct settings for MTRR: [https://bugzilla.redhat.com/show_bug.cgi?id=584493 Link]
  
== BIOS Update ==
+
== BIOS update ==
Turns out to be very Linux unfriendly. There a ways to boot the .iso image with grub. I tried grub2 with help from syslinux memdisk, reached some kind of bios update menu. But got stuck there. After all I did it by installing Win7 and running the Windows BIOS update tool.
+
{{WARN| Always use an up-to-date BIOS version. Old versions are known to cause problems with shutdown and wakeup after suspend-to-RAM.}}
  
== Boot from USB Stick ==
+
1. Get the bios update iso (8duj10uc.iso here) from the lenovo support site.
Sysresccd (2.2.0), which has a pretty nice script to create a bootable USB-Stick, failed to boot on the X220. Created an bootable usb stick from the gentoo-minimal.iso with unetbootin. Works.
 
  
=== Partition the Drive ===
+
2. Get 'geteltorito' and extract the boot image from the iso (isobar.c probably works too)
 +
 
 +
{{cmduser|wget 'http://www.uni-koblenz.de/~krienke/ftp/noarch/geteltorito/geteltorito.pl'}}
 +
 
 +
{{cmduser|perl geteltorito.pl 8duj10uc.iso > biosupdate.img}}
 +
 
 +
3. Copy the image to the usb thumdrive
 +
 
 +
{{cmdroot|ddrescue biosupdate.img /dev/usbthumdrive}}
 +
 
 +
Reboot, Press F12 and boot from thumb drive.
 +
 
 +
The latest BIOS for the X220 can be found [http://support.lenovo.com/en_US/research/hints-or-tips/detail.page?&LegacyDocID=MIGR-77280 here].
 +
 
 +
== Boot from USB stick ==
 +
Sysresccd (2.2.0), which has a pretty nice script to create a bootable USB-Stick, failed to boot on the X220.
 +
Created an bootable usb stick from the gentoo-minimal.iso with unetbootin. Works.
 +
 
 +
=== Partition the drive ===
 
{{cmdroot|parted}}
 
{{cmdroot|parted}}
  
 
{{cmd|mklabel gpt|(parted)}}
 
{{cmd|mklabel gpt|(parted)}}
 +
 +
{{NOTE|X220s will not boot GPT partitioned drives using Legacy BIOS, so you will have to setup UEFI if you use GPT.}}
  
 
{{cmd|mkpart primary fat32 1 201|(parted)}}
 
{{cmd|mkpart primary fat32 1 201|(parted)}}
Line 102: Line 130:
 
{{NOTE| The ''mkfs.btrfs'' binary is not yet on the gentoo minimal image.}}
 
{{NOTE| The ''mkfs.btrfs'' binary is not yet on the gentoo minimal image.}}
  
== Gentoo stage3 ==
+
== Gentoo installation ==
Just like the handbook, boot from gentoo-minimal-image. Unpack stage3 and portage. Edit fstab and set a root password. Everything else can be done later on.
+
 
 +
=== Gentoo stage3 ===
 +
Just like the [http://www.gentoo.org/doc/en/gentoo-x86-quickinstall.xml handbook]:
 +
*  Boot from gentoo-minimal-image.  
 +
Unpack stage3 and portage.  
 +
Edit fstab
 +
{{path|/etc/fstab}}
 +
<pre>
 +
/dev/sda1 /boot/efi vfat noauto 1 2
 +
/dev/sda3 / btrfs noatime 0 1
 +
/dev/sda2 none swap sw 0 0
 +
</pre>
 +
 
 +
* If you have a SSD, you should use Trim (discard)
 +
{{path|/etc/fstab}}
 +
<pre>
 +
/dev/sda1 /boot/efi vfat noauto 1 2
 +
/dev/sda3 / btrfs noatime,discard 0 1
 +
/dev/sda2 none swap sw 0 0
 +
</pre>
 +
 
 +
*  Set a root password.  
 +
Everything else can be done later on.
 +
 
 +
=== Grub with EFI support installation ===
 +
This was by far the hardest part. Because UEFI and GPT a relatively new, I am not so familiar with it and the documentation isn't so good at the time of writing.
 +
Basically EFI on the X220 looks for a FAT32 formatted GPT partition with the boot flag set.
 +
If it finds one it tries to start {{path|/EFI/boot/bootx64.efi}} from this partition. (Note that this is actually case-insensitive because of FAT32).
 +
 
 +
Enable GRUB_PLATFORMS=efi-64 in make.conf and emerge >=sys-devel/grub-1.99.
  
=== Grub with efi support installation ===
+
{{cmdroot|<nowiki>GRUB_PLATFORMS="grub_platforms_efi-64" emerge -v sys-boot/grub</nowiki>}}
This was by far the hardest part yet. Because UEFI and GPT a relatively new and I am not so familiar with it and the documentation isn't so good yet. Basically EFI on the X220 looks for a FAT32 formatted GPT partition with the boot flag set. If it finds one it tries to start /EFI/boot/bootx64.efi (Note that this is actually case-insensitive because of FAT32).
 
  
Grub-1.99 from scarabeus overlay is needed. Fix the STRIP_MASK error, remove last "a". Enable GRUB_PLATFORMS=efi-64 in make.conf. TODO add tar.gz with fixed ebuild for adding to overlay
+
Create a mountpoint for the UEFI partition and mount the partition.
  
 +
{{cmdroot|mkdir /boot/efi}}
  
Not sure if this is needed:
+
{{cmdroot|mount /dev/sda1 /boot/efi}}
  
cp /usr/share/grub/{unicode.pf2,ascii.pf2} /boot/efi/efi/grub/
+
{{cmdroot|mkdir /boot/efi/efi/grub -p}}
  
grub2-install --boot-directory=/boot/efi/efi --bootloader-id=grub --no-floppy --recheck
+
{{HELP|I don't think that this is needed, it's from the [https://wiki.archlinux.org/index.php/GRUB2#UEFI_systems Arch Wiki on UEFI boot]. Maybe outdated, please report if it works without for you or simply delete this part.}}
 +
 
 +
{{cmdroot|cp /usr/share/grub/{unicode.pf2,ascii.pf2} /boot/efi/efi/grub/}}
  
 
Important part:
 
Important part:
  
grub-mkimage -d /lib/grub/x86_64-efi -O x86_64-efi -p "" -o /boot/efi/efi/boot/bootx64.efi part_gpt btrfs fat ext2 normal chain boot configfile linux multiboot efi_gop
+
{{NOTE| The efi_gop grub module is very important. If it's not loaded, you won't see anything on boot after grub}}
 +
 
 +
{{cmdroot|grub2-mkimage -d /lib/grub/x86_64-efi -O x86_64-efi -p "" -o /boot/efi/efi/boot/bootx64.efi part_gpt btrfs fat ext2 normal chain boot configfile linux multiboot efi_gop linux}}
  
 
Optional but useful:
 
Optional but useful:
  
cp /lib/grub/x86_64-efi/*.mod /boot/efi/efi/boot/
+
{{cmdroot|cp /lib/grub/x86_64-efi/*.mod /boot/efi/efi/boot/}}
  
cp /lib/grub/x86_64-efi/*.lst /boot/efi/efi/boot/
+
{{cmdroot|cp /lib/grub/x86_64-efi/*.lst /boot/efi/efi/boot/}}
  
 +
==== Minimal grub.cfg ====
 +
<pre>
 +
set prefix(hd0,gpt1)/efi/boot
 +
pager=1
 +
timeout=20
  
Put grub.cf in same directory as bootx64.efi -> /boot/efi/efi/boot/
+
menuentry "Gentoo Linux" {
 +
        set root=(hd0,gpt3)
 +
        linux /boot/bzImage root=/dev/sda3 ro raid=noautodetect
 +
}
 +
</pre>
 +
Put grub.cfg in same directory as bootx64.efi: {{path|/boot/efi/efi/boot/}}
  
 +
'''Thanks to Finnbarr P. Murphy for [http://blog.fpmurphy.com/2010/03/grub2-efi-support.html his] [http://blog.fpmurphy.com/2010/11/boot-fedora-14-using-uefi-and-grub2.html blog] [http://blog.fpmurphy.com/2011/06/boot-fedora-15-using-uefi-and-grub2.html posts] about Grub and UEFI.'''
  
'''Thanks to Finnbarr P. Murphy for [http://blog.fpmurphy.com/2010/03/grub2-efi-support.html his] [http://blog.fpmurphy.com/2010/11/boot-fedora-14-using-uefi-and-grub2.html blog] [http://blog.fpmurphy.com/2011/06/boot-fedora-15-using-uefi-and-grub2.html posts] about Grub and UEFI'''
+
===== Optimized grub.cfg =====
 +
 
 +
Use 'threadirqs' with kernel > 3.0.0 and because PCIE_ASPM is not detected correct (and you may want longer battery life) you should use 'pcie_aspm=force'.
 +
 
 +
<pre>
 +
set prefix(hd0,gpt1)/efi/boot
 +
pager=1
 +
timeout=3
 +
 
 +
menuentry "Gentoo Linux" {
 +
        set root=(hd0,gpt3)
 +
        linux /boot/bzImage root=/dev/sda3 ro fastboot splash=silent quiet threadirqs pcie_aspm=force i915.i915_enable_rc6=1 i915.i915_enable_fbc=1 i915.lvds_downclock=1 rootfstype=ext4
 +
}
 +
</pre>
 +
 
 +
According to following links (threads), you should set i915.i915_enable_rc6=1, i915.i915_enable_fbc=1 and i915.lvds_downclock=1 for less power consumption (used kernel: 3.1.0rc3).
 +
:[http://forum.notebookreview.com/lenovo-ibm/575569-linux-x220-19.html Link Forum Notebookreview]
 +
:[https://bugs.launchpad.net/ubuntu/+source/linux/+bug/818830 Link Ubuntu Launchpad Bugs]
 +
:[https://bbs.archlinux.org/viewtopic.php?pid=974592#p974592 Link Archlinux BBS]  
 +
:[http://www.phoronix.com/scan.php?page=article&item=intel_i915_power&num=12 Link Phoronix Tweaks To Extend The Battery Life Of Intel Linux Notebooks]
 +
:[https://bugzilla.redhat.com/show_bug.cgi?id=727579 RedHat Bugzilla]
  
 
=== Kernel ===
 
=== Kernel ===
For UEFI you have to use a kernel > 3.0-rc1
+
For UEFI on the X220 you have to use a kernel > 3.0-rc1. Suspend-to-RAM and brightness control of the display work with kernel >= 3.0-rc6.
  
My [https://gist.github.com/1056225 current Kernel .config]. Please feel free to comment if you have spotted an unnecessary enabled hardware option or something that should be enabled on the X220. This is work in progress :)
+
My [https://gist.github.com/1056225 current Kernel .config (3.0-rc6)].  
 +
Please feel free to comment if you have spotted an unnecessary enabled hardware option or something that should be enabled on the X220.  
 +
The config is hosted as github gist, so you can easily ask for merges with your version.
 +
This is work in progress :)
 +
 
 +
==== Kernel configuration remarks ====
 +
* Use the deadline I/0 scheduler when you have an SSD. If you don't have an SSD, use the CFQ scheduler.
 +
 
 +
=== make.conf ===
 +
{{path|/etc/make.conf}}
 +
<pre>
 +
CFLAGS="-march=core2 -O3 -pipe"
 +
CXXFLAGS="${CFLAGS}"
 +
CHOST="x86_64-pc-linux-gnu"
 +
MAKEOPTS="-j5 -l5"
 +
GRUB_PLATFORMS="efi-64"
 +
INPUT_DEVICES="evdev synaptics"
 +
VIDEO_CARDS="intel vesa fbdev"
 +
</pre>
 +
 
 +
With gcc > 4.2:
 +
 
 +
{{path|/etc/make.conf}}
 +
<pre>
 +
CFLAGS="-march=native -O3 -pipe"
 +
CXXFLAGS="${CFLAGS}"
 +
CHOST="x86_64-pc-linux-gnu"
 +
MAKEOPTS="-j5 -l5"
 +
GRUB_PLATFORMS="efi-64"
 +
INPUT_DEVICES="evdev synaptics"
 +
VIDEO_CARDS="intel vesa fbdev"
 +
</pre>
  
 
=== Finishing touches ===
 
=== Finishing touches ===
Set timezone
 
  
Set locale.gen
+
==== Set timezone ====
 +
{{cmdroot|cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime}}
 +
 
 +
=== Locale ===
 +
{{cmdroot|nano /etc/locale.gen}}
 +
{{cmdroot|locale-gen}}
 +
 
 +
Set LANG in {{path|/etc/env.d/90locale}}
 +
<pre>
 +
LANG=en_US.utf8
 +
LC_TIME=de_DE.utf8
 +
LC_COLLATE=de_DE.utf8
 +
LC_MONETARY=de_DE.utf8
 +
LC_NUMERIC=de_DE.utf8
 +
</pre>
 +
Read more here: [http://www.gentoo.org/doc/en/guide-localization.xml Gentoo Linux Localization Guide]
 +
 
 +
== Hardware setup ==
 +
 
 +
=== WLAN Intel Advanced 6205 ===
 +
{{cmdroot|emerge wpa_supplicant linux-firmware}}
 +
{{NOTE| You will see a lot of "DMAR:[DMA Write] Request device [03:00.0] fault addr XXXXXXXX" errors in syslog, caused by the WLAN module/firmware. But the device seems to work just fine}}
 +
 
 +
= Further installation steps =
 +
== Emerging the system ==
 +
=== xorg ===
 +
{{cmdroot|emerge xorg-x11}}
 +
The touchpad can be accessed by the evdev and the synaptics driver, which can lead to X11 not starting.
 +
To fix this add the following lines to {{path|/usr/share/X11/xorg.conf.d/50-synaptics.conf}}.
 +
<pre>
 +
    MatchDevicePath "/dev/input/event*"
 +
            Option "TapButton1" "1"
 +
            Option "TapButton2" "2"
 +
            Option "TapButton3" "3"
 +
</pre>
 +
==== DPI ====
 +
{{cmduser|xdpyinfo}} gets the displays dimensions wrong, while {{cmduser|xrandr}} shows the correct screen size (277x156mm). Although it seems to make no big difference (yet), you '''could''' specify the displays dimensions/DPI via one of these two methods manually:
 +
 
 +
* Via an xorg.conf:
 +
{{path|/usr/share/X11/xorg.conf.d/10-monitor.conf}}
 +
<pre>
 +
Section "Monitor"
 +
    Identifier "<default monitor>"
 +
#    Option  "DPI" "125 x 125"
 +
    DisplaySize 277 156    # In millimeters
 +
EndSection
 +
</pre>
 +
But this doesn't fix the ''xdpyinfo'' either (at least in my case).
 +
 
 +
* Via xrandr
 +
{{cmduser|xrandr --dpi 125}}
 +
 
 +
==== KMS ====
 +
One quick word about Kernel mode-setting (KMS) which comes with Linux 3.0. The i915 driver seems to support it flawlessly and it's really impressing how fast the switch console <-> x11 is done now.
 +
 
 +
=== GNOME and GDM ===
 +
{{cmdroot|emerge gnome}}
 +
 
 +
{{WARN| nss failes to emerge on systems with a 3.0 kernel. See Gentoo Bug 372001 }}
 +
[https://bugs.gentoo.org/show_bug.cgi?id=372001 Bug 372001] workaround from [https://bugs.gentoo.org/show_bug.cgi?id=372001#c2 here] allows you to emerge nss.
 +
 
 +
{{cmdroot|emerge gdm}}
 +
 
 +
=== NetworkManager ===
 +
Emerge a newer version of NetworkManager which comes with a built-in gentoo module. You can read more about the module on [http://qiaomuf.wordpress.com/2010/07/29/good-news-the-plug-in-has-been-added-to-portage/ Mu Qioa's Blog]
 +
 
 +
{{cmdroot|<nowiki>emerge =net-misc/networkmanager-0.8.2-r10 --autounmask-write</nowiki>}}
 +
 
 +
{{cmdroot|rc-update add NetworkManager default}}
 +
 
 +
Make sure that the ifnet module (gentoo interface handling) is enabled:
 +
{{path|/etc/NetworkManager/nm-system-settings.conf}}
 +
<pre>
 +
[main]
 +
plugins=ifnet,keyfile
 +
[ifnet]
 +
managed=true
 +
auto_refresh=false
 +
</pre>
 +
 
 +
== Ecryptfs home ==
 +
I have setup an ecryptfs home for my user account and written an how-to about it in the gentoo-wiki.
 +
Read it [http://en.gentoo-wiki.com/wiki/Encrypt_home_directory_with_ecryptfs here]
 +
 
 +
== Fingerprint reader ==
 +
While I don't use the fingerprint reader for auth purposes (It's [http://dasalte.ccc.de/biometrie/fingerabdruck_kopieren?language=en just] [http://www.ccc.de/en/updates/2007/umsonst-im-supermarkt insecure]).
 +
It would be nice to scan some fingers for fun :-).
 +
Unfortunately there [https://bugs.freedesktop.org/show_bug.cgi?id=33666 is a bug] in libfprint that fails every enroll with '''"Enroll failed with error -22"'''. Hopefully it will be fixed soon.
 +
 
 +
{{cmdroot|emerge fprint_demo}}
 +
 
 +
=== Working Fingerprint reader ===
 +
 
 +
If you'd like to use the fingerprint sensors, just emerge following:
 +
 
 +
{{cmdroot|emerge sys-auth/fprintd}}
 +
 
 +
Afterwards edit following:
 +
 
 +
{{Path|<nowiki>/etc/pam.d/system-auth</nowiki>}}
 +
<pre>
 +
...
 +
auth      sufficient  pam_fprintd.so
 +
...
 +
</pre>
 +
 
 +
Enroll your finger :-)
 +
 
 +
{{cmdroot|fprintd-enroll}}
 +
 
 +
== Extra keys ==
 +
Another overview can be found [http://www.thinkwiki.org/wiki/Installing_Ubuntu_11.04_(Natty_Narwhal)_on_a_ThinkPad_X220#Key_table here]
 +
 
 +
=== Functional ===
 +
Most keys work out of the box. Tested so far are:
 +
*  {{key|Fn}}{{key|F2}} lock screen
 +
*  {{key|Fn}}{{key|F3}} display battery status
 +
*  {{key|Fn}}{{key|F4}} suspend to RAM
 +
*  {{key|Fn}}{{key|F5}} enable/disable WLAN (Note that there is also a hardware switch on the left side of the X220 which disabled WLAN '''and''' bluetooth
 +
*  {{key|Fn}}{{key|End}} and {{key|Fn}}{{key|Pos 1}} brightness controll
 +
*  Volume up/down/mute incl. sound mute indicator LED
 +
*  {{ibmkey|ThinkVantage|#495988}}, emits ''XF86Launch1''
 +
*  {{key|Fn}}{{key|F8}} - disable/enable touchpad
 +
From [https://wiki.archlinux.org/index.php/Touchpad_Synaptics#Software_Toggle ArchWiki]: Add the following file and make it executable. Then set the file to be executed when XF86TouchpadOn is pressed via System -> Preferences -> Keyboard Shortcuts.
 +
 
 +
{{Path|<nowiki>/usr/bin/touchpad-toogle</nowiki>}}
 +
<pre>
 +
#!/bin/bash
 +
 
 +
if [ $(synclient -l | grep TouchpadOff | gawk -F '= ' '{ print $2 }') -eq 0 ]; then
 +
    synclient TouchpadOff=1
 +
else
 +
    synclient TouchpadOff=0
 +
fi
 +
</pre>
 +
 
 +
=== Functional with some limitations ===
 +
*  {{Key|MicMute}} emits keycode 248. There is currently some lack of support for this feature. Also the LED is not controllable yet. See these [https://bugs.launchpad.net/ubuntu/+source/linux/+bug/408903 two] [https://bugs.launchpad.net/ubuntu/+source/linux/+bug/788540 bugs]
 +
 
 +
= Notes =
 +
== ThinkLight ==
 +
Can be enabled and disabled with the hardware button and the /sys interface. More information can be found on [[ThinkLight]]

Latest revision as of 11:39, 2 December 2013

Installing Gentoo on a Lenovo X220 with UEFI and GPT

The goal is a working Gentoo installation utilizing UEFI and GPT on an SSD. I work on improving the page step-by-step, but at the moment it's more or less for the advanced gentoo user. Anyways, you can always ask me for clarification. :)

Model specs

General specs

X220 - 4290-W1B, i5-2520M, 4GB RAM

Replaced internal HDD with SSD Intel 320 Series 120GB, 2.5", SATA II (SSDSA2CW120G310). It's a SSD with 7.5mm height, so it fits nicely in the X220. 2.5" 9mm SSDs fit too, but you have to remove parts of the SSDs case.

ATTENTION!
Some Intel 320 Series SSDs are affected by a firmware bug
ATTENTION!
The mSATA Intel 310 Serices SSD requires UEFI BIOS 1.19 (proved with X220 4290-W4H)

cpuinfo

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 42
model name      : Intel® Core™ i5-2520M CPU 2.50GHz
stepping        : 7
cpu MHz         : 2501.000
cache size      : 3072 KiB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 2
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 x2apic popcnt aes xsave avx lahf_lm ida arat epb xsaveopt pln pts dts tpr_shadow vnmi flexpriority ept vpid
bogomips        : 4983.17
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

lspci

00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09)
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
00:16.0 Communication controller: Intel Corporation 6 Series/C200 Series Chipset Family HECI Controller #1 (rev 04)
00:16.3 Serial controller: Intel Corporation 6 Series/C200 Series Chipset Family KT Controller (rev 04)
00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit Network Connection (rev 04)
00:1a.0 USB Controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 1 (rev b4)
00:1c.1 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 2 (rev b4)
00:1c.3 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 4 (rev b4)
00:1c.4 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 5 (rev b4)
00:1d.0 USB Controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation QM67 Express Chipset Family LPC Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation 6 Series/C200 Series Chipset Family 6 port SATA AHCI Controller (rev 04)
00:1f.3 SMBus: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller (rev 04)
03:00.0 Network controller: Intel Corporation Centrino Advanced-N 6205 (rev 34)
0d:00.0 System peripheral: Ricoh Co Ltd Device e823 (rev 04)

lsusb

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 003: ID 147e:2016 Upek Biometric Touchchip/Touchstrip Fingerprint Sensor
Bus 001 Device 004: ID 04f2:b217 Chicony Electronics Co., Ltd 

Required kernel modules for the X220 hardware

  • Intel Gigabit Ethernet: (CONFIG_E1000EI)
  • Intel WLAN: (CONFIG_IWLAGNI)
  • Intel HD Graphic: (CONFIG_DRM_I915I)
  • TPM Chip (CONFIG_TCG_TIS)

There are still no correct settings for MTRR: Link

BIOS update

ATTENTION!
Always use an up-to-date BIOS version. Old versions are known to cause problems with shutdown and wakeup after suspend-to-RAM.

1. Get the bios update iso (8duj10uc.iso here) from the lenovo support site.

2. Get 'geteltorito' and extract the boot image from the iso (isobar.c probably works too)

$ wget 'http://www.uni-koblenz.de/~krienke/ftp/noarch/geteltorito/geteltorito.pl'

$ perl geteltorito.pl 8duj10uc.iso > biosupdate.img

3. Copy the image to the usb thumdrive

# ddrescue biosupdate.img /dev/usbthumdrive

Reboot, Press F12 and boot from thumb drive.

The latest BIOS for the X220 can be found here.

Boot from USB stick

Sysresccd (2.2.0), which has a pretty nice script to create a bootable USB-Stick, failed to boot on the X220. Created an bootable usb stick from the gentoo-minimal.iso with unetbootin. Works.

Partition the drive

# parted

(parted) mklabel gpt

NOTE!
X220s will not boot GPT partitioned drives using Legacy BIOS, so you will have to setup UEFI if you use GPT.

(parted) mkpart primary fat32 1 201

NOTE!
We don't start with sector 0 because of alignment. I am not sure if the result is optimal, but at least parted doesn't complain

(parted) set 1 boot on

(parted) mkpart primary linux-swap 202 4047

(parted) mkpart pimrary ext2 4048 120GB

Format the partitions

# mkfs.vfat /dev/sda1

# mkswap /dev/sda2

# mkfs.btrfs /dev/sda3

NOTE!
The mkfs.btrfs binary is not yet on the gentoo minimal image.

Gentoo installation

Gentoo stage3

Just like the handbook:

  • Boot from gentoo-minimal-image.
  • Unpack stage3 and portage.
  • Edit fstab

/etc/fstab

/dev/sda1		/boot/efi	vfat		noauto		1 2
/dev/sda3		/		btrfs		noatime		0 1
/dev/sda2		none		swap		sw		0 0
  • If you have a SSD, you should use Trim (discard)

/etc/fstab

/dev/sda1		/boot/efi	vfat		noauto		1 2
/dev/sda3		/		btrfs		noatime,discard	0 1
/dev/sda2		none		swap		sw		0 0
  • Set a root password.
  • Everything else can be done later on.

Grub with EFI support installation

This was by far the hardest part. Because UEFI and GPT a relatively new, I am not so familiar with it and the documentation isn't so good at the time of writing. Basically EFI on the X220 looks for a FAT32 formatted GPT partition with the boot flag set. If it finds one it tries to start /EFI/boot/bootx64.efi from this partition. (Note that this is actually case-insensitive because of FAT32).

Enable GRUB_PLATFORMS=efi-64 in make.conf and emerge >=sys-devel/grub-1.99.

# GRUB_PLATFORMS="grub_platforms_efi-64" emerge -v sys-boot/grub

Create a mountpoint for the UEFI partition and mount the partition.

# mkdir /boot/efi

# mount /dev/sda1 /boot/efi

# mkdir /boot/efi/efi/grub -p

Help needed
I don't think that this is needed, it's from the Arch Wiki on UEFI boot. Maybe outdated, please report if it works without for you or simply delete this part.

# cp /usr/share/grub/{unicode.pf2,ascii.pf2} /boot/efi/efi/grub/

Important part:

NOTE!
The efi_gop grub module is very important. If it's not loaded, you won't see anything on boot after grub

# grub2-mkimage -d /lib/grub/x86_64-efi -O x86_64-efi -p "" -o /boot/efi/efi/boot/bootx64.efi part_gpt btrfs fat ext2 normal chain boot configfile linux multiboot efi_gop linux

Optional but useful:

# cp /lib/grub/x86_64-efi/*.mod /boot/efi/efi/boot/

# cp /lib/grub/x86_64-efi/*.lst /boot/efi/efi/boot/

Minimal grub.cfg

set prefix(hd0,gpt1)/efi/boot
pager=1
timeout=20

menuentry "Gentoo Linux" {
        set root=(hd0,gpt3)
        linux /boot/bzImage root=/dev/sda3 ro raid=noautodetect
}

Put grub.cfg in same directory as bootx64.efi: /boot/efi/efi/boot/

Thanks to Finnbarr P. Murphy for his blog posts about Grub and UEFI.

Optimized grub.cfg

Use 'threadirqs' with kernel > 3.0.0 and because PCIE_ASPM is not detected correct (and you may want longer battery life) you should use 'pcie_aspm=force'.

set prefix(hd0,gpt1)/efi/boot
pager=1
timeout=3

menuentry "Gentoo Linux" {
        set root=(hd0,gpt3)
        linux /boot/bzImage root=/dev/sda3 ro fastboot splash=silent quiet threadirqs pcie_aspm=force i915.i915_enable_rc6=1 i915.i915_enable_fbc=1 i915.lvds_downclock=1 rootfstype=ext4
}

According to following links (threads), you should set i915.i915_enable_rc6=1, i915.i915_enable_fbc=1 and i915.lvds_downclock=1 for less power consumption (used kernel: 3.1.0rc3).

Link Forum Notebookreview
Link Ubuntu Launchpad Bugs
Link Archlinux BBS
Link Phoronix Tweaks To Extend The Battery Life Of Intel Linux Notebooks
RedHat Bugzilla

Kernel

For UEFI on the X220 you have to use a kernel > 3.0-rc1. Suspend-to-RAM and brightness control of the display work with kernel >= 3.0-rc6.

My current Kernel .config (3.0-rc6). Please feel free to comment if you have spotted an unnecessary enabled hardware option or something that should be enabled on the X220. The config is hosted as github gist, so you can easily ask for merges with your version. This is work in progress :)

Kernel configuration remarks

  • Use the deadline I/0 scheduler when you have an SSD. If you don't have an SSD, use the CFQ scheduler.

make.conf

/etc/make.conf

CFLAGS="-march=core2 -O3 -pipe"
CXXFLAGS="${CFLAGS}"
CHOST="x86_64-pc-linux-gnu"
MAKEOPTS="-j5 -l5"
GRUB_PLATFORMS="efi-64"
INPUT_DEVICES="evdev synaptics"
VIDEO_CARDS="intel vesa fbdev"

With gcc > 4.2:

/etc/make.conf

CFLAGS="-march=native -O3 -pipe"
CXXFLAGS="${CFLAGS}"
CHOST="x86_64-pc-linux-gnu"
MAKEOPTS="-j5 -l5"
GRUB_PLATFORMS="efi-64"
INPUT_DEVICES="evdev synaptics"
VIDEO_CARDS="intel vesa fbdev"

Finishing touches

Set timezone

# cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime

Locale

# nano /etc/locale.gen # locale-gen

Set LANG in /etc/env.d/90locale

LANG=en_US.utf8
LC_TIME=de_DE.utf8
LC_COLLATE=de_DE.utf8
LC_MONETARY=de_DE.utf8
LC_NUMERIC=de_DE.utf8

Read more here: Gentoo Linux Localization Guide

Hardware setup

WLAN Intel Advanced 6205

# emerge wpa_supplicant linux-firmware

NOTE!
You will see a lot of "DMAR:[DMA Write] Request device [03:00.0] fault addr XXXXXXXX" errors in syslog, caused by the WLAN module/firmware. But the device seems to work just fine

Further installation steps

Emerging the system

xorg

# emerge xorg-x11 The touchpad can be accessed by the evdev and the synaptics driver, which can lead to X11 not starting. To fix this add the following lines to /usr/share/X11/xorg.conf.d/50-synaptics.conf.

     MatchDevicePath "/dev/input/event*"
            Option "TapButton1" "1"
            Option "TapButton2" "2"
            Option "TapButton3" "3"

DPI

$ xdpyinfo gets the displays dimensions wrong, while $ xrandr shows the correct screen size (277x156mm). Although it seems to make no big difference (yet), you could specify the displays dimensions/DPI via one of these two methods manually:

  • Via an xorg.conf:

/usr/share/X11/xorg.conf.d/10-monitor.conf

Section "Monitor"
    Identifier "<default monitor>"
#    Option   "DPI" "125 x 125"
    DisplaySize 277 156    # In millimeters
EndSection

But this doesn't fix the xdpyinfo either (at least in my case).

  • Via xrandr

$ xrandr --dpi 125

KMS

One quick word about Kernel mode-setting (KMS) which comes with Linux 3.0. The i915 driver seems to support it flawlessly and it's really impressing how fast the switch console <-> x11 is done now.

GNOME and GDM

# emerge gnome

ATTENTION!
nss failes to emerge on systems with a 3.0 kernel. See Gentoo Bug 372001

Bug 372001 workaround from here allows you to emerge nss.

# emerge gdm

NetworkManager

Emerge a newer version of NetworkManager which comes with a built-in gentoo module. You can read more about the module on Mu Qioa's Blog

# emerge =net-misc/networkmanager-0.8.2-r10 --autounmask-write

# rc-update add NetworkManager default

Make sure that the ifnet module (gentoo interface handling) is enabled: /etc/NetworkManager/nm-system-settings.conf

[main]
plugins=ifnet,keyfile
[ifnet]
managed=true
auto_refresh=false

Ecryptfs home

I have setup an ecryptfs home for my user account and written an how-to about it in the gentoo-wiki. Read it here

Fingerprint reader

While I don't use the fingerprint reader for auth purposes (It's just insecure). It would be nice to scan some fingers for fun :-). Unfortunately there is a bug in libfprint that fails every enroll with "Enroll failed with error -22". Hopefully it will be fixed soon.

# emerge fprint_demo

Working Fingerprint reader

If you'd like to use the fingerprint sensors, just emerge following:

# emerge sys-auth/fprintd

Afterwards edit following:

/etc/pam.d/system-auth

...
auth       sufficient   pam_fprintd.so
...

Enroll your finger :-)

# fprintd-enroll

Extra keys

Another overview can be found here

Functional

Most keys work out of the box. Tested so far are:

  • FnF2 lock screen
  • FnF3 display battery status
  • FnF4 suspend to RAM
  • FnF5 enable/disable WLAN (Note that there is also a hardware switch on the left side of the X220 which disabled WLAN and bluetooth
  • FnEnd and FnPos 1 brightness controll
  • Volume up/down/mute incl. sound mute indicator LED
  • ThinkVantage, emits XF86Launch1
  • FnF8 - disable/enable touchpad

From ArchWiki: Add the following file and make it executable. Then set the file to be executed when XF86TouchpadOn is pressed via System -> Preferences -> Keyboard Shortcuts.

/usr/bin/touchpad-toogle

#!/bin/bash

if [ $(synclient -l | grep TouchpadOff | gawk -F '= ' '{ print $2 }') -eq 0 ]; then
    synclient TouchpadOff=1
else
    synclient TouchpadOff=0
fi

Functional with some limitations

  • MicMute emits keycode 248. There is currently some lack of support for this feature. Also the LED is not controllable yet. See these two bugs

Notes

ThinkLight

Can be enabled and disabled with the hardware button and the /sys interface. More information can be found on ThinkLight