CPU upgrades are fun

Why do I do this to myself? I decided to upgrade my PC's CPU from 2.4 GHz to 3.0 GHz. I had a good reason to do so, the old processor was one that I bought cheap on ebay and it was a poor match for my motherboard. Also, the new CPU had three times as much cache and was more energy efficient, not to mention that it ran at a faster FSB and would therefore increase the speed of my memory.

Unfortunately the switch did not go smoothly. After I inserted the new CPU, the computer tried to boot three times before it finally booted far enough to allow me into the BIOS. There, I noticed that I had hard-set the multiplier to that of my old CPU, so I fixed that, and rebooted. This time it almost finished loading Linux before it died. Multiple reboots and playing with the BIOS got me nowhere, usually it wouldn't even make it to the BIOS screen. Finally, I found the motherboard manual and did a BIOS reset. Oddly, afterwards it said "recovering BIOS from IDE partition" and refused to boot past that point until I disconnected my hard drives. When it finally did boot, the system was still unstable.

So, I put in the old CPU — it's a big pain to switch these things — and thankfully it booted faithfully. Then I downloaded a newer BIOS, saved it on a floppy (yeah, I still have some) and went though the rigamarole to flash the new BIOS onto my motherboard. Afterwards my PC went through the whole "recovering BIOS from IDE partition" thing, requiring me to remove the hard disks, but I figured that the BIOS had been loaded. Since everything seemed to be working with my old CPU, I decided to try the new one again.

No luck. Just as bad as before. At this point, I'm thinking that something must be broken and I'm just hoping that it isn't my fault. Next time I get to the BIOS, I crank down the CPU speed to just 2 GHz and the memory speed to just 800 MHz, and this time it boots all the way into Linux but dies 5 minutes later. So now I'm thinking that it must be a bad CPU. Or maybe a bad power supply, because bad CPUs usually don't boot at all, while bad power supplies are better at keeping you guessing. It was 2 am, so I went to bed debating whether to buy a new power supply, or whether to try and exchange the CPU at the store.

In the morning, I checked online for the power consumption of the new CPU. Yup, exactly the same as the old one, but I still wasn't convinced that it was the CPU's fault. But in my day, I have seen many failed power supplies but never a faulty CPU — the quality control at Intel is very strict. I re-checked the online info for my motherboard to make sure it was compatible, and yes it was for the BIOS that I had loaded.

Since it was 8 am on a Sunday and the stores would not open for three hours, I decided to give the BIOS one more shot. So I switched back to my good CPU (gah! what a pain!) saved a BIOS to floppy again, and re-flashed my motherboard. This time I noticed something odd.. the checksum was all decimal digits, but last time I could have sworn that I saw some hexadecimal digits. If the checksum was not the same as before, that could not be a good thing. So I tried again… and again it was different. At this time I'm also cursing my motherboard manufacturer, because what good is a checksum if it just prints it but doesn't, you know, check it and tell you if it is wrong!

You know what my problem was? A bad floppy! Since my BIOS was trashed I had to reset it again and boot up and save a new BIOS on a new floppy and re-flash and then re-flash again to make sure the checksums matched and then finally reboot. And you know, that first boot screen goes by too fast for my monitor to even come out of it's power-save mode, so I cannot even verify that the BIOS version of my motherboard matches the version that I loaded from the floppy.

Anyway, after yet another CPU switch, my computer is finally up and running at 3 GHz. And 10 hours of my weekend are irretrievably lost. Well, I can't say "lost" because it was kinda fun, but only because it all worked out in the end.

A collector of virtual computers

You know those people who keep all their old computers on the off-chance that they might eventually find a use for them? The ones that even have their old Commodore 64 and its original monitor? Well, I can understand these people because I have a fondness for old things… especially old computers. But I'm not a packrat and since I usually only stay in one city for a few years, having too much stuff weighs me down in a very real way.

