Debian Squeeze on a ThinkPad X201

Note: boot windows first and create the Rescue and Recovery Media immediately after unboxing..

Note #2: yes, there are Intel i915 video issues, but both the Debian Squeeze d-i graphical and text installers work fine with this video chipset, however, the screen is blank on first boot – either a) install the SSH Server task and log in via ssh for module and xorg.conf edits, or b) boot into single user mode on first boot with “i915.modeset=0” to make the edits.

Note #2 Update: linux-2.6 version 2.6.32-19 was uploaded to unstable 2010-08-05 – this kernel image is working well for me and none of the configuration changes to get vesa working should be necessary.

How not to start:

The very first thing I did, after opening the box, was boot the latest Debian Squeeze net install from USB and got to work – I had a heck of a time with R&R Media creation after the fact. R&R 4.3 is quite different than older versions, and I could not boot into it from the Grub bootloader – writing Grub to the master boot record, as I usually do, hosed booting to the Rescue and Recovery partition as well as using R&R fully from within Windows 7 for some reason. Attempting to reinstall R&R 4.3 fails while trying to write the MBR (which is IBM/Lenovo’s suggested fix to MBR problems..)

I finally got the media created on an 8GB USB flash disk, after some dreaded Windows MBR hacking only to find that the R&R USB key was not bootable, and I could not create the Recovery Media a second time – one attempt is all you get.. After mounting the R&R partition (label: Lenovo_Recovery) under linux and digging around, I found the simple edit of $MOUNT/factoryrecovery/service_done.ini from “DONE=1” to “DONE=0” allowed the factory reset Recovery Media to be written again. Nice. The trick to getting my USB key to be bootable was to completely zero out the boot blocks of the key, plug it in while running windows and quick format NTFS on it, and then go fire up R&R Rescue Media creation – the boot and data recovery media takes up ~6.5GB on the key. Now that I finally had bootable recovery media, the X201 got a factory reset so I could start over fresh.. all my previous day’s research and gave me some ideas on how I wanted to proceed.

Starting from unboxing the X201: 😉

Note: the goal here is to have a working ThinkVantage button to access the Lenovo Rescue and Recovery partition, as well as a fully functional Windows 7 and Debian Squeeze dual-boot. The key to this is to not touch the Windows/Lenovo MBR. Do not install Grub to the MBR!

