Installing Ubuntu 9.10 on a Toshiba Satellite L500

I bought a new Toshiba Satellite L500 online in early March of 2010. I had done a little bit of research beforehand, but apparently not enough! Hopefully on this page I will share with you some of the things that took me days to figure out, and your experience will be better than mine.

Goals

Toshiba doesn't offer Linux pre-installed. Since I'm paying the Windows tax anyway, I figured I might as well leave it, dual-boot the system, and use the Windows partition to run iTunes so I can actually work with my iPodTouch. So the goals of this install are:

An overview of the methodology here: Resize the Windows 7 partition, create a new ext4 partition, install Ubuntu on it, make the bootloader work with both OSes, and then spend some time making the laptop's hardware work in Linux (always a pain in the ass).

I used this page as a reference along the way. You can refer to it for more detail but I've replicated most of the useful information here.

Hardware options

Toshiba lets you configure your machine. Here's what my machine has:

BIOS

The BIOS screen loads and disappears incredibly fast on this machine. Be prepared to hit F2 to bring up the BIOS Setup scren as soon as it does because there's not much room for error. When you do get the BIOS screen up, press Right until you get to the boot order screen, then follow the directions to move the CD drive higher in the order than the internal hard disk. If you want to change it back later, go for it, but let the CD drive boot first for now.

Your other option is to press F12 in that short window of time to bring up the boot menu, which will allow you to manually specify the CD drive at boot time.

Preparing for the install

Boot into Windows 7. Toshiba has helpfully included a DVD burning program.

Download and burn a Windows 7 install DVD. It's particularly important to do this if you decide to use GPartEd to resize your Win7 partition – more on this later.

Download and burn an Ubuntu ISO. I recommend clicking on "Alternative download options" and using BitTorrent, but you'll need to download a torrent client first.

If you don't have convenient wired Internet access, then download the Linux driver for the Realtek 8192SE card now, because Ubuntu won't recognize it. You don't have to do anything with this now; we'll deal with it later. Ubuntu has added the rtl8192 driver into their kernel source package, so you shouldn't have to do this anymore.

While you're waiting for those gigantic ISO files to burn, go ahead and install Mozilla Firefox and iTunes (64-bit version).

Resizing the Windows partition

Since you're already booted into Windows, you can use the built-in partition manager to "safely" resize the Win7 partition.

If you feel like it, this is a good time to uninstall the random cruft that Toshiba gives you that you'll never touch. I removed 'Amazon Links' and 'NetZero Launcher'.

Run the Windows Disk Manager tool by going to the Start Menu and typing "Disk Management" into the run box. I found that Windows thinks I have three partitions:

Of those three, only the C: drive has any used space. The others are 100% free, according to Windows. Since Windows thinks partition #1 is the recovery partition, I'm going to leave that one alone, shrink partition #2, and wipe partition #3. I still haven't figured out what partition #1 is for -- you can boot straight to partition #2 in Grub. You might want to try wiping #1.

Delete partition #3. Right-click partition #2 and select Shrink.

The first time I tried this, Windows only allowed me to shrink the partition down to 150GB, which was unacceptably large. This page has some handy tips for how to convince Windows to give you more space. After running Disk Cleanup, disabling System Restore, and deleting all old backups (directions at the above link), I was able to get the drive down to around 100GB. I've decided that since I'm going to run iTunes out of the Windows partition, I'll store all my music there as well. Linux can read and write NTFS partitions now, so I'll have access to that drive from Linux, too.

The shrink takes a couple of minutes. I recommend that you make sure at this point that you can still boot Win7; use the Win7 install DVD to Repair Your Installation if necessary. (You burned a Win7 DVD already, right?)

There is another option, which is to use GPartEd to resize the partition. GPartEd has the advantage that it will allow you to set whatever size you want on the NTFS partition. However, if you do this, it will hose your Win7 installation. You will need to boot a Win7 install disc and run the Windows Repair process to recover it. People have reported success with this method but I have not tried it.

You can either download and burn a GPartEd LiveCD, or just use the Ubuntu Installer Disc (which comes with GPartEd). If you use a GPartEd LiveCD, boot it in "Failsafe" mode, select "Forcevideo", and use 1024x768, "vesa" video driver, and 24bpp. That will get you running well enough to run GPartEd. (Note that GPartEd has very different things to say than Windows about what is "used" and what is "free" on that 3rd partition.)

Installing Ubuntu

Put the Ubuntu LiveCD into the drive and boot it. Choose the default keymap. From the menu, move the cursor over "Install Ubuntu" but don't hit Enter yet. Press F4 and pick "Failsafe Graphics Mode". Hit Escape. Press F6 and turn on every option except "Free software only". Hit Escape, then Enter. Wait a long time (several minutes) while the CD churns. Eventually it will boot a usable X display and drop you into the installer.

Specify your partitions manually. I created /dev/sda3 as a physical partition with ext4, filling all available space. I also specified that /dev/sda2 should be mounted as NTFS as /media/win7. (You can put whatever mount point you want here.) Don't bother creating a swap partition unless you're planning on using hibernate. The machine boots so quickly that I haven't bothered, and Ubuntu will set up a swap file for you automatically.

Don't bother with the Migration Assistant.

This section is only a few short paragraphs but it will take a significant chunk of time while the installer writes your new operating system and all of your new applications to the disc. It's "unattended" time though, so go eat dinner while it runs. You'll need the brainpower for what's to come.

Booting Ubuntu and cleaning up the broken stuff

Your first boot will take a couple of minutes. That's because there's a bunch of broken stuff going on in the background, which we're now going to fix. Start by opening a Terminal window (Applications / Accessories / Terminal).