So, a while ago I started the habit of virtualizing my old computers before selling them — or recycling them, if too old to sell. This started with my old Amiga 1200, which I had been packing around from 1992 until 2007. The old beast had to go but I couldn't really part with it, because I had written a ton of old software for it that wouldn't run on any other machine:

  • My first GUI widget toolkit, written in Amiga BASIC.
  • My first 3D graphics library, written in 68000 assembler.
  • My first interpreter, for Scheme (a variant of LISP).

None of these are particularly useful to me now, but I still enjoy playing with them now and again. So I spent a day recreating this old machine's hard drive on my Linux box, copying the files over on a 720k floppy. Then I downloaded an emulator, and ran the virtual machine… with all the files exactly where they used to be.

Since then, virtualizing my old computers has been a habit of mine. For most of my computers from school or work, I just keep a copy of all the files. But for my home computers, I keep the old hard disk (or sometimes just the partition) and run it as a virtual machine… either inside VMWare or Parallels (or for Linux, just inside a chroot). So for example, on my main home computer I have:

  • 64-bit Linux as the main operating system, for work.
  • A virtual Windows XP system running under VMWare, actually a copy of an older work machine.
  • My old 32-bit home computer running in a chroot jail with its own X session. I use CTRL-ALT-F9 and CTRL-ALT-F7 to switch back and forth between my "work" computer and my "home" computer.
  • Another Windows XP virtual machine (running on my virtual "home" machine).
  • My old Amiga with all its software, games, and art.
  • An Apple II+, the first computer I ever used.
  • Full backups from school/home/work going back to 1988.

You might think this is a bit excessive, but hey, none of these take up any shelf space, and it's nice to keep all this old stuff around. Now if there was only some way that I could virtualize my old pets, so that I could keep them around forever, too.

BSOD

Even though my PC is a virtual machine, a BSOD is a very real PITA. I can guess why it happened… I let my MacBook battery die while the virtual PC was running. Oddly, it didn’t happen all in one go. First I got a forced CHKDSK on reboot, which ran for a couple hours and politely told me what files might be toasted. After the next reboot, I reinstalled the trashed files and crossed my fingers. On the next restart, the blue screen of death appeared. Since I was running a virtual PC, I was able to get a screen shot.

Some friendly Microsoft help pages told me that a STOP 0X00000024 on the BSOD means a problem with NTFS, either a bad driver or a corrupt file system. But since the machine could no longer boot far enough to run its own CHKDSK, I decided to cut my losses and restore the partition from a backup. Which I accidentally did in reverse. So, yeah, instead of doing a restore, I had just created a backup of a corrupted partition. Gah! Then I suddenly became paranoid and made backups of all my other partitions, in the correct direction of course.

With my only backup overwritten, running CHKDSK was my only hope, but I no longer had a Windows machine to run it from. So I took a deep breath, booted my Mac from the WinXP install disk, went into the repair console (no automatic repair for me, thanks), and ran "CHKDSK /R" manually. I half expected it to trash my whole Mac. But after chugging away for an hour and some, it said it was done, and a reboot proved my Mac to still be alive. And wonder of wonders, my virtual PC started up just fine. Now I just have to cross my fingers that no system files are missing.

This confirms to me why having more partitions is a good thing. I keep all my documents on their own "Work" partition, so even if a system partition gets trashed, I won't lose them. Also, having Windows on a real partition instead of in a virtual "disk file" made running CHKDSK on it a straightforward, though scary, endeavour. And even if I had failed to make it bootable, I can always mount the partition under OS X or Linux and snatch any important files.

Long story short: David 1, BSOD 0.

Depmod and Linux love/hate

This is a reminder to myself. Rather simple, really.

If no USB devices show up with lsusb, then run depmod.

The story here is pretty simple. I wanted to scan something, but the scanner software couldn't see my scanner. I searched /dev for scanner devices, and found one. I did "lsusb", and found nothing. My next step, foolish me, was to install new drivers, using a package from Hewlett-Packard that looked fairly safe. The install proceeded cleanly, until it tried to probe for the scanner… it couldn't find it.

