Lenovo Thinkpad X201s & Debian Linux
They essentially built the smallest thinkpad you could whilst still using the full-sized Thinkpad keyboard. As a result it's very nice to use, my main complaint is the lack of HDMI port.
- lsusb -v output
- lspci -vv output
- dmidecode output
- acpidump output
- kernel .config
- kernel patches
- dmesg during boot
- /etc/X11/xorg.conf
- /etc/modprobe.d/x201s_hw.conf
The following page details some of the weirder bits you'd encounter whilst installing Debian (or another linux) on the X201s. If you need a more general guide on installing Debian, then I suggest going elsewhere first and come back for specifics.
↑Hardware
Replacing HDD
The HDD is a regular 2.5" SATA drive, and easily replacable (pull out, replace 2 screws).
BIOS Setup
To enter the BIOS, hold down F1.
Intel AMT
This is a system to remotely administer your machine, whilst you may not have a need for this, it has to be enabled for temperature sensing to work. In theory you should also be able to use this to give the system a virtual CD drive too.
Memory upgrades
Whilst faster newer memory can work, the X201s is picky. I experienced the below when nabbing modules from an X230:
https://forums.anandtech.com/threads/thinkpad-x201-ram-upgrade.2447284/
...however ordering matched modules from Crucial worked.
↑Installation
Partitions on the HDD
There are 3 partitions by default on the HDD:-
- Hidden SYSTEM_DRV partition:
- Alternative windows install with diagnostic programs, triggered by holding down ThinkVantage. Whilst the BIOS prompts for this, this is only because it is written on the splashscreen. The switch is done by a custom MBR, without it there will be a boot menu. Thinkwiki has more.
- Windows:
- The main windows partition, nothing interesting.
- Hidden install media partition:
- A partition containing WIM (tar-like) images of the first 2 partitions. A preinstalled utility allows you to burn these onto any install media. Virtual CD can be used to "write" these onto bootable DVD ISOs.
All are safe to remove if you don't want them.
Booting
Since generally you will not have a CD drive, follow these instructions to make a bootable USB stick (or SD card, since the SD slot is USB connected and can be booted from).
Kernel
The stock Debian kernel will just work generally here.
↑Graphics configuration
Xorg - intel
Generally works with modesetting. An xorg.conf isn't necessarily required, however I have one to set monitor positions, etc at startup.
↑Powersaving/ACPI configuration
There are a bundle of changes that PowerTOP suggests:
echo min_power > /sys/class/scsi_host/host0/link_power_management_policy echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
CPU Frequency Scaling
ACPI-compatible frequency scaling will alter the frequency from 1.1Ghz to 2.1Ghz. Install cpufrequtils and the ondemand govenor will be enabled on startup.
Sleep States
Suspend to RAM and suspend to disk all seem to work fine out of the box.
↑Input devices
Keyboard
The keyboard is ace, being a thinkpad. There are 2 keyboard devices, a regular PS/2 keyboard and the "ThinkPad Extra Buttons" provided by thinkpad_acpi. Both should just work with a newish kernel.
Making Fn-F5 disable bluetooth
The new udev mappings by default make Fn-F5 KEY_WLAN. As of 2.6.31 this causes rfkill to disable the wireless for you. This is fairly useless since there is already an rfkill switch. Remapping it to KEY_BLUETOOTH causes it to toggle bluetooth, which is much more useful. Create a /etc/udev/rules.d/x201s_bluetooth.rules containing:
ENV{DMI_VENDOR}=="LENOVO*", KERNELS=="input*", ATTRS{name}=="ThinkPad Extra Buttons", RUN+="keymap $name /etc/udev/keymaps/module-lenovo"
And a new keymap /etc/udev/keymaps/module-lenovo containing:
0x4 bluetooth # Fn+F5
Programming the rest of the Thinkpad keys
Every other key should just be available as a key to Xorg, I use kbindkeys to then map them to s2ram, etc. For example, .xbindkeysrc contains:
###### Hardware volume keys "/usr/bin/amixer -q set Master toggle" XF86AudioMute "/usr/bin/amixer -q set Master 5%-" XF86AudioLowerVolume "/usr/bin/amixer -q set Master 5%+" XF86AudioRaiseVolume ###### Hardware media keys "/usr/bin/mocp --stop" XF86AudioStop "/usr/bin/mocp --toggle-pause" XF86AudioPlay "/usr/bin/mocp --previous" XF86AudioPrev "/usr/bin/mocp --next" XF86AudioNext
Trackpoint
The trackpoint is a regular PS/2 mouse, I haven't got a touchpad so have no idea how that might be wired.
Bluetooth
The bluetooth is internally a USB dongle. thinkpad_acpi lets you plug it in and remove it (turning the light on/off in the process) and registers with rfkill to control it. To do this yourself use the rfkill tool:
# rfkill list 8: tpacpi_bluetooth_sw: Bluetooth Soft blocked: no Hard blocked: no # rfkill block 8
Whilst you can also control it with /proc/acpi/ibm/bluetooth, this causes rfkill to go out of sync. You can also turn it off on startup with the following in /etc/rc.local:
rfkill list | awk '/tpacpi_bluetooth_sw/ { gsub(/:$/,"",$1); print $1 }' | xargs rfkill block
Fingerprint Reader
The fingerprint reader is supported by the upeke2 driver in fprint. Not the upeksonly driver despite having the same USB ID. Installing fprint_demo will let you play with it. It seems to only support recognising a single predefined image, i.e. it can't tell you which of your fingers you scanned.
Accelerometer
The accelerometer is supported by the tp_smapi module (not the mainlined hdaps module). This will also give you access to further battery settings too. To play with it:
# m-a -t a-i tp-smapi # modprobe tp_smapi # modprobe hdaps # NB: This isn't the same as mainline hdaps, but a modified version to work with tp_smapi) # evtest /dev/input/eventX # Where X is the new devices that appeared
↑Other bits
HDA Sound and system beep
Mostly works, however the PC speaker beep is handled by the BIOS out of the box, which mutes the normal output whilst beeping in a jarring way. This can be disabled (and save some power) by making /etc/modprobe.d/snd_hda_intel.conf:
# The pc speaker mutes other sound output, which is really annoying blacklist pcspkr options snd_hda_intel power_save=1 bdl_pos_adj=0
↑Windows installation (under KVM)
Turning OEM Windows 7 install into KVM image
Whilst you still can boot into windows, back up your windows activation. I used ABR for this. The backup can be restored onto a stock Win7 installation.
Next, you need to generate a custom BIOS for KVM to use, using seaslic.
Get a copy of a Windows 7 ISO (there used to be direct downloads, but now it's up to you), and an ISO containing the VirtIO drivers for windows.
Create a blank image to use:
qemu-img create -f qcow2 win7_clean.qcow2 30G
Create a shell script to launch the virtual machine, so you don't have to remember all the KVM options. For example:
cat <<EOF > start.sh #!/bin/sh kvm -m 2048M -usb \ -bios custom-seaslic-image.bios \ -drive file="${1-win7_clean.qcow2}",if=virtio \ -net nic,model=virtio,macaddr=52:54:00:12:34:56 -net user \ -monitor stdio \ -cdrom win7_pro_x64_technet.iso -boot once=d \
Run the script and start installing windows. You will need to put the virtio CD in at the appropriate moment. To do this:
(qemu) change ide1-cd0 ../isos/virtio-win-0.1-30.iso
Don't forget to put the Windows 7 CD back:
(qemu) change ide1-cd0 /mnt/moo/iso/win7_pro_x64_technet.iso
You should have an unactivated windows installation. Remove the -cdrom
line from start.sh now. Finally, you can restore your activation by
putting ABR onto a fake USB stick:
dd if=/dev/zero of=abr.img bs=1M count=10 mkfs.ntfs -F abr.img ntfs-3g abr.img /mnt/oink/ cp -r ./ABR /mnt/oink/ umount /mnt/oink/ (qemu) usb_add disk:abr.img
I was also hit by a faulty wship6.dll.
Creating and using snapshots
One really neat advantage of using KVM is you get to snapshot your windows
installation and always return to a known point. To get this going, make
your win7_clean.qcow2
read-only and add -snapshot
to start.sh. Now
any changes to windows will only last that session.
You can also store your changes in a separate image, make thus:
qemu-img create -f qcow2 -b win7-clean.qcow2 trying-some-software.qcow2
And then start windows with:
./start.sh trying-some-software.qcow2
Since we still have -snapshot
in start.sh, it still won't write back to
trying-some-software.qcow2
. To commit any changes, restart windows
holding F8 (just so it doesn't boot), and do:
(qemu) commit all
Installing a Windows XP image
Windows XP could be installed with a similar process, although for this laptop it will be a fresh install. The other difference is that it doesn't support CDs at installer boot time. Instead:
- Set the main HDD to
model=ide
and add another temporary HDD that ismodel=virtio
. - Install XP onto the IDE HDD. After installation, install the virtio drivers.
- Shutdown, remove temporary HDD and turn main HDD to
model=virtio
.