Wednesday, May 6, 2009

Ubuntu 9.04 on the Toshiba Satellite L305

Previously I had written about installing Ubuntu 8.10 on the Toshiba Satellite L305. It was not without its problems, the hardware on Toshiba systems can be pretty picky. The omnibook module got the fan and brightness keys working, but on some systems, this also caused the laptop to turn itself on three to fifteen minutes after being shut down. The good news for those who had this problem is that in 9.04, the fan problem is easily fixable without the module, and with a few workarounds, the brightness keys work too. Furthermore, wireless now works out of the box with the ath5k module, so madwifi or ndiswrapper are no longer necessary.

If you are already running the omnibook module without this problem, I recommend using that instead, as it is a simpler fix.

Step 1: Install and get the fan going

Download and install Ubuntu 9.04. In my experience, the DVD drive in the L305 can be a little picky, so I recommend either installing from a usb stick or burning the Ubuntu CD at a slower speed. The installation should go smoothly. When it boots to your new Ubuntu desktop, you first need to get the fan going.

This is a pretty easy fix, all you need to do is modify your grub file. Open up a terminal and type:

sudo gedit /boot/grub/menu.lst

*note: You can use nano, vi, kate, or whatever your preferred text editor is.

Add 'acpi_osi="Linux"' to your kernel's boot parameters. This is an example of my menu.lst file, with the part you need to add in bold (the rest may differ slightly in your file):


title Ubuntu 9.04, kernel 2.6.28-11-generic
uuid a91f7379-e93b-490c-b541-0681173bccc2
kernel /boot/vmlinuz-2.6.28-11-generic root=UUID=a91f.. ro quiet splash acpi_osi="Linux"
initrd /boot/initrd.img-2.6.28-11-generic
quiet


Reboot and your fan should work fine. In my experience, it turns on at about 50 degrees and turns back off at about 35. Your brightness keys might be usable now, too. In my experience, though, these keys stop working after a few reboots. (If your keys continue to work, you can skip the brightness keys workaround section).

Optional: monitor your temperatures with lm-sensors
I wanted to make sure that the fan was working appropriately, so I wanted to monitor the computer's temperature. This is easy to do by installing the lm-sensors package. After you set up the sensors, you can either run the sensors package to display temperatures, or install the sensors-applet package to monitor them from the desktop:

sudo apt-get install lm-sensors sensors-applet
sudo sensors-detect

sensors-detect will set up the sensors. It will ask a lot of questions, the defaults should all be fine, though when asked if I want to add the modules to /etc/modules, I say yes. either reboot or manually add the modules it specifies manually. Add the sensors applet to the panel and you should be able to monitor your temperatures.

Step 2: Get the brightness keys working
For some reason, after a couple of reboots, the function keys no longer work for me. It seems the function key (fn) doesn't get input. I've developed a workaround to make the super (Windows) key to work with F6 and F7 to change brightness levels.

First you need to modify the keyboard with xmodmap to allow the use of the super key, because by default it is set to a different use. Though it is supposedly changeable through Gnome, I have had no luck. It is actually quite easy to do manually though.

First open a console and run xev. Hit the windows key and look for the keycode output. On my computer, it is 147, though may be different (there are a few different models of L305s). Close out of xev and make (or modify) ~/.Xmodmap (note the dot and the capital X). Add the following lines to .Xmodmap:

keycode 147 = Super_L
add mod4 = Super_L

Save and close the file, then run xmodmap. The super key should now be mapped to "Super_L" (you can test this again in xev, if you like)

Next you need to bind super+F6 and super+F7 to the brightness keys. This is doable with xbindkeys, which is installable in the console, and you may also need the keytouch daemon: (sudo apt-get install xbindkeys keytouch). Xbindkeys will be mapped to run acpi keys with "acpi_fakekey", which should already be installed on your system. The keytouch daemon will install apci-related things that make acpi_fakekey work (I'm not exactly sure how, but in my experience, without the keytouch daemon, acpi_fakekey doesn't work)


You are also going to need to install the lineakd package to find out what the event keys are for your brightness keys. Lineakd comes with a program called evtest. Run it (as root) on the different events in /dev/input/ until you find the one with brightness event codes. Mine is in /dev/input/event5, though it may be different for you:

sudo apt-get install lineakd
sudo evtest /dev/input/event5

It lists for me that brightness down is 224 and brightness up is 225.

Next you need to modify the xbindkeys config file. This is easiest by installing the xbindkeys-config package, and run that. Here you can add various commands for different combinations of keypresses. Click “add.” Name the command whatever you like. Click on “get key” and press your key combination. For the action type in “acpi_fakekey [keycode]”, where [keycode] is the event code you found with evtest. For example, for my brightness down key I put acpi_fakekey 224. You can also use this for other commands, too.