My next step? Reboot. And… kaboom. Graphics, ethernet, and even some of my disk partitions, gone. Panic time. My first thought was, what has HP done to my system? But apt said the package database was clean. I searched through the kernel modules, they were all unchanged. Nothing funny in /etc/init.d either. The HP drivers seemed to be completely in userspace. Well, that's nice, but why wasn’t my system working? I reinstalled the video drivers. Reboot. No change. Boot into safe mode, and see lots of odd stuff… ext2 driver is missing? That would explain the missing partitions. I try to manually load some modules with "modprobe", but none of them are found. Maybe the hard drive is corrupt. Finally (after losing over an hour) I thought to myself, maybe there is nothing wrong with my system, after all. I ran "depmod", rebooted, and… everything came up! I did my scan, life is good.

So, that is why I love and hate Linux. It can be easy to mess things up, but everything is open for viewing and, generally, whatever goes wrong can be fixed. I still have no idea why the module dependency database was erased. I know that the only reason my machine even stayed bootable afterwards was because the most important modules were in the initrd.

I cannot help but think, what if something similar were to happen to my MacBook? I would probably be up the creek with no paddle. Or maybe I would find out that fiddling with Mac internals is not so bad. I am not eager to find out.

Sharing the OS X desktop with Linux

This article is about my adventures in getting Linux to run on the OS X desktop. Usually Parallels and VMWare only allow the Linux virtual machine to run fullscreen or in a window, in contrast to they way they allow Windows to share the OS X desktop in their "Coherence" and "Fusion" modes.

Fortunately, by using X11 on OS X and XDMCP on Linux it is possible for Linux to use the OS X desktop as if it was its own, and with virtually no loss of performance. I also discovered other tricks along the way, for instance the OS X nfs server is much faster than Parallels' shared file system. The instructions are too long for a news post, so I have set up a wiki page for them.

When I purchased my MacBook back in October 2009, my very first action was to load Windows and Linux on it. Linux because it has been my day-to-day operating system for years, and Windows because it is a necessary evil for financial software and the like. A magical piece of software called rEFIt allows me to choose an operating system at boot time, and a shared "Work" partition keeps all my code available to both Linux and OS X.

So, with Parallels, I chose to run my virtual machines directly off the Windows and Linux partitions. This is how I have always created virtual machines. It's a fair bit more work than using a virtual drive, but I always like to know that I can boot the partitions directly if I have to. And it is, in fact, irrelevant to the topic at hand: getting Linux to share the OS X desktop works identically regardless of how the virtual machine has been set up.

MacBook quick sleep

After I sold my old laptop and bought a MacBook Pro, I was constantly annoyed at how long it took to go to sleep.  When I close the lid, that usually means I'm about to toss my Mac in my bag and go… but the fact that the hard drive keeps spinning for 20 seconds makes me hesitant to do the whole "toss it in the bag" thing.  Why did it take so long for Mr. Sandman to arrive?  Was my MacBook busy counting electric sheep?

Well, actually it was busy saving its RAM to the hard drive.  Which seems silly, because it keeps the RAM powered while it sleeps.  It only saves the RAM to disk because Apple is concerned that you might leave your laptop in sleep mode for so long that it runs out of power, forcing it to read the RAM back from disk when it powers back up again.  Thank you for your concern, Apple, but what if a faster sleep is more important to me than saving the RAM to disk?

Apple doesn’t provide any sleep vs. hibernation control in its preferences, but this page says how to change hibernation modes on the command line. And it’s dirt simple!

  • sudo pmset -a hibernatemode 0

The above command makes my MacBook go to sleep instantaneously when I close the lid.  I can grab it and go, without worrying about jarring the hard drive. And I only have to run this command once, not every time I put my Mac to sleep.

The "hibernatemode" actually has several settings, for which I have created aliases in my .bash_profile:

  • alias hibernatefast="sudo pmset -a hibernatemode 0"
  • alias hibernatefull="sudo pmset -a hibernatemode 5"
  • alias hibernatesafe="sudo pmset -a hibernatemode 7"

Here, "hibernatefast" is the immediate sleep, the way that I like best; "hibernatefull" is the true hibernate mode that saves RAM to disk and turns off the power, which is what I need when boarding an airplane; "hibernatesafe" is the Apple default combined sleep/hibernate mode.