Monday, March 3, 2014

How to Install Bodhi Linux on Lenovo Thinkpad X131e Chromebook


In previous posts I described what I learned in trying to install Bodhi Linux on the Lenovo Thinkpad X131e Chromebook. In this post, I will describe how to actually download and execute a script to help others get  Bodhi Linux installed on the X131e Chromebook, either on a USB device or on the main SD card.

Please Note First

If you are familiar with the normal operation of Chromebooks, you will note that they automatically update. When you first get your Lenovo Thinkpad X131e Chromebook, if you wish to install Bodhi Linux or another alternative OS, you should first allow your Chromebook to update once, which it should do soon after logging in the first time. The reason I say this is that my Thinkpad Chromebook initially was using a version of Chrome OS with a 3.4.0 Linux kernel, but after updating, it was using a newer Linux 3.8.11 Linux kernel. The newer kernel is preferable.

Instructions Using My Script

Most steps to use in using my script are similar to those I described in an earlier post about installing on a Samsung Chromebook, as well as numerous posts by Jeff Hoogland (Bodhi Linux team leader) about installing on the Samsung Chromebook. There are some differences though that you will need to be aware of:
  1. The instructions for getting into developer mode are different.
  2. The (disk) device mappings are different.  The main SD card on the Thinkpad X131e Chromebook is /dev/sda, not /dev/mmcblk0.
In the following sections, I will describe how to get Bodhi Linux installed on the Thinkpad X131e Chromebook.
Step 1: Boot in Recovery Mode

Keep in mind that you will lose current data, so you should back up any data you need first. Any data you had previously will be lost. I assume at this point that you have a ChromeOS verified boot environment. You now need to boot into recovery mode. The instructions for booting into recovery mode are detailed here. The instructions are different for the Thinkpad X131e Chromebook in that you have to remove power (AC and battery) and then boot into recovery mode within 20 seconds of reapplying power. So after reapplying power, you must quickly boot into recovery mode by  holding ESC (escape) and Refresh (F3) and hitting the power button.

Step 2: Enter Developer Mode

You now should hit Ctrl+D and then on the next screen press enter. You will not be prompted, you have to know to do it. It will ask you to confirm, which you should do. At this point the system should reboot into recovery mode. Once it reboots into recovery mode it takes a few minutes to configure everything, so please be patient.

Step 3: Get into a Virtual Terminal with Internet Access

After the system has started up, select a wireless access point to which to connect. It might take a few seconds after starting up for the list of access points to get populated into the pull-down list.  After selecting the wireless access point, go to the next screen (the google login screen) but do not log in. Hit Ctrl+alt+-> (where -> is where F2 would be on many keyboards).  This will open up a shell window.  For the username enter chronos and just press enter for the password (there is no password).

Step 4: Download and Run the Installation Script

From the command prompt run:

wget --no-check-certificate

Now you need to determine which device you are going to install to. Note that there are limitations as to what devices you can use. Although someone must know exactly what and what is not supported, it seems many of us learn  this only via discovery (that is, trial and error).  Based on my various attempts, I think your choices are limited to:
  • A USB flash drive, or
  • The main SD card used as the main drive on the Chromebook
What is clearly known is that only certain USB ports can be used for booting from a flash drive. This has been discovered (and thus documented) for various Chromebook models.  I attempted to install to and then boot from an external SD card and was not successful.  The behavior I saw (a pause and a loud beep) made me believe that booting from an external SD card was not supported. I cannot state this definitively as a fact, but can only recount my own experience.  
I have also encountered various USB flash drives from which I could not boot from on either the Samsung or Thinkpad Chromebooks, although I used the exact same steps (scripts) to create the install image as I did for USB flash drives from which I could (always) boot. I spent a lot of time trying to determine why some USB flash drives could be used while others could not. I was unsuccessful. I have not seen the cause, or a way to check for suitability, documented anywhere. So when it comes to USB flash drives, if after installing to one using my script, the boot fails, you may want to consider another USB flas drive. All of the USB flash drives I tried were SanDisk Cruzer drives. A couple worked, a couple did not.  I found no discernable pattern.  An old 4GB and a very new 16 GB worked, while a fairly new 8GB and slightly older 16GB did not.
So first you need to decide if you want to install to an external USB flash drive or not. You may want to do this initially, even if your long term goal is to use the main SD card in the Chromebook, just to try out the experience of running Bodhi on the Thinkpad Chromebook. If you choose an external USB flash drive I would recommend at least 8GB, although I have used 4GB for testing previously on my Samsung Chromebook.

