Installing Debian on a ThinkPad T420

From ThinkWiki
Jump to: navigation, search

The machine

This is a T420 that I bought secondhand off Ebay in December of 2013. I opted to buy this instead of a new Thinkpad because I dislike the new 6-row keyboards and the buttonless trackpads. This is its configuration:

  • Intel® Core™ i5-2520M (2.5GHz, 3MB L3, 1333MHz FSB)
  • Discrete NVIDIA NVS 4200M (1GB VRAM) with Optimus™ Technology
  • UEFI BIOS Version 83ET76WW (1.46)
  • 4GB DDR3 - 1333MHz main memory
  • 14.0" HD+ (1600 x 900) (230 NITS) TFT display
  • Intel® 82577LM Gigabit (Hanksville) Digital Office ethernet adapter
  • Intel Centrino Advanced-N 6205 (Taylor Peak) 2x2 AGN WLAN adapter

Installation

Preparing a Bootable Flash Drive

I installed Debian 7.3.0 (Wheezy) from a bootable flash drive. The process of creating bootable flash drive is described here. It is helpful to add firmware-iwlwifi to this drive so wireless networking can work while you're installing. The installer will notice this and install it automatically.

Installing wicd With Preseed

A helpful extra step is to use preseeding to have wicd installed automatically and to add the first user added to the sudo group. With wicd you can easily connect to a WiFi access point without a GUI. Create a text file named preseed.cfg on the flash drive and put the following in it:

d-i passwd/user-default-groups string cdrom floppy sudo audio dip \
    video plugdev netdev scanner bluetooth
d-i pkgsel/include string sudo wicd-curses wicd-cli

At the bottom of the aforementioned instructions on making a bootable flash drive are instructions on getting the preseed.cfg file installed to the drive.

When you boot into your new system, remember that you need to explicitly tell wicd what the wireless LAN device is. Use the # ifconfig command to check what it is. This turned out to be wlan0 for me, but it might be different if you have a different interface.

Preseeding is a great way to preselect what you want an install to do, saving you time and aggravation. Read more about it here and here. As demonstrated here, you don't have to have a long and drawn-out preseed.cfg file.

Booting the Flash Drive

Plug in your bootable flash drive and turn on your T420. Quickly press F1 to get into the BIOS. Check to make sure that booting from a USB flash drive is enabled. Don't change its priority. If you changed anything, save and exit to reboot the machine. Quickly press F12 to get a boot menu and select the flash drive. The Debian installation process will then begin.

Not Installing a GUI

After answering questions about what keyboard you have, timezone, root password, first user, and so on; you will be shown a menu of software to install. There are ten options. "Debian Desktop Environment", "Print server", "Laptop", and "Standard system utilities" should be preselected for you. If you don't care for Gnome3, deselect "Debian Desktop Environment". That will yield a machine with no GUI at all. Detailed below is the procedure for installing MATE.

The remaining steps of the install process are uneventful. You will end up with a bootable and usable system.

Post-Install Configuration

MATE Desktop

Add this line to /etc/apt/sources.list:

 deb http://packages.mate-desktop.org/repo/debian/ wheezy main

Then update your APT cache

 #  apt-get update

Install the MATE keys with

 #  apt-get install mate-archive-keyring

and press 'Y' when you're asked if your sure. Then do:

 #  apt-get install mate-desktop-environment

This installs the basic environment. If you want more, do:

 #  apt-get install mate-desktop-environment-extra

Now, if you don't want to install gdm3, you'll need to install the xinit package:

 #  apt-get install xinit

This will enable you to start an X session by typing "startx".

Sleep and Hibernate

Install the packages hibernate and nvram-wakeup. The thinkpad and nvram modules should automatically install without needing to list them in /etc/modules. After a reboot, the Fn-F4 and Fn-F12 key combinations will cause suspend-to-RAM and hibernate-to-disk respectively.

Discrete Graphics versus Integrated Graphics

Make sure you have Nvidia Optimus and switchable graphics enabled in the BIOS. Then install Bumblebee.

Read this from the Debian wiki about Bumblebee. This tool is now included in the Debian repos. Basically, it boils down to this:

Add this line to /etc/apt/sources.list:

 deb http://YOURMIRROR.debian.org/debian wheezy-backports main contrib non-free

Do apt-get update and then install linux headers as shown below. It is important that you do this before installing anything else related to Bumblebee or else the bbswitch module won't be built and optirun will not run. The official Debian howto doesn't mention this:

 #  apt-get install linux-headers-$(uname -r)

Now you can install Bumblebee. Do it like this:

 #  apt-get install -t wheezy-backports bumblebee-nvidia primus mesa-utils

This specifies that you want to use the proprietary drivers. Remove -nvidia from bumblebee-nvidia if you want the open-source ones. If you want to install i386 libs, do this instead:

 #  dpkg --add-architecture i386
 #  apt-get update
 #  apt-get install -t wheezy-backports bumblebee-nvidia primus primus-libs:i386 mesa-utils

Edit /etc/bumblebee/bumblebee.conf and look for the "[driver-nvidia]" section. There you will see a line that looks like this:

 KernelDriver=nvidia

Change that to:

 KernelDriver=nvidia-current

Reboot your T420. Then start an X11 session. Start a terminal emulator and type:

 optirun glxgears -info

Unfortunately glxgears is a very poor test of 3D acceleration. http://unigine.com has several benchmarks of varying sophistication and cost (some are free as in beer). These benchmarks will yield good results if the quality is set to "low". Another good benchmarker is glxspheres which can be found at http://sourceforge.net/projects/virtualgl. If you install the .deb file, the binaries will be installed to /opt/VirtualGL/bin.

You might want to explicitly tell Bumblebee to use the primus acceleration/rendering bridge rather than auto. See the line that begins with "Bridge=primus".

Laptop video interfaces are always rather poor compared to desktop ones, so don't be disappointed when your top-of-the-line laptop pales in comparison to a desktop in the graphics department.

If You Break Something

I managed to break Bumblebee by following some bad advice on getting 32-bit libraries installed so I can run 32-bit binaries with the Nvidia GPU. I installed the "install libgl1-nvidia-glx:i386" package. To get out of this, I did

# apt-get remove bumblebee bumblebee-nvidia

# apt-get autoremove

# apt-get install -t wheezy-backports bumblebee-nvidia primus primus-libs:i386

# apt-get install -t wheezy-backports xserver-xorg-video-nvidia

# apt-get install xserver-xorg-video-intel

Reboot and all should be well.

If this doesn't work, you may also need to check /etc/bumblebee/bumblebee.conf. Look for the LibraryPath and XorgModulePath variables. For paths ending in nvidia, and /current.

Integrated Webcam

Skype immediately noticed the camera and used it without trouble.