Debian Wheezy on X120e


IMPORTANT UPDATE: this guide is not up-to-date (for example, with the latest kernel in testing, there is no need to compile wifi drivers from source.). I will update it sometime soon. I also moved from LXDE to Awesome.
This is a quick guide to installing Debian Wheezy amd64 (testing release) on a Lenovo ThinkPad X120e. It deals with the issues specific to installing Debian with LXDE on this netbook. For generic help with Debian, please use your favorite search engine or visit the official Debian web page. Comments are welcome, especially if you point out mistakes or you have useful suggestions: just drop me an email.
I do not assume any legal liability or responsibility for any damage, data loss or inconvenience that you might cause to yourself or to other people by following the procedures below. RTFM, first.

My System Configuration
  • Model: Lenovo Thinkpad X120e
  • CPU: AMD Fusion E-350 (dual core)
  • RAM: 4 GB
  • SSD: Intel X25-M 80 GB (original: HDD 250 GB 5400 rpm) --- Note that I am not configuring this system for a dual boot with Windows 7, as I am installing Debian on this brand-new SSD. If you are going to install a dual boot system, be sure to know what are you doing and always prepare a backup of your data before playing with the partitions of your HDD!
  • Graphic Card: AMD Radeon HD 6300M
  • Display: 11.6" HD LED Anti-Glare, 1366x768
  • Ethernet Adapter: Realtek RTL8111/8168 PCI Express Gigabit Ethernet controller
  • WiFi Adapter: Realtek RTL8188CE 802.11b/g/n WiFi Adapter
  • Bluetooth Adapter: Broadcom Bluetooth controller (ID 0a5c:217f)
  • Battery: 6 cells
  • Original OS: Windows 7 Professional
Main Installation
  • Download the Debian Squeeze (stable release) 6.0.1 amd64 netinst ISO image here and burn it into a USB stick, (1) following this guide, or (2) using unetbootin, or (3) copying the ISO image to a USB pen, formatted in FAT16 and with the boot flag set, using dd:
    # dd if=/path/to/your/ISOFile.iso of=/dev/sdX
    (sdX = your USB pen). If you prefer, you can use a full CD/DVD image. I use the netinst because I have a fast Ethernet connection.
  • Reboot your machine. Make sure you have the UEFI/Legacy Boot set to Both and UEFI/Legacy Boot Priority set to Legacy First in the BIOS.
  • Plug in the USB stick and reboot. By pressing F12 at boot time you will presented with the list of available supports: choose the USB stick. (You might have to enable Boot device List F12 Option in the BIOS first.)
  • Select Alternative Desktop Environments, then LXDE (or the DE of your choice). Then, select Graphical Install, which starts the installation process.
  • Select your language, country, keyboard layout.
  • Choose your hostname, root password and non-privileged user name/password.
  • Select your time zone.
  • Partition the disk. I divided my 80 GB SSD as follows: 1.2 GB (/boot, ext4, primary, boot), 24.0 GB (/root, ext4), 30.0 GB (/home, ext4), 4.2 GB (swap), free space (the remaining). Change this scheme depending on your HD/SSD and your needs. Note that I set my swap to 4.2 GB so that I can suspend-to-disk (hibernate), having 4 GB of RAM.
  • Configure your packet manager: choose your mirror and set up your proxy (if needed).
  • Choose the packages you want to install.
  • Input your workgroup name, if any.
  • Install GRUB to the MBR: you can safely say Yes. If you are installing a dual boot system on the original disk and you want to preserve the Lenovo Recovery Partition, probably you should say No at this step and then you should play with Windows 7 bootloader to add the option for booting Debian.
  • Enjoy some cups of tea or coffee while the installer downloads the required packages and sets up your brand-new machine...
  • Once prompted, remove the USB stick and reboot.
  • You will reboot with Linux 2.6.32-5-amd64 kernel.
  • Move to a virtual console (CTRL+ALT+F2) and login as root.
  • Stop gdm:
    # invoke-rc.d gdm stop
  • Edit your sources:
    # nano /etc/apt/sources.list
  • Replace everywhere squeeze with wheezy. Add repositories contrib and non-free after main. Look here for my sources.list.
  • Perform a full-upgrade:
    # aptitude update
    # aptitude full-upgrade
  • Reboot, choose the 2.6.38.3-amd64 kernel (it should be the default option) and then login on a virtual console as root again, stopping gdm as done before.
  • Install the essentials:
    # aptitude install linux-headers-$(uname -r) build-essential module-assistant dkms
  • Install the fglrx driver:
    # aptitude install fglrx fglrx-driver
  • Create the initial xorg.conf file:
    # aticonfig --initial
  • Install gpointing-device-settings:
    # aptitude install gpointing-device-settings
  • Reboot:
    # reboot
  • You will reboot with the right screen resolution thanks to the ATI/AMD drivers. Use gpointing-device-settings to enable the multi-touch touchpad.
