Wed Oct 26 20:59:32 EST 2005

Thinkpad T30 - Hotswap, and Software Suspend


One of the things that I've gotten used to in Windows is the nice Hibernate feature. I like to just close my laptop and have it suspend to disk then quickly resume. I'll do this several times a day during my work. I figured, if Windows can do it, then Linux should be able to do it better right? :D

Well, it wasn't exactly easy but it built on what I learned messing with ACPI as I talk about in my last post. First of all, there really isn't any specific documentation for Slackware when it comes to suspend to disk that I could find. But, I found some info on Gentoo, Debian, and Fedora which was useful. Now it turns out that in the 2.6.13 kernel (and possible older ones I don't know) that there is already a suspend to disk feature right under power management in your menuconfig. I gave that a shot and lets just say it doesn't play well with my Thinkpad. Basically I can suspend it but it never comes back. It tries to resume but then locks.

Some more research pointed me to a project called Software Suspend 2 for Linux that actually works. Basically it consists of a kernel patch for the vanilla 2.6.13 kernel and a hibernate script. Both the patch and the support scripts are super easy to install. The documentation and the FAQ are really nice on their site. Once you compile the kernel with suspend2 enabled you can either suspend to a file or to swap space. To resume you just add an option to your lilo.conf or your grub menu.lst file to tell the kernel where you expect a suspend file or partition. Then all you have to do it type hibernate and it will suspend to disk. They even have a tip on how to setup sudo so you can hibernate without being root which lets you use it in something like Klaptop to hibernate the system when the batter gets critically low.

This is all well and good but I want to set this up so that it will hibernate when i close the lid of the laptop regardless of if I'm in KDE or at the console. Oh, and make sure not to use the hibernate function of Klaptop with suspend2. It corrupted my drive so bad I had to reinstall. I'm thinking it may have been something I did wrong in the hibernate.conf file but since I'm not planning on using klaptop to take care of the lid I didn't look into it.

Anyway, I figured acpid would be the way to go to catch the lid button event and have it run hibernate for me. Watching /var/log/acpid gave me a event called "button/lid LID 00000080 00000001" but I found out the hard way that it actually counts up such that the last bit of it changes. Pressing the button counts as an event as well as releasing it. So I couldn't just check for the entire thing. Also, I needed to make it only suspend on every other event. Otherwise it would suspend on the lid button press and would then suspend again right after the resume when it would get the lid button release. The suspend2 FAQ had the answer. Here is what worked for me:
event=button[/]lid LID.*[13579bdf]$
action=/usr/local/sbin/hibernate
I just stuck that in a file in the /etc/acpid/events directory along with my other events and issued a /etc/rc.d/rc.acpid restart and now the laptop suspends to disk perfectly every time I close the lid. As a point of interest I initially made the event expression to be event=button[/]lid LID.*[02468ace]$ which had the odd effect of only suspending the system when opened the lid.

One word of advice, if you try to set this up manually like I did rather than relying on your distro to set it up for you then do it on a test system. It seems that once you get it tweaked and working it works fine, but one mess up while learning it can irreversibly corrupt your file system. On, and one other thing of to note, read the section of the How to Avoid Data Loss section of the HOWTO if you mount a Windows partition to avoid killing your fat vfat or msdos partitions.

The other thing I did that was much easier than figuring out all this ACPI and suspend to disk stuff was figure out how to hot swap my drive bay so I can switch between my floppy and my CD-ROM without having to reboot. The utility to use is called Khotswap that sits in your system tray in KDE. The author also has a Gnome applet for it and it has a command line only version of itself just called hotswap and an X generic one called xhotswap.

So, at this point I'm well on my way to getting the foundation of the laptop done in Slackware enough to start thinking of setting up the rest to use for day to day work. I know, I could have used another distro and had much of this stuff work right out of the box. I hear Ubuntu is very good at this. But if I did that where would the challenge be and what would I learn in the process?

Posted by Brian | Permalink | Categories: Computers and Technology, Work | |

Sun Oct 23 19:05:42 EST 2005

ACPI and Speedstep with Linux on my Thinkpad


Well, I've decided to go with Slackware for the laptop mostly because it's what I know. So, Slackware being what it is I had to take matters into my own hands and configure some of the more ugly things that may be done for you in other distributions. In this case it was ACPI and CPU Frequency Throttling (Speedstep). I don't know for sure if this stuff just works on another distro as I didn't try. What can I say, it's hard to break the Slack habit. ;)

The laptop in question is an IBM Thinkpad T30 and according to Google it is well supported in Linux (mostly). I went and installed Slackware 10.2 and most everything worked right out of the box like sound, wireless LAN, and APM. APM worked fine except that I didn't see any support for the Thinkpad buttons and saw that the kernel had a module just for Thinkpads in ACPI. Rather than figure out just what modules I needed to modprobe in I just compiled the things right into the kernel since I can't think of any time I'd not want them there. That worked well, the sleep button worked and when I closed the laptop lid the system went to sleep.

I did notice though that when I was on batter i was only getting about 40 minutes of run time when I was getting about 1.5 hours in Windows. So then it was onto learning how to throttle the CPU speed. Now, this was a pain in the rump. I had the modules I needed loaded and no matter what I did Klaptop wouldn't change the CPU speed when going from between battery and AC. I even compiled all the modules directly into the kernel to see if it helped. No go. I could change the speed manually but not automatically.

It turns out that after some research I learned that this model only supports two speeds of CPU. One at 1.8GHz and the other at 1.2GHz. Klaptop wanted to throttle based on percentage. For some odd reason I could set the percentage manually and it seemed to make a difference in performance but it just wouldn't do it automatically.

So, as far as CPU frequency throttling it can be by a userspace program or by the kernel itself. Klaptop is a userspace program and since that wasn't working I decided to try out letting the kernel do it. I compiled in speedstep-ich and the ondemand governor. The idea is that the ondemand Governor will watch your current CPU needs and adjust the speed accordingly. To get this working all you have to do is make sure the ondemend module and the speedstep module is loaded (or compiled into the kernel) and then echo -n ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor and supposedly it will "just work". For some reason when I echo ondemand into scaling_governor it doesn't take and just stays as userspace. I haven't put much effort into figuring out the why since I'm a bit tired of playing with this. I did figure out that I could manually echo either 1200000 or 1800000 into /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed and it would work. But how to make it do this automatically?

All I did was kept and eye on /var/log/acpid with tail -f and unplugged the AC adapter and plugged it back in a few times. In my case every time I plugged in the adapter it generated an ACPI event called "ac_adapter AC 00000080 00000001" and when I unplugged it a "ac_adapter AC 00000080 00000000" event was generated. All I had to do was create two scripts in /etc/acpi. One of the scripts I called on_battery.sh and it contains:
# Sets the CPU to 1.2 GHz when on battery
#
echo -n 1200000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
#
# Set Hard Drive sleep to 5 minutes
hdparm -S 60 /dev/hda
And the other one called ac_cpu.sh contains:
# Sets the CPU to 1.8 GHz when on wall AC
#
echo -n 1800000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
#
# Set hard drive sleep time to 20 minutes
hdparm -S 240 /dev/hda
I made them executable then went into /etc/acpi/events and created two new files to catch and then run the script to make the CPU frequency change. The two files can be called pretty much anything as far as I can tell as long as they aren't hidden files. I called one ac_cpu and the other onbattery_cpu. ac_cpu contains:
event=ac_adapter AC 00000080 00000001
action=/etc/acpi/ac_cpu.sh
and onbattery_cpu contains:
event=ac_adapter AC 00000080 00000000
action=/etc/acpi/onbattery_cpu.sh
Finally I had to restart acpid with /etc/rc.d/rc.acpid restart and it worked! Now I can get about 1.5 hours out of a full charge instead of 30-45 minutes. And I can put other commands into the scripts to do other things when the state changes. You can see I already have hdparm to tweak my sleep times.

Posted by Brian | Permalink | Categories: Computers and Technology, Work | |

Thu Oct 20 19:01:08 EST 2005

Moving Forward getting Linux on the Laptop


Today the 60GB hard drive for my laptop arrived at work. I've been wanting to dual boot with Linux on it for some time but the 15GB drive wasn't enough to give either Windows or Linux enough space and still be able to hold my work files. So I was faced with a choice of going cold turkey to Linux which I didn't want to do since I need to actually get work done on it. With the extra space I can make the change gradually like I did at home giving me time to work out any oddness that may crop up. I'm thinking it will go much more smoothly this time since I've already been using Linux for a couple of years but I'm a little nervous since I've never setup any Linux distro on a laptop.

This brings up one big question though. What distro to try first? ;)

