1 Title: How to fix a Thinkpad X230 with a broken 180 GB SSD disk
6 <a href="http://people.skolelinux.org/pere/blog/The_Thinkpad_is_dead__long_live_the_Thinkpad_X230_.html">my
7 new laptop</a>. I've previously written about the problems I had with
8 my new Thinkpad X230, which was delivered with an
9 <a href="http://people.skolelinux.org/pere/blog/Intel_SSD_520_Series_180_GB_with_Lenovo_firmware_still_lock_up_from_sustained_writes.html">180
10 GB Intel SSD disk with Lenovo firmware</a> that did not handle
11 sustained writes. My hardware supplier have been very forthcoming in
12 trying to find a solution, and after first trying with another
13 identical 180 GB disks they decided to send me a 256 GB Samsung SSD
14 disk instead to fix it once and for all. The Samsung disk survived
15 the installation of Debian with encrypted disks (filling the disk with
16 random data during installation killed the first two), and I thus
17 decided to trust it with my data. I have installed it as a Debian Edu
18 Wheezy roaming workstation hooked up with my Debian Edu Squeeze main
19 server at home using Kerberos and LDAP, and will use it as my work
20 station from now on.</p>
22 <p>As this is a solid state disk with no moving parts, I believe the
23 Debian Wheezy default installation need to be tuned a bit to increase
24 performance and increase life time of the disk. The Linux kernel and
25 user space applications do not yet adjust automatically to such
26 environment. To make it easier for my self, I created a draft Debian
27 package <tt>ssd-setup</tt> to handle this tuning. The
28 <a href="http://anonscm.debian.org/gitweb/?p=collab-maint/ssd-setup.git">source
29 for the ssd-setup package</a> is available from collab-maint, and it
30 is set up to adjust the setup of the machine by just installing the
31 package. If there is any non-SSD disk in the machine, the package
32 will refuse to install, as I did not try to write any logic to sort
33 file systems in SSD and non-SSD file systems.</p>
35 <p>I consider the package a draft, as I am a bit unsure how to best
36 set up Debian Wheezy with an SSD. It is adjusted to my use case,
37 where I set up the machine with one large encrypted partition (in
38 addition to /boot), put LVM on top of this and set up partitions on
39 top of this again. See the README file in the package source for the
40 references I used to pick the settings. At the moment these
41 parameters are tuned:</p>
45 <li>Set up cryptsetup to pass TRIM commands to the physical disk
46 (adding discard to /etc/crypttab)</li>
48 <li>Set up LVM to pass on TRIM commands to the underlying device (in
49 this case a cryptsetup partition) by changing issue_discards from
50 0 to 1 in /etc/lvm/lvm.conf.</li>
52 <li>Set relatime as a file system option for ext3 and ext4 file
55 <li>Tell swap to use TRIM commands by adding 'discard' to
58 <li>Change I/O scheduler from cfq to deadline using a udev rule.</li>
60 <li>Run fstrim on every ext3 and ext4 file system every night (from
63 <li>Adjust sysctl values vm.swappiness to 1 and vm.vfs_cache_pressure
64 to 50 to reduce the kernel eagerness to swap out processes.</li>
68 <p>During installation, I cancelled the part where the installer fill
69 the disk with random data, as this would kill the SSD performance for
70 little gain. My goal with the encrypted file system is to ensure
71 those stealing my laptop end up with a brick and not a working
72 computer. I have no hope in keeping the really resourceful people
73 from getting the data on the disk (see
74 <a href="http://xkcd.com/538/">XKCD #538</a> for an explanation why).
75 Thus I concluded that adding the discard option to crypttab is the
76 right thing to do.</p>
78 <p>I considered using the noop I/O scheduler, as several recommended
79 it for SSD, but others recommended deadline and a benchmark I found
80 indicated that deadline might be better for interactive use.</p>
82 <p>I also considered using the 'discard' file system option for ext3
83 and ext4, but read that it would give a performance hit ever time a
84 file is removed, and thought it best to that that slowdown once a day
85 instead of during my work.</p>
87 <p>My package do not set up tmpfs on /var/run, /var/lock and /tmp, as
88 this is already done by Debian Edu.</p>
90 <p>I have not yet started on the user space tuning. I expect
91 iceweasel need some tuning, and perhaps other applications too, but
92 have not yet had time to investigate those parts.</p>
94 <p>The package should work on Ubuntu too, but I have not yet tested it
97 <p>As for the answer to the question in the title of this blog post,
98 as far as I know, the only solution I know about is to replace the
99 disk. It might be possible to flash it with Intel firmware instead of
100 the Lenovo firmware. But I have not tried and did not want to do so
101 without approval from Lenovo as I wanted to keep the warranty on the
102 disk until a solution was found and they wanted the broken disks