Tuesday, March 31, 2009

A Widget

I decided to try my hand at Widget development recently, and the result was this (here featured next to my favorite widget):

It doesn't do much, besides prove that I can access the command line from a widget and that I have some basic dynamic html skills. To be more precise, it runs "id -un" and "uname -n" and refreshes with a click of the refresh icon. So if you're connected to the internet through some network, it'll show that address instead of the local address (like, guest-wireless.usc.edu).

Anyhow, I'm making it available here. Maybe you'll come across it, and it will be just perfect because you were just thinking of how handy it would be to have a widget like this. Or maybe you'll download it for kicks, and it will prove itself useful beyond your wildest widgety dreams.

Download the "Name and Location" widget

Monday, March 9, 2009

Triple Booting on a Mac

When I first got my Macbook Pro, I was not exactly computer savvy, but in the spirit of forwarding that goal I decided that I needed my computer to have a Mac, Windows, and Linux OS. And I wanted native booting, not virtual machines. The process of triple booting on a Mac is not that hard if you know what you are doing, but as I had no idea what I was doing, it took me a while to figure out. I cobbled together numerous tutorials and help pages and I am posting my version here so that others might make use of it.

This isn't exactly something I built, but I think it is in the spirit of 'Building Stuff, Makin' Friends' (though I guess I pretty much decide the spirit of this place anyway). So, without further ado, the tutorial.

A summary first:
This tutorial assumes you have a Mac, with the Mac OS already installed. It also assumes no prior partitions on your drive. Furthermore, it assumes that your Windows install CD is exactly that--a SINGLE install CD (you won't be able to eject during the install process because you don't have the drivers for that installed!).

What you will essentially do is this: Install the rEFIt boot Menu, use Mac to make your partitions, install Windows first, install Linux second. The rest is just details.

What you need:
Mac install CDs (I have Leopard)
Windows install CD (I have XP)
Ubuntu (I used 8.10, the 64-bit version. The download is free. Burn it to CD with Disk Utility)

Download and install rEFIt.

Use the terminal (Applications->Utilities->Terminal) to write partitions. This assumes no previous partitions. (Type the stuff in italics. Be warned! This stuff can be dangerous. If you are not sure of what you're doing, back up your data, and maybe read up on these commands before executing them.)

sudo diskutil resizeVolume disk0s2 249G "HFS+" "Linux" 17G "MS-DOS FAT32" "Windows" 32G

Disk0s2 should be the Mac volume. I wanted to leave 249 GB to it, and put 17GB aside for Linux and 32 for Windows. The three sizes must add up to less than your total available space on the drive. The command
diskutil list will show you the partitions you have set up.

Windows will have to reformat the partition it will be using, otherwise it will install but not boot. I did this to get the installer to give me that option:

sudo dd if=/dev/zero of=/dev/rdisk0s4 bs=1m count=100

That writes over the metadata for that partition, making it Unknown Format to the installer. Alternatively, it seems like you can also just delete and recreate the partition in the Windows Installer instead of using the partition you created with the Mac OS. I prefer the former, though, because I know it worked for me.

Install Windows by putting in the CD and restarting with key C held. After setup, choose the right partition to install to. It will restart a few times, so make sure to boot into Windows to complete the process. After it is done, use the Mac OS install CD to install the drivers for Windows (for older Macbooks it may be necessary to find these drivers in BootCamp and burn them to a CD).

Next, put in the Ubuntu CD and boot it as a live CD. Open up the terminal. Back up the MBR (Master Boot Record). I don't remember if you need to use sudo to get this to work. If permissions are denied, just add it in.

dd if=/dev/sda of=/tmp/sda.mbr bs=512 count=1

Run the installer (it is sitting on the desktop). Choose to partition manually. Select the right partition (sda3 should be it) and press Edit partition. Choose to mount to '/', to format it, and to use ext3. Go to next and ignore the error message about swap. When offered the install summary, look at the advanced options (important!). Install the boot loader on sda3 (your Linux partition) and not on the default (that will make Windows unbootable and none of the fixes I found actually worked without jeopardizing the rest of my systems).

Restore the mbr. I'm not sure exactly when this is supposed to be done but I did it after hitting install and it worked fine. Again, in the terminal:

dd if=/tmp/sda.mbr of=/dev/sda

Wait for the installer to finish. Restart as necessary. Actually, try to shut down instead of restart, because at this point there's a bug that I experienced where restarting freezes my computer on the restart part. Shuts down works fine though, so shut down and press the power button.

Update the MBR by using the Partitioning Tool in rEFIt. When prompted, choose Yes to update. Boot Linux. I had to try booting it twice, but that seems to just be a fluke. I had a lot of those during this process, actually. Make sure all problems are real problems by checking if they happen at least twice.

Finally in Linux open the terminal to make a swap space. Use sudo when permissions are denied.

dd if=/dev/zero of=/swap bs=1024 count=1048576
mkswap /swap
swapon /swap
chmod 600 /swap

Now check all your systems to see if they boot properly.

An afterword: who needs that many operating systems anyway?
Well, I do. Since installing all three operating systems, I have found that I use them pretty equally. I use Linux for certain robotics and programming projects, Windows for gaming and other programming projects, and Mac just because it works best with this particular machine and also for programming certain things, like Widgets. There are a lot of things I wouldn't have tried if I didn't have the right OS, but now I can run just about anything. And now that I created a 32-bit environment in my Ubuntu for compiling 32-bit code, I can really run just about anything.

Hope this helps you out!

Monday, March 2, 2009

Robot Windchime

It took me much longer than I would have liked, and didn't come out as I initially imagined, and my room is now a mess (and my laundry is still wet, since I forgot to put it in the dryer). Oh well...the creative process can be distracting...

A word about the process: Bass wood and brass tubing, a part from an old hard drive, beads. A bunch of pissed off room- & suite- mates, even though I put away the circle saw at 10:30 when they all went to sleep. I also managed to cut my finger with the regular, manual saw I had to use as a replacement. And, since I insisted on finishing it tonight, I only have seven hours until my first class.

It does sound surprisingly nice for total guesswork though. So I have only few regrets.