You need to know how to identify the device you are installing to.  On my Thinkpad Chromebook I descovered that the main drive (SD card) was /dev/sda.  When I installed a USB flash drive, it appeared as /dev/sdb.  You can use

sudo blkid

to try identify the device you wish to use.  For the main drive (which I saw was /dev/sda), I saw multiple partitions: /dev/sda1, /dev/sda3, /dev/sda5, etc.  For an external USB flash drive, typically you would see fewer partitions. Again, the first USB drive I plugged in was identified as /dev/sdb. The blkid command may show /dev/sdb or /dev/sdb1 and /dev/sdb2, etc.. Given that you know which device to install to, you invoked the downloaded script with the device:

sudo bash 4eyrq4 device

where device is the device to be installed to, which typically would be either /dev/sda (for the main SD drive) or /dev/sdb (for an external USB drive).  After entering the command (which runs the script), you will be provided some information about your Chromebook. To continue, press enter.

Note: The next two steps only apply if you install to the main SD card. Otherwise, the script will run to completion without rebooting or entering more information. You will be given the chance to abort the operation before it writes to your device. Assuming you don't, the filesystem will be downloaded and installed. This takes a while, as it is about 320 MB.

There is one other interesting thing to note about the installation.  A strange thing happened often when I tested the installation script. The extraction and copying from the tgz file to the target drive often encountered issues. It appears that either during the copy itself, or the subsequent unmount command, the machine determined the command was taking too long (perhaps seemed hung) and rebooted. Because of this, I was forced to extract and copy parts of the filesystem image in pieces, and to insert sync commands to insure that previous image parts were completely copied before installing.  So as the script runs, you will notice that it describes extracting sections and syncing and sleeping to try to guarantee success.

Step 5: Choose How Much Space to Give to Bodhi Linux

This step only applies if you are installing to the main drive. The installer will prompt you for how much space you want to give to Bodhi. You should enter an integer amount for how many GB you would like to give Bodhi. On the 16 GB Chromebook the most Jeff (and others) recommended giving to Bodhi is 9 GB (with the maximum being 10).  For information, the initial base Bodhi install occupies around 1.6 GB. Once you select an amount of space to give Bodhi the drive will be re-partitioned automatically and then the system will restart. After restarting,  you will need to go through the Chrome OS setup process once more (see the beginning of step #3). Again, when you get to the google login screen do not log in.

Step 6: Getting the Linux Filesystem Set Up

Again, this step only applies if you are installing to the main drive. Get into the virtual terminal again as described at the end of step #3. Then run the same two commands given in step #4, which will download and execute the script a second time.  This time the installation script will see that your drive has already been partitioned and it will begin downloading the Bodhi Chromebook image which it will then install onto the system. Note that this will take some time depending on your internet connection speed since a 320MB tarball needs to be downloaded and extracted.

After the Script is Finished

Please note that I commented out the line at the bottom of the script which reboots, in case you wish to look around before rebooting.

When you are ready to reboot, enter the command

sudo reboot

After rebooting, you need to enter Ctrl-D if you installed to the main SD card, or Ctrl-U if you installed to the USB flash drive. Note that I discovered only the yellow USB 2.0 USB port on the right hand side of the machine could be used for booting with a USB flash drive. Hopefully you will then boot into the LXDM login screen. Note that the default installed user is bodhi32 and the password is bodhilinux. That user has sudo rights. After logging in, you should then see the Enlightenment desktop.

Please also note that I did run into issues with the wireless dropping its connection sometimes, and the wireless password screen (for the access point I had been logged into) appearing. It seemed rebooting was the only way to resolve this at this point (that is, entering the password did not seem to help).  I have tried various steps to try to solve this issue. My latest attempt was to edit, with sudo, /etc/modprobe.d/ath9k.conf. Note that this file did not initially exist. I put in the line:

options ath9k nohwcrypt=1 blink=1 btcoex_enable=1

Note also that I initially tried only nohwcrypt=1, but this was not sufficient. At time of writing, I have not encountered the dropped connection problem again, but note that I have only had these latest module settings set for about a day.

You will probably want to change the password of the default user.

Future Plans

Fans of Bodhi Linux will note that an alpha version of Bodhi 3.0 was just announced. I may update my script at some point in the future to allow you the choice of installing Bodhi 3.0 instead of the current supported version, 2.4.0.