{"id":46,"date":"2009-04-01T10:43:24","date_gmt":"2009-04-01T10:43:24","guid":{"rendered":"https:\/\/chroot-me.in\/newblog\/2009\/04\/46\/"},"modified":"2014-01-30T02:37:32","modified_gmt":"2014-01-30T01:37:32","slug":"lenovo-thinkpad-x300-and-linux-configuration-and-power-management","status":"publish","type":"post","link":"https:\/\/chroot-me.in\/blog\/2009\/04\/lenovo-thinkpad-x300-and-linux-configuration-and-power-management\/","title":{"rendered":"Lenovo Thinkpad X300 and Linux &#8211; Configuration and power management"},"content":{"rendered":"<p>I recently replaced my Macbook with a Lenovo Thinkpad X300 notebook. Here are some notes and tips concerning GNU\/Linux installation and configuration for an optimal day to day use.<\/p>\n<div style=\"border-bottom: 1px black solid; margin: 0;\"><\/div>\n<h3>UPDATE (2011\/07)<\/h3>\n<p>Here are my current settings for power management :<\/p>\n<p><strong>\/etc\/rc.local:<\/strong> Simplified, no more vm.laptop_mode (not useful with a ssd).<\/p>\n<div class=\"cmd\">\n<pre># Audio powersave\r\necho 1 &gt; \/sys\/module\/snd_hda_intel\/parameters\/power_save\r\n\r\n# For thinkfan\r\necho watchdog 0 &gt;| \/proc\/acpi\/ibm\/fan\r\nchmod 666 \/proc\/acpi\/ibm\/fan\r\n\r\n# For PHC Voltage regulation kernel patch http:\/\/www.linux-phc.org\r\necho 15 15 15 &gt;| \/sys\/devices\/system\/cpu\/cpu0\/cpufreq\/phc_vids\r\necho 15 15 15 &gt;| \/sys\/devices\/system\/cpu\/cpu1\/cpufreq\/phc_vids<\/pre>\n<\/div>\n<p><strong>\/etc\/thinkfan.conf:<\/strong> Simplified, less fan, more silence :)<\/p>\n<div class=\"cmd\">\n<pre>(0,     0,      40)\r\n(1,     35,     58)\r\n(2,     56,     64)\r\n(5,     58,     128)<\/pre>\n<\/div>\n<p>Do not forget to follow <tt>powertop<\/tt> indications.<\/p>\n<div style=\"border-bottom: 1px black solid; margin: 0;\"><\/div>\n<p>First, the specs of this new toy:<\/p>\n<p><strong>*<\/strong> Intel\u00ae Core 2 Duo SL7100<\/p>\n<p><strong>*<\/strong> 2x1Go PC2-5300 DDR<\/p>\n<p><strong>*<\/strong> 64GB SSD<\/p>\n<p><strong>*<\/strong> 1.61 Kg with 6 cells main battery and Ultrabay 3 cells secondary battery<\/p>\n<h3>Hardware<\/h3>\n<p>Then, <strong>lspci<\/strong> output:<\/p>\n<div class=\"cmd\">\n<pre>00:00.0 Host bridge: Intel Corporation Mobile PM965\/GM965\/GL960 Memory Controller Hub (rev 0c)\r\n00:02.0 VGA compatible controller: Intel Corporation Mobile GM965\/GL960 Integrated Graphics Controller (rev 0c)\r\n00:02.1 Display controller: Intel Corporation Mobile GM965\/GL960 Integrated Graphics Controller (rev 0c)\r\n00:19.0 Ethernet controller: Intel Corporation 82566MM Gigabit Network Connection (rev 03)\r\n00:1a.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #4 (rev 03)\r\n00:1a.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #5 (rev 03)\r\n00:1a.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #2 (rev 03)\r\n00:1b.0 Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 03)\r\n00:1c.0 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 1 (rev 03)\r\n00:1c.1 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 2 (rev 03)\r\n00:1c.2 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 3 (rev 03)\r\n00:1d.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #1 (rev 03)\r\n00:1d.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #2 (rev 03)\r\n00:1d.2 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #3 (rev 03)\r\n00:1d.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #1 (rev 03)\r\n00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev f3)\r\n00:1f.0 ISA bridge: Intel Corporation 82801HBM (ICH8M-E) LPC Interface Controller (rev 03)\r\n00:1f.1 IDE interface: Intel Corporation 82801HBM\/HEM (ICH8M\/ICH8M-E) IDE Controller (rev 03)\r\n00:1f.2 SATA controller: Intel Corporation 82801HBM\/HEM (ICH8M\/ICH8M-E) SATA AHCI Controller (rev 03)\r\n00:1f.3 SMBus: Intel Corporation 82801H (ICH8 Family) SMBus Controller (rev 03)\r\n03:00.0 Network controller: Intel Corporation PRO\/Wireless 4965 AG or AGN [Kedron] Network Connection (rev 61)<\/pre>\n<\/div>\n<p>About <strong>lsusb<\/strong>, just one useful line:<\/p>\n<div class=\"cmd\">\n<pre>Bus 003 Device 002: ID 0483:2016 SGS Thomson Microelectronics Fingerprint Reader<\/pre>\n<\/div>\n<p><em>Important note: since I disabled Bluetooth, WiMAX and the touchpad in the BIOS,<\/em><\/p>\n<p>they are not present in lspci and lsusb outputs, but both Bluetooth and touchpad are functional with Ubuntu.<\/p>\n<p>Quite a modern hardware, and thus some issues concerning Linux support. Indeed, only the <strong>2.6.28<\/strong> offers a good support, previous versions are either bugged or <em>hackish<\/em>.<\/p>\n<h3>Operating System<\/h3>\n<p>I chose <strong>Ubuntu 9.04<\/strong> <em>beta<\/em> for an easy yet fine setup, with LVM+Crypto for the root partition. However a bug in <em>xserver-xorg-evdev<\/em> in 64 bits edition breaks the must-have <a href=\"http:\/\/www.thinkwiki.org\/wiki\/How_to_configure_the_TrackPoint\">trackpoint scrolling<\/a> feature. Thus, I decided to run 32-bit version, despite a 64 bits CPU.<\/p>\n<p>Most of the hardware components work out the box, without particular setup, including the webcam. <span class=\"strikethrough\">The only regression compared to previous kernel versions is the integrated microphone, which remains disabled. I hope to fix it out soon. However, the jack input line is fully functional.<\/span> <strong>Update: just run alsamixer, type tab to enter in the Capture section and enable the internal microphone<\/strong>. Speakers offer a good (and loud) sound experience, quite surprising from a Thinkpad notebook.<\/p>\n<p>No particular thoughts on Ubuntu itself, except that <em>Jaunty Jackalope<\/em> will certainly bring a better user experience than ever (new themes, new notification system, general speed improvements, boot time dramatically reduced&#8230;).<\/p>\n<h3>Power management<\/h3>\n<p>Now the real deal: how to maximize battery operation and lifetime with the Lenovo Thinkpad X300?<\/p>\n<p>The average base power consumption is <strong>14 W<\/strong>, WiFi on, 75% backlight, some terminals and Firefox.<\/p>\n<p>First, disable everything you will never use in the BIOS. Currently, I disabled Bluetooth, WiMAX, Wireless WAN (3G),\u00a0\u00bbUSB Wifi\u00a0\u00bb (wtf?) and touchpad. <strong>Saving: 2 W<\/strong><\/p>\n<p>Then disable <em>Wake On Lan<\/em>, unless you need it. It keeps the Gigabit Ethernet Controller to remain in an active state that actually use energy. <strong>Saving: 1W<\/strong><\/p>\n<p>Moreover, I blacklisted the <em>e1000e<\/em> module, since I mainly use WiFi. When I need wired connection, I simply modprobe it.<\/p>\n<p>Then concerning the <em>wlan0<\/em> WiFi interface, just run:<\/p>\n<div class=\"cmd\">\n<pre>iwconfig wlan0 power on<\/pre>\n<\/div>\n<p>in order to active Power Management. <strong>Saving: 0.5W<\/strong><\/p>\n<p>Some <em>sysctl<\/em> tweaking in <em>\/etc\/sysctl.conf<\/em>:<\/p>\n<div class=\"cmd\">\n<pre>vm.laptop_mode = 5  # Activating laptop mode, power friendly I\/Os\r\nvm.dirty_writeback_centisecs = 2000\r\nkernel.nmi_watchdog = 0\r\nvm.swappiness = 5<\/pre>\n<\/div>\n<p>And in <em>\/etc\/rc.local<\/em>:<\/p>\n<div class=\"cmd\">\n<pre>echo 10 &gt; \/sys\/module\/snd_hda_intel\/parameters\/power_save\r\necho min_power &gt; \/sys\/class\/scsi_host\/host0\/link_power_management_policy\r\necho min_power &gt; \/sys\/class\/scsi_host\/host1\/link_power_management_policy<\/pre>\n<\/div>\n<p><strong>Saving: 2W<\/strong><\/p>\n<p>Quite simple, heh? :) Now, my average consumption is <strong>8.8W<\/strong>, allowing a real use of the X300 <strong>for more than 6 hours<\/strong>, instead of 4h30.<\/p>\n<h3>Last thoughts<\/h3>\n<p>The internal fan management is kinda broken in Linux. The workaround is to append <strong>thinkpad_acpi<\/strong> to <em>\/etc\/modules<\/em> and <strong>options thinkpad_acpi fan_control=1<\/strong> to <em>\/etc\/modprobe.d\/fan<\/em> for instance.<\/p>\n<p>Then you could use <a href=\"http:\/\/sourceforge.net\/projects\/thinkfan\/\">thinkfan<\/a> and this sample <em>thinkfan.conf<\/em>:<\/p>\n<div class=\"cmd\">\n<pre># thinkfan example config file\r\n# ============================\r\n#\r\n# Syntax:\r\n# (LEVEL, LOW, HIGH)\r\n#\r\n# LEVEL is the fan level that's written to \/proc\/acpi\/ibm\/fan\r\n# LOW is the temperature at which to step down to the previous level\r\n# HIGH is the temperature at which to step up to the next level\r\n# All numbers are integers.\r\n#\r\n# You can put spaces anywhere you want. Anything that doesn't match this\r\n# syntax is ignored.\r\n#\r\n# The number of tuples is limited by the size of your system memory.\r\n#\r\n# WARNING: Sanity checks are only made for correct ordering of the fan levels\r\n# and for (LOW &lt; HIGH) within one tuple. You can still use any kind of insane\r\n# temperature limits.\r\n\r\n(0,     0,      50)\r\n(1,     48,     58)\r\n(2,     54,     61)\r\n(3,     56,     63)\r\n(4,     58,     65)\r\n(5,     60,     66)\r\n(7,     63,     128)<\/pre>\n<\/div>\n<p>Concerning lithium batteries, you should keep them charged between <a href=\"http:\/\/www.thinkwiki.org\/wiki\/Maintenance#Battery_treatment\">40% and 80%<\/a>. It is quite easy to do with Thinkpads: just append <strong>tp_smapi<\/strong> to <em>\/etc\/modules<\/em>, and the upper charge limit will be set to 86%, which is a good compromise. Moreover, instead of completely drain the Ultrabay battery before switching to the main battery, you can manually force discharge; as root type:<\/p>\n<div class=\"cmd\">\n<pre>echo 1 &gt; \/sys\/devices\/platform\/smapi\/BAT0\/force_discharge<\/pre>\n<\/div>\n<p>But do not forget that even if you replug your laptop, discharge will resume anyway!<\/p>\n<p>Thus, you have to bypass forced discharge; as root type:<\/p>\n<div class=\"cmd\">\n<pre>echo 0 &gt; \/sys\/devices\/platform\/smapi\/BAT0\/force_discharge<\/pre>\n<\/div>\n<p><span class=\"strikethrough\">Annoying workaround, but I will try to find or code a proper solution.<\/span><\/p>\n<p><strong>UPDATE: See my <em>Baswim<\/em> script <a href=\"https:\/\/chroot-me.in\/blog\/index.php\/blog\/28\">here<\/a>.<\/strong><\/p>\n<p>That&rsquo;s all folks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently replaced my Macbook with a Lenovo Thinkpad X300 notebook. Here are some notes and tips concerning GNU\/Linux installation and configuration for an optimal day to day use. UPDATE (2011\/07) Here are my current settings for power management : \/etc\/rc.local: Simplified, no more vm.laptop_mode (not useful with a ssd). # Audio powersave echo 1 &hellip; <a href=\"https:\/\/chroot-me.in\/blog\/2009\/04\/lenovo-thinkpad-x300-and-linux-configuration-and-power-management\/\" class=\"more-link\">Continuer la lecture<span class=\"screen-reader-text\"> de &laquo;&nbsp;Lenovo Thinkpad X300 and Linux &#8211; Configuration and power management&nbsp;&raquo;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,4,2],"tags":[],"class_list":["post-46","post","type-post","status-publish","format-standard","hentry","category-english","category-geek","category-hacks"],"_links":{"self":[{"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/posts\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/comments?post=46"}],"version-history":[{"count":0,"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/posts\/46\/revisions"}],"wp:attachment":[{"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/media?parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/categories?post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chroot-me.in\/blog\/wp-json\/wp\/v2\/tags?post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}