Graphics card. Ubuntu probably came up with terrible 1024x768 graphics, because it's using a generic graphics card driver. Run sudoedit /etc/X11/xorg.conf. In the Device section at the top change the Driver from "vesa" to "intel". Save and quit. This change will take effect when next you reboot.

Fix boot options. All over the Internet there are people complaining that their laptop won't boot unless they add the option "noapic" to their boot command line. Guess what? You have one of those machines now. Fortunately the fix is easy. Run sudoedit /etc/default/grub. Look for the line GRUB_CMDLINE_LINUX_DEFAULT. Its current value should be "quiet splash"; change that to "quiet splash noapic". Save and exit. From the command line again run sudo update-grub.

Reboot. If everything is working well, your machine should boot much faster (around 15-20 seconds), your graphics should be reasonable (1366x768), and your Bluetooth card should be recognized (if you have one). However, there's an insidious bug that will cause your machine to lock up at a random interval. So as soon as your desktop comes up, go to System / Preferences / Appearance / Visual Effects and click "None". The lockup bug went away after I did this, and it hasn't come back.

Wireless driver. Ubuntu 10 (Lucid) and later have the wireless driver included, so you shouldn't need to do this.

You already downloaded the Linux driver from the Realtek website, right? If not, and you don't have wired Internet access, you're in trouble. Go reboot into Win7 and do that. If so, it's sitting in your Downloads folder under Windows, which is probably somewhere like /mount/win7/Users/yourname/Downloads.

If you do have wired Internet, your Ethernet jack should work just fine; plug in a cable and you're good to go. Either way eventually you'll have the driver in a .tar.gz archive file. Wherever it is, move that file into /usr/src. Now run the following commands:

% cd /usr/src
% tar xzvf rtl8192se_lin<tab>
% cd rtl819<tab>
% sudo bash
# make clean
# make
# make install
# modprobe r8192se_pci
# exit

(N.B. You MUST run sudo bash; do not try to run each make command with sudo.) Your wireless card should come up, and the Network Manager in your Gnome Panel should list the available access points and let you connect.

Update your system software. This will almost certainly include a new kernel. That's okay; the work we've done already should be ported over to the new kernel, with one exception: the wireless card. After the update finishes (this will probably take a while) Ubuntu will want you to reboot again. When the machine comes back up, you'll need to rebuild the wireless drivers using the steps in the box above. (You don't have to run the tar command, since the directory already exists. Just cd there and start from sudo bash.) The wireless card should come back up without rebooting, but if it doesn't, reboot again.

At this point I found just one thing missing: power management. For some reason, the battery wasn't being recognized, which meant I had no idea when my battery was about to die. Not okay. Other people report that USB didn't work for them at this point, too. Unfortunately, the fix for this is much more hairy, and it requires rebuilding your kernel. It is possible that by the time you read this tutorial, Ubuntu will have released a kernel upgrade that fixes the problem, which is why I left this last. If your battery and USB devices are working at this point, then STOP. If not, take a deep breath and read on.

Fixing ACPI. The problem is this: Toshiba included two sets of boot data that tell the OS what hardware exists in the machine. Windows reads the correct one. Linux doesn't. Helpfully, some kernel hackers figured out how to make Linux read the correct one, but you'll need to build your own kernel to make this happen. If you've never built a kernel before, it's not that hard, and I'll walk you through it step by step.

First, we need to find the config file that was used to compile the current kernel. It's stored in the /boot directory and it will be named something like /boot/config-2.6.something. You rebooted at least once after upgrading your system software, right? So you should be currently running the latest kernel that Ubuntu has installed. Run uname -r, which will tell you the version number of the current kernel. Then the file you want is /boot/config-version. Remember this filename; you'll need it in a minute.

% cd /usr/src
% sudo aptitude install wget linux-source-2.6.31 build-essential libncurses5-dev
% wget http://bugzilla.kernel.org/attachment.cgi?id=23958 -O acpi-patch
% tar xjvf linux-source-2.6.31.tar.bz2
% cd linux-source-2.6.31
% patch -p1 < ../acpi-patch
% make menuconfig

From within the menuconfig program, (L)oad an alternate config file. Type in the config filename from the previous paragraph; in my case, it was /boot/config-2.6.31-20-generic.

I recommend, while you're here, that you change the default CPU frequency governor from 'Performance' (which runs at top speed all the time) to 'On-Demand' (which cycles fast and slow depending on what you're doing). You can always change this at run-time with the Gnome Processor Frequency applet. From the menuconfig toplevel, choose (P)ower Management and ACPI Options / (C)PU Frequency Scaling / (D)efault cpufreq governor / (o)ndemand. Then select (E)xit to go back out to the main menu.

Now select (G)eneral Setup / (L)ocal Version and enter the string "-acpi". (E)xit to return to the top menu. (S)ave an alternate config file; enter ".config". (E)xit to the shell. Keep track of what version this kernel is; I downloaded version 2.6.31.9. You'll need it in the next batch of commands. If you're not sure, run head .config and it should be in the first few lines. Compile the new kernel with the following commands; this will take a while (30-60 minutes).

% make -j16
% sudo make install
% sudo make modules_install
% sudo update-initramfs -c -k 2.6.31.9-acpi
% sudo update-grub

Reboot, hopefully for the last time. You'll have no wireless, but you should have a battery. Go back to the Wireless Card section above and recompile the wireless driver (again).

Future considerations

In the future, every time that Ubuntu wants to upgrade your kernel, you should let it, but keep the following things in mind.