Posted by Brian | Permalink | Categories: Computers and Technology, Work | |

Wed Oct 19 22:00:41 EST 2005

The Evils of Wal-Mart


While reading on my current favorite alternative news site, AlterNet I discovered that they have a nice collection of Wal-Mart coverage. I've read here and there on other places about the evils of Wal-Mart. I can't recall exactly where but I think I've seen the occasional article on other alternative news sites like Democracy Now! Anyway, this collection on Alternet is a nice central place to get caught up on the evils of Wal-Mart.

If after reading it you still shop at Wal-Mart I'd be surprised. Oh, and just in case you forgot, you are the consumer and you have power at any retail store. Corporations only think in terms of money. If they are pissing you off or going against what you think is right then don't buy there. When they see their profits take a hit they notice.

Posted by Brian | Permalink | Categories: News | |

Wed Oct 19 21:35:45 EST 2005

To Hell with the Microsoft Tax!


While listening to the Techshow this evening someone pointed out a system that comes with Linux for $150. Now that's an affordable PC and the system specs aren't all that low, except for the memory, but that's the only thing I'd want to upgrade hardware wise. I don't like Linspire so I'd put something else on it. Still though it's a sweat deal if you need a spare system and are on a tight budget. To bad I didn't know about this when I was upgrading my fathers PC.