Save the file and close xbindkeys-config. Here, I like to move the config file from its default location (~/.xbindkeysrc) to its own folder in /etc, because the commands should be system wide, and also for security (the commands it will be running will be running as root). I copied it to /etc/xbindkeys/xbindkeysrc


Now it's time to test it. run xbindkeys as root with "sudo xbindkeys -f [location of xbindkeysrc file]" . Press super+F6 and super+F7 to make sure they adjust the brightness as they should. If everything is set up right, your brightness should be changing now!

Step 3: Get xbindkeys to run at boot:
As long as the keys are working, the only thing left to do is to make xbindkeys run on boot. The following is the only way I've been able to find to get that to work (init scripts make it run too early and it segfaults). Many thanks to Ubuntu Forums user BslBryan for this tip!

First, modify the sudoers file with the command "sudo visudo" Add the following to the end of the file:

[your username(s)] ALL= NOPASSWD: /usr/bin/xbindkeys

This makes xbindkeys able to be run as root without a password. It's important for the next step. Next go to System -> Preferences -> Startup Applications. Click on add. Name it xbindkeys. For the command, type "sudo /usr/bin/xbindkeys" (without the quotes). Sudo won't ask for a password now because we edited the sudoers file earlier with visudo. Type a description if you like and click add, then close out of startup applications.

Now reboot. If all went well, when you reboot super+F6 and super+F7 should adjust the brightness. Along with the easy fix for the fan, this makes Ubuntu 9.04 much more usable on newer Toshiba laptops.

26 comments:

Anonymous said...

Thanks for your tip about adding acpi_osi="Linux" to that config file! I was about to return this Toshiba laptop to the store because I thought the fan wouldn't work with Ubuntu on it. I verified that the fix works by just putting an expensive for-loop in python and letting it run for awhile. Now my fan is happily humming away whenever it gets hot, and stops when it's cold. Awesome!

It looks like the snippet you posted got cut off, though. I had to check the source HTML to see what you changed. Just a heads-up.

Davidcowan2004 at yahoo.ca said...

Thanks for your tips, but they don't seem to work for me for the fan...question:

What BIOS do you have ( Insyde ? Phoenix ?)

Also, are you using the 32 bit or 64 Ubuntu Jaunty ?