Setting Up the WiFi Card (Realtek 8188CE)
  • Download the official drivers from Realtek support site (RTL8188CE Unix (Linux) section). In my case, I grabbed 92ce_se_de_linux_mac80211_0003.0401.2011.tar.gz.
  • Open a terminal, become root and move to the directory where you downloaded the drivers.
  • Unpack the file:
    # tar xf 92ce_se_de_linux_mac80211_0003.0401.2011.tar.gz
  • Move to the extracted directory and make:
    # make
  • Make install:
    # make install
  • Reboot:
    # reboot
Enabling CPU Scaling
  • Install sysfsutils:
    # aptitude install sysfsutils
  • Install powernowd:
    # aptitude install powernowd
  • Load powernow-k8 module:
    # modprobe powernow-k8
  • You can add powernow-k8 to /etc/modules so that it will be loaded at every boot:
    # echo "powernow-k8" >> /etc/modules
  • Now you can use the interface /sys/devices/system/cpu/cpuX/cpufreq/scaling_governor (X=0,1) to set the CPU scaling to conservative, powersave, userspace, ondemand (default), or performance. Example:
    # echo conservative > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
    # echo conservative > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
  • You can also use this setcpufreq script (it is not written by me but I do not remember where I downloaded it...).
  • I copied the above script in /usr/sbin/ and then I used visudo to grant my regular, non-privileged account the right to run it. You can also add it to your PATH variable, so you can invoke it from command line.
Fixing Supension (Suspend-to-RAM)
Apparently, suspending to RAM does not work well out-of-box: precisely, suspending works fine but resuming yields a blank screen. Reading the logs, it seems to me that the problem is in the r8169 driver, which refuses to sleep. (Initially I blamed the fglrx driver.) A quick workaround is to include it in the modules to unload before suspending and reload after resuming:
  • Open a terminal and become root.
  • Copy the file unload_modules that you can dowload here into your /etc/pm/config.d/ directory.
  • You might want to check that your configuration files /etc/default/fglrx-atieventd, /etc/default/fglrx-driver and /etc/default/acpi-support have the same arguments as mine.
After these few steps, you should be able to suspend to RAM. To resume, open the lid or press the Fn key. Both suspending and resuming take 1-2 seconds.
Swapping the Audio Cards
  • The default audio card is the HDMI output, instead of the speakers. You can make the latter be the default output by copying this file to /etc/asound.conf.
Enabling TRIM and using tmpfs
  • To enable TRIM on the SSD, just add the option discard to the lines of /etc/fstab corresponding to ext4 partitions.
  • I added the following three lines to enable tmpfs:
    tmpfs /tmp tmpfs defaults,nodev,nosuid,mode=1777 0 0
    tmpfs /var/lock tmpfs defaults,nodev,nosuid,noexec,mode=1777,size=100m 0 0
    tmpfs /var/run tmpfs defaults,nodev,nosuid,noexec,mode=0775,size=100m 0 0
Using Feh and Conky on LXDE
  • Install Feh:
    # aptitude install feh
  • Install Conky:
    # aptitude install conky conky-all
  • Comment out the line starting pcmanfm in /etc/xdg/lxsession/LXDE/autostart, by adding a # at the beginning of the line:
    #@pcmanfm --desktop --profile LXDE
  • Append the following line at the end of the same file:
    @feh --bg-center /path/to/your/wallpaper/image.jpg
  • Copy this conky.desktop file in your /home/USERNAME/.config/autostart/ directory. (Create it, if it does not exist.)
  • Logout and login again. Your wallpaper should be managed by feh and you should see your conky information on it.
  • Here you can find my /etc/xdg/lxsession/LXDE/autostart, /etc/conky/conky.conf, and /home/USERNAME/.config/autostart/conky.desktop files.