Posted by Brian | Permalink | Categories: Computers and Technology | |

Wed Oct 12 20:07:41 EST 2005

Cablemodem Suddenly Offline


I haven't had good luck with things staying up here as of late. Not long after my 11 hours without electricity my cable connection up and died with no warning. The modem just sat there blinking its lights for hours trying to get a connection. Obviously I called my ISPs tech support which said it was something wrong with the line itself as far as they could tell and a tech would have to come out. The soonest they said they could get here was in 6 days. What!? 6 days!? That's crazy.

After a little bit of prying I found the only reason they wanted to take that long was because they wanted access into my home. I had already checked my lines as best as I could internal to my home so they could be out tomorrow. I call them them this afternoon and much to my surprise it's already working!

I'm a happy camper now. A geek going cold turkey off of the Net is not a pretty sight. :D

Posted by Brian | Permalink | Categories: Computers and Technology, Miscellaneous | |

Sun Oct 9 02:09:14 EST 2005

11 Hours Without Power


I just had an incredible Saturday evening. The power cut out around 3:30PM or so and just finally came back on at around 2:30AM. It's been raining heavily and our two sump pumps run on wall AC so it's been an entertaining 11 hours of scooping out the pumps with a small bucket and emptying it into the basement sink every 15 to 30 minutes. I thought this may happen one day but figured the likelihood of it to be small, so I've been putting of getting a small generator to run the pumps. Time to start pricing up generators I guess. Now watch, if I do get a generator this won't happen again for 20 years.

Time for bed.

Posted by Brian | Permalink | Categories: Miscellaneous | |

Thu Oct 6 19:49:25 EST 2005

Star Wars Episode 3


Well, I finally got around to seeing Episode 3. After the last two I was sort of worried that this one would suck too. But it seems that George Lucas finally got it right without the help of Joseph Campbell. Or maybe it's just that Jar-Jar's part is only about 30 seconds long and he doesn't actually talk or do anything? Except for the lame "NNNNOOOOOOOOO!!!" it was pretty good. And I like that the effort was taken to tie it into the originals.

I guess the first two didn't totally suck. I still bought them and watch them every once in a while but there is still something missing compared to the originals that I can't put my finger on.

Anyway, I guess I'll be buying this one too.

Posted by Brian | Permalink | Categories: Entertainment | |

Thu Oct 6 19:35:48 EST 2005

America's Warped Priorities


So, you want more vacation? Then leave the US.. I think this explains in part why so many seem to suffer from job burnout. I've known that we are the most worked nation in the world for a long time, but I've never seen the actual numbers. It makes me wonder where our priorities are.

You know, I can't think of any case where someone has said with their dieing breath, "I wish I spent more time at the office...". My priorities are with my family, especially my children. I can replace my job, I can never get back the time I've lost with my family.

At least I work at a place where the priorities are sane.

Posted by Brian | Permalink | Categories: Miscellaneous | |

Sat Oct 1 20:36:55 EST 2005

Photogallery Update


I've been behind in getting my pictures up to the photogallery. I've added pictures from a wedding I was to recently, a Labor Day picnic, and my youngest daughter's first birthday.

Posted by Brian | Permalink | Categories: Miscellaneous | |