(I have a Toshiba L300D, Insyde Bios, and 64 bit Jaunty, everything works except the fan control - always on.

Swinky said...

Anonymous,

Thanks for letting me know that part got cut off. Formatting for the code sections can be quite tricky. I am very glad to hear that your fan works now!

Swinky said...

Davidcowan2004,

My bios is the InsydeH20 BIOS (revision 3.5). I am running 32 bit Jaunty. I did attempt to use the 64 bit Jaunty at first but was having some problems getting the 32 bit programs to connect to the internet (I prefer to use 32 bit Firefox, for example, to run flash) so I went back to 32 bit. But while I was using 64 bit, the fan control worked fine.

I am not sure about the L300D, but if you are still having fan issues, you might want to try out the omnibook module, the latest can be found here. Since you are running 64-bit Jaunty you'll have to compile the source code yourself. After it is installed, load the module with "sudo modprobe omnibook ectype=11" and see if your fan control works better (ectype=12 I have heard may also work).

The omnibook module does, on some models, make the computer turn itself back on after you have turned it off, so just watch out for that. If it does, unload the module and remove it and it should stay off properly again. Sorry I can't be of more help.

Davidcowan2004 said...

Thanks for the omnibook tip...I may try it...but the battery thing is almost as bad as the fan always on...

By the way, there is a workaround for Flash on 64bit : swfdeck-gnome - works too!

Ciao !

Anonymous said...

thank you so much !!! I thought I was going to burn the computer my boss gave me!!!! (Tosh Satellite L305) I was about to go back to vista... you save me!

Cal Yeah said...

thanks for your tips. I made everything work eventually. But my computer (Toshiba l305) has another problem, that is, after suspend, it can't wake up properly. The screen is blank and it doesn't respond to any keystrokes. do u have similar problems? Thanks!!

Swinky said...

Hi ye,

I haven't actually tried it, I generally don't suspend or hibernate my laptop. Unfortunately I don't have any suggestions to help that.

Simplicio said...

Ah, no luck in solving the fan issue. I tried adding the acpi_osi flag to the boot options, and while I think it actually worked on the first reboot, after that the fan went back to its old behavior. I have the same kernal version, bios and Toshiba model as you, so I can't imagine what the difference might be.

Ah well, thanks for putting the effort into the guide anyways. I'll post again if I find a solution that works on my computer.

Simplicio said...

Ah, actually works (fan and brightness control) if I boot with the "acpi_osi" option and then suspend and bring back from suspend. Sorta inconvenient, but less so then having my laptop running at 80C all the time.

(and on the plus side: hey! suspend works!)

havencruise said...

Thanks a lot for this very useful post. I've tried to do many things to make the keys work. The first step did the trick and so far its worked for 3 reboots. Hope it continues to work further too.
I have observed another issue with ubuntu and laptops where the touchpad is very slow to respond to tapping. I run a Toshiba L300 and I've managed to get used to the clicking of the LMB. Is there anything you have done/using to make tapping as sensitive as in Windows?

Swinky said...

Hi havencruise!

Glad this could help you out! I don't know about the L300, but hopefully your keys keep on working so you don't have to do the workaround for them.

As far as your question about the touchpad, I haven't noticed this problem on my laptop (L305).I don't really know if that means it is there and I just don't notice or if I am not having that problem (I click the buttons instead of tapping the touchpad half the time anyways.) Good luck on finding a solution for it, though.

havencruise said...

Also in 9.04, the alt-select key ( the one in between right alt and right ctrl ) does a lock screen whenever clicked. Can you suggest me a way so that it does the right click of mouse as in windows?

daka said...

Hi

I am a newbie and still don't have wifi working on Jaunty. Can you explain what you mean by "ath5k module" .... what is this ... how to do it etc..... or point me in the right direction.

Many thanks

daka

Swinky said...

Daka,

Welcome to the world of Linux! If you have not already, I suggest checking out ubuntuforums.org. They tend to be very helpful there, but you have to be patient because they can be quite busy at times. Just make sure you are very specific with your problem and include computer specifications and the like.

To answer your question in a nutshell (keep in mind this is a simplified answer), a module is similar to "drivers" in Windows; they are what make the different hardware work with the operating system. The "ath5k" module is the wireless module for Atheros WiFi chipsets. In my experience, during the Jaunty setup, if you have an Atheros WiFi card, Ubuntu should have detected it and set it up for you. You can test this by typing the following in the terminal:

lsmod | grep ath5k

(that symbol in the middle is a "pipe," which is the character you get when you hold shift and hit the "\" key, not an I or an l.)

If the module is loaded, you should get a line of text that says "ath5k" as well as some other numbers. If it is NOT loaded, it will bring you back to the prompt.

If it is not loaded, try loading it manually by typing:

sudo modprobe ath5k

If the wireless interface starts up, can tell the module to load on boot (there are plenty of tutorials on the net or at ubuntuforums.org). If it doesn't, you might not have an Atheros based WiFi chipset. Hope it helps!

william said...

Thank you! you are a monster!

Pinky The Whacker said...

Thanks for the article, I'm using wubi to install ubuntu, and may switch back to xubuntu after this, thought it was the version causing the problem. Anyway, I cannot for the life of me find menu.lst in this install. The closest I've found is a file called grub.cfg in the /boot/grub directory, I'm adding the code you suggest there.

Pinky The Whacker said...

Well disregard that last post, its saying I'm trying to save to a read only disc. Hmmm

Pinky The Whacker said...

AHA, sorry to keep posting dude, apparently latest version is running grub2, you have to edit 40_custom in /etc/grub.d then run sudo update-grub. This placed the entry my grub.cfg file, and my fan seems to be working now.

Chris Belcher said...

Thank You. I have grown so tired of windows and it's viruses but till now I was unable to run Ubuntu in a stable way.

Unknown said...

Hi Swinky,

Thanks for your post!It really saves me!Please do continue to do such thing as it may ease other peoples burden!Lol..

I only did Step1 & it work like a breeze. Here's my kernel, for others to see. I just edited it & put this line acpi_osi="Linux".Now my fan & brightness keys are working perfectly.

title Ubuntu 9.04, kernel 2.6.28-18-generic
uuid d0260848-6fed-46ab-83dd-f1ee5eb02290
kernel /boot/vmlinuz-2.6.28-18-generic root=UUID=d0260848-6fed-46ab-83dd-f1ee5eb02290 ro quiet splash acpi_osi="Linux"
initrd /boot/initrd.img-2.6.28-18-generic
quiet

More power & Godbless....
jayson relox
Philippines

Unknown said...

Do you know if this works on ubuntu 9.10?

richard said...

in ubuntu 64bit 10.4 with grub 2 use
sudo gedit /etc/default/grub

and add the acpi on the end
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_osi=Linux"

sudo update-grub

and reboot

Think this works ... if you downloaded and installed omni book

Carlos said...

The solution gave by Richard is true, but for me work this line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi=Linux"

The problem... with any change in the kernel or grub configuration, the fan doesn't work again... you need to apply the solution again and it'll work.

Efudex Cream said...

Hi, thank you for sharing this great info. Was just browsing through the net in my office and happened upon your blog. It is really very well written and quit comprehensive in explaining with a very simple language.

Unknown said...

I like your style of writing. You break it down nicely. Very informative post. Keep up the good work.

Lenovo - Refurbished - 14" ThinkPad Notebook - 2 GB Memory - 160 GB Hard Drive

Lenovo - Refurbished - 14" ThinkPad Notebook - 2 GB Memory - 320 GB Hard Drive