Some useful key bindings
I wrote a advancedOSD script to be called from the Openbox key bindings, to mimic the behavior of Fn+FX combinations. You have to perform the following steps:
  • Install scrot (command-line utility to take screenshots):
    # aptitude install scrot
  • Install libnotify-bin (command-line utility to send desktop notification):
    # aptitude install libnotify-bin
  • Install amixer (command-line utility to control the mixer):
    # aptitude install amixer
  • Install xinput (command-line utility to control the touchpad/trackpoint):
    # aptitude install xinput
  • Create a directory .bin in your HOME directory.
  • Copy there the advancedOSD script, you can get here, giving it the execution bit.
  • Copy the keybindings section of my lxde-rc.xml file into your ~/.config/openbox/lxde-rc.xml.
Now you can use the following key bindings, which will display also a nice OSD notification:
  • Fn+Esc: Toggle (mute/unmute) volume
  • Fn+F1: Decrease volume by 5%
  • Fn+F2: Increase volume by 5%
  • Fn+F8: Toggle (enable/disable) touchpad
  • Fn+Ins: Take a screenshot (and copy it to ~/.screenshots/)
  • Win: Open an xterm terminal.
  • Alt+Win: Open a lxterminal terminal.
Moreover, the following key bindings works out-of-box:
  • Fn+F4: Suspend the system
  • Fn+Del: Decrease screen brightness
  • Fn+Home: Increase screen brightness
Clearly, you can modify the script and the configuration file to define your own key bindings.
Other Useful Tools
  • Gnome Power Manager (set the suspend/lid action and to control the screen brightness):
    # aptitude install gnome-power-manager
    You might want to create a file /home/USERNAME/.config/autostart/gnome-power-manager.desktop so that GPM will be executed at each login. (Here you can find mine.)
  • Gnome Network Manager (manage the Ethernet/WiFi networks):
    # aptitude install gnome-network-manager
  • Skype: install it from the 64 bit version for Debian you can download here. I installed skype-debian_2.2.0.25-1_amd64.deb:
    # dpkg -i skype-debian_2.2.0.25-1_amd64.deb
    It might require some additional (32 bit) libraries, see the output of the installer if it fails: just use aptitude to install them and then try to install skype again.
  • Cheese (take pictures/videos with the integrated webcam):
    # aptitude install cheese
  • Adding Debian Multimedia repository:
    # wget http://www.debian-multimedia.org/pool/main/d/debian-multimedia-keyring/debian-multimedia-keyring_2010.12.26_all.deb
    # dpkg -i debian-multimedia-keyring_2010.12.26_all.deb
    # echo "deb http://www.debian-multimedia.org wheezy main non-free" >> /etc/apt/sources.list
    # aptitude update
  • UPDATE 08/09/2011: Viktor Stremler contributed the ICC profile x120eicc.tar.gz that you can get here to enhance the LCD colors. It was generated with dispcalGUI.
Not Working / Not Tested
  • Not tested: HDMI output, suspend-to-disk (hibernation).
Notes and Comments
  • I tried to directly install Debian Wheezy using the weekly-built images, with no luck: once the installer did not even start, and the second time the keyboard and the touchpad/trackpoint did not work at the gdm login screen (even if they worked during the installation!) This is why I first installed Debian Squeeze and then performed a full upgrade after changing the repositories from the stable to the testing ones.
  • Since the Fn is the bottom leftmost key and I find this quite inconvenient, I swapped it with the CTRL button by enabling the corresponding option in the BIOS.
  • Some Fn+FX combinations do not work (but maybe they can be bind using the Openbox bindings --- I haven't had time to check this out yet). However, Fn+Del and Fn+Home work and decrease/increase the screen brightness, respectively.
  • If you stick to Debian Squeeze (stable release with 2.6.32 kernel), you will not have the multi-touch touchpad (it is recognized as a generic PS/2 mouse) and the internal microphone will not work, while they work fine in Wheezy (I guess these are kernel-related issues).
  • The integrated webcam (ID 04f2:b1b4) works out-of-box and provides several resolutions in cheese (1280x720, 640x480, and smaller ones). I think that the actual resolution is 0.3 Mpixels (640x480), and so the 1280x720 is extrapolated.
  • The integrated Bluetooth device works, since running bluetooth-applet correctly identifies the device scans for all Bluetooth devices in the surroundings. However, I haven't tried to actually use it yet.
  • Everything not mentioned in the above Not Working/Not Tested section works out-of-box.
  • UPDATE 08/09/2011: Alexey Pechnikov notes that VirtualBox modules crash kernel 3.x on suspend. As I cannot confirm, I just report his workaround: add SUSPEND_MODULES="vboxpci vboxnetadp vboxnetflt vboxdrv" to unload_modules.
Links