Boot Windows 7 and run through the quick user setup stuff. 1) Create the Rescue and Recovery Factory Restore Media – I used an 8GB USB flash disk. (make sure the thing actually boots..) 2) Shrink the Windows7_OS volume from within Windows (Start – right-click on Computer – Manage, then something like storage or disks.. select the Windows partition and shrink it – the space used was about 22GB (sad as there is nothing but the OS, Lenovo tools, and an unlicensed MS Office installed..), so I gave it 40GB. (BTW, ntfsresize within d-i worked fine on my first install, but using the volume shrink within Windows to free up space was simple and certainly assured to be pleasing to windows..)

Boot the Debian Squeeze d-i installer and install as normally in the free space, but do not install Grub to the MBR. Install Grub to the /dev/sdaX device that you set up for the “/” filesystem (or “/boot” if you set up a separate boot partition). I usually use a 256MB USB flash disk with the netinst.iso and non-free firmware for installing on anything that I don’t PXE boot. This is not a d-i lesson – google how to do this.

It is probably possible to re-set the bootable bit on the Windows partition during install – d-i attempted to set the bootable bit on my “/” partition (it’s extended and actually won’t set it), removed the bootable bit from the Windows partition, and upon reboot after install, I got no bootable partitions found. A quick run back into Rescue Mode in d-i, and a toggle bootable on the Windows partition with fdisk is all that took – Windows booted back up fine as normal, the ThinkVantage button works fine, and all is well.. except no default Debian boot, yet.

So as not to screw up the killer ThinkPad feature of the blue ThinkVantage button, this means leaving the Lenovo-customized Windows 7 Master Boot Record intact. I decided to try to use the Windows bootloader to boot to grub on my Debian “/” partition. In my digging around on my Lenovo R&R access issues, I found a reference to EasyBCD by NeoSmart to manage dual-booting Windows versions – this little Windows utility manages the cryptic BCD (Boot Configuration Data database) to easily set up booting a multitude of operating systems. Bravo – trying to do this all by hand was miserable..

After installing EasyBCD, I added a Debian boot menu entry, set it as the default, set a timeout of 3 seconds under “Change Settings”, saved my changes, and rebooted.. Windows boot menu comes up, boots grub from my “/” partition, and everything looks great.. oh yeah, no video 🙂

Edit /etc/default/grub and set:

GRUB_CMDLINE_LINUX="i915.modeset=0"

run (as root):

update-grub

Edit /etc/modprobe.d/i915-kms.conf and set:

options i915 modeset=0

run (as root):

update-initramfs -u

Create /etc/X11/xorg.conf (as root) with:

# Minimal xorg.conf for the device driver
Section "Device"
	Identifier	"Default screen"
	Driver		"vesa"
EndSection

Reboot. Perfection. (until Intel gets their video driver support sorted out..)

By the way, this X201 is the type-model 3249-CTO – here’s the lspci output:

00:00.0 Host bridge: Intel Corporation Core Processor DRAM Controller (rev 02)
00:02.0 VGA compatible controller: Intel Corporation Core Processor Integrated Graphics Controller (rev 02)
00:16.0 Communication controller: Intel Corporation 5 Series/3400 Series Chipset HECI Controller (rev 06)
00:16.3 Serial controller: Intel Corporation 5 Series/3400 Series Chipset KT Controller (rev 06)
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)
00:1a.0 USB Controller: Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller (rev 06)
00:1b.0 Audio device: Intel Corporation 5 Series/3400 Series Chipset High Definition Audio (rev 06)
00:1c.0 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 1 (rev 06)
00:1c.3 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 4 (rev 06)
00:1c.4 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 5 (rev 06)
00:1d.0 USB Controller: Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller (rev 06)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev a6)
00:1f.0 ISA bridge: Intel Corporation Mobile 5 Series Chipset LPC Interface Controller (rev 06)
00:1f.2 SATA controller: Intel Corporation 5 Series/3400 Series Chipset 6 port SATA AHCI Controller (rev 06)
00:1f.3 SMBus: Intel Corporation 5 Series/3400 Series Chipset SMBus Controller (rev 06)
00:1f.6 Signal processing controller: Intel Corporation 5 Series/3400 Series Chipset Thermal Subsystem (rev 06)
02:00.0 Network controller: Intel Corporation Centrino Ultimate-N 6300 (rev 35)
ff:00.0 Host bridge: Intel Corporation Core Processor QuickPath Architecture Generic Non-core Registers (rev 02)
ff:00.1 Host bridge: Intel Corporation Core Processor QuickPath Architecture System Address Decoder (rev 02)
ff:02.0 Host bridge: Intel Corporation Core Processor QPI Link 0 (rev 02)
ff:02.1 Host bridge: Intel Corporation Core Processor QPI Physical 0 (rev 02)
ff:02.2 Host bridge: Intel Corporation Core Processor Reserved (rev 02)
ff:02.3 Host bridge: Intel Corporation Core Processor Reserved (rev 02)

If you have 4+GB RAM and are using the i386 architecture, install linux-image-2.6-686-bigmem (I thought about installing x86_64, but I’m currently having to hack around day-to-day issues like using flash and enigmail on my 64-bit desktop install..). If you didn’t set up non-free firmware during install, then go do that. I have the Intel Centrino Ultimate-N 6300 wireless card, so d-i installed the firmware-iwlwifi package for me.

