Installing Gentoo on a ThinkPad X220
Contents
DRAFT! Installationdiary - Gentoo on a X220 DRAFT!
Model Specs
X220 - 4290-W1B
replaced internal HD with SSD Intel SSD 320 Series 120GB, 2.5", SATA II (SSDSA2CW120G310)
cpuinfo
processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 42 model name : Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz stepping : 7 cpu MHz : 2501.000 cache size : 3072 KB 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 Device 0104 (rev 09) 00:02.0 VGA compatible controller: Intel Corporation Device 0126 (rev 09) 00:16.0 Communication controller: Intel Corporation Cougar Point HECI Controller #1 (rev 04) 00:16.3 Serial controller: Intel Corporation Cougar Point KT Controller (rev 04) 00:19.0 Ethernet controller: Intel Corporation Device 1502 (rev 04) 00:1a.0 USB Controller: Intel Corporation Cougar Point USB Enhanced Host Controller #2 (rev 04) 00:1b.0 Audio device: Intel Corporation Cougar Point High Definition Audio Controller (rev 04) 00:1c.0 PCI bridge: Intel Corporation Cougar Point 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.3 PCI bridge: Intel Corporation Cougar Point PCI Express Root Port 4 (rev b4) 00:1c.4 PCI bridge: Intel Corporation Cougar Point PCI Express Root Port 5 (rev b4) 00:1d.0 USB Controller: Intel Corporation Cougar Point USB Enhanced Host Controller #1 (rev 04) 00:1f.0 ISA bridge: Intel Corporation Device 1c4f (rev 04) 00:1f.2 SATA controller: Intel Corporation Cougar Point 6 port SATA AHCI Controller (rev 04) 00:1f.3 SMBus: Intel Corporation Cougar Point SMBus Controller (rev 04) 03:00.0 Network controller: Intel Corporation Device 0085 (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
Kernel Modules
- Intel Gigabit Ethernet: e1000e
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.
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
mklabel gpt
mkpart primary fat32 1 201
set 1 boot on
mkpart primary linux-swap 202 4047
mkpart pimrary ext2 4048 120GB
Format the partitions
mkfs.vfat /dev/sda1 mkswap /dev/sda2 mkfs.btrfs /dev/sda3
Note that mkfs.btrfs is not yet on the gentoo minimal image.
Gentoo stage3
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.
Grub with efi support installation
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
Not sure if this is needed:
cp /usr/share/grub/{unicode.pf2,ascii.pf2} /boot/efi/efi/grub/
grub2-install --boot-directory=/boot/efi/efi --bootloader-id=grub --no-floppy --recheck
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
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/
Put grub.cf in same directory as bootx64.efi -> /boot/efi/efi/boot/
Thanks to Finnbarr P. Murphy for his blog posts about Grub and UEFI