12 thoughts on “Debian Squeeze on a ThinkPad X201”

  1. How do you install drivers for wireless and wire network interfaces during installation?
    Did you use net-install? or install it fully from dvd?

    1. I use the netinst iso and grab the non-free firmware tarball and extract in /firmware on the USB key. You can also just grab the new firmware netinst iso image from the daily builds 😉

  2. good job. I went as well through these troubles with Sqeeze installation on x201.
    for the Grub issue, after installation I’ve just upgraded Grub (I use version 2)

    regarding display: the vesa driver doesn’t perform well. so my recommendation is to get kernel 2.6.34, then change /usr/src/linux-2.6.34.1/drivers/gpu/drm/i915/intel_display.c
    find line 884 and replace
    int err_most = (target >> 8) + (target >> 10);
    by
    int err_most = (target >> 8) + (target >> 9);

    —————–Extract from my current kernel
    bool found;
    /* approximately equals target * 0.00488 */
    int err_most = (target >> 8) + (target >> 9); *****HERE REPLACE 10 by 9*****
    found = false;

    if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
    int lvds_reg;

    if (HAS_PCH_SPLIT(dev))
    lvds_reg = PCH_LVDS;
    else
    lvds_reg = LVDS;
    if ((I915_READ(lvds_reg) & LVDS_CLKB_POWER_MASK) ==
    LVDS_CLKB_POWER_UP)
    clock.p2 = limit->p2.p2_fast;
    else
    clock.p2 = limit->p2.p2_slow;
    } else {

    so enjoy it (compiz included).. 🙂

    1. (that formatting is not going to appear correctly.. sorry about that) I have seen this patch, and I’m not currently in need of accelerated graphics, but thanks for the patch note. As I mentioned in the last little bit – Intel and Linus need to get this chipset working correctly in the vanilla kernel, then it will trickle down to the distributions, etc.. 🙂 I’ve had similar issues with fglrx and new ATI chipsets, nvidia, etc.. over the years – it will get fixed upstream, and I’m perfectly happy not maintaining my own patched kernel – vesa is working great for everything I need so far.

  3. I added an update to the post:

    Note #2 Update: linux-2.6 version 2.6.32-19 was uploaded to unstable 2010-08-05 – this kernel image is working well for me and none of the configuration changes to get vesa working should be necessary.

  4. Hi Michael,
    I’m about receiving the same maachine, I will follow your wise advice and not installing grub on the MBR (I encountered many problems with GRUB install on MBr with my previous VAIO laptop).What tool did yoy use to resize the partition ? I will get a 256Gb SSD and I wondered about using Microsoft proprietary tools , or tools made for Windows or using the good old gparted as a live disk ?

    Thanks for your reply
    Kind regards
    jerome

  5. Thanks for your reply Michael…
    Just a small question more, what is the average autonomy seen with your laptop ?
    lenovo seems to be proud to announce 9-11hours with a 9 cells battery on the X201 with i7 620M processor … It sounds fantastic and far more superior than the one seen with my VAIO with the same processor (about 4 hours maximum)

    Regards
    Jerome

    1. My X201 has an i5 M520, so it’s not an exact comparison, but using a default Debian Gnome install, banging away on all my normal activity, with the screen 2 ticks down from full brightness (which is where I normally keep it), I get about 4 hours on my 9-cell battery. If I disable everything possible in powertop and crank the screen down to barely readable, I can probably get another 30-45 minutes.

      The amazing numbers that OEMs give for battery life (and most other numbers..) are usually contrived.. proc scaled all the way down, disk parked, fan off or barely running, all radios disabled, screen off, running DOS 6.22, with a stopwatch that just happens to run a little fast.. 😉

  6. You’re right Michael, with my VAIO I fine tuned the battery usage using powertop , laptop-mode and all other tools … I hope that the SSD drive will contribute to get a low power consumption… I should receive my machine next week so more coming soon…

    Thanks
    jerome

  7. Hi, Michael,
    I did a stupid thing before I am reading your article. I did over write the MBR after I made the factory recovery disks. But when I again want to restore Win 7, the rescue and recovery works at the beginning. But it soon says the recovery has been finished before actually doing anything. The whole local drive is still there intact.
    Do you have any suggestions about the next I can do? Thanks.

Comments are closed.