Archive for December, 2009

Happy New Year!

Thursday, December 31st, 2009

Today is the last day of the year 2009. Tomorrow is the first day of year 2010 which is really awkward to type. For the last ten years I have been typing two followed by two zeros when writing the year, and it will be really hard to break this habit. I mean, the two zeros just seem to belong there. It’s almost as bad as when we had to switch from 199x to 200x.

Since a picture is worth a thousand words, here is a picture of year 2010 for you:

Since I'm sitting at a windoze box right now, you get a screenshot of Cygwin

According to my intertubes, in the Chinese calendar 2010 is the year of the Tigger, with 2009 being the year of the Piglet which explain the swine flue outbreak. In the new year we can expect a tiger flu which is quite unpleasant. According to my sources (ie. the interwebnets) it works like this: every time you sneeze, a tiger appears behind you and mauls you for 5 minutes straight. Then it checks it’s watch, and says “Fuck, I’m late to my meeting – I’ll see you next time asshole!” and runs off. Unless of course it’s Wednesday – as everyone knows, tigers don’t work on Wednesdays, and so you can expect to be eaten alive on that day.

Worst part about tigers is that they are not lions and so getting in the car does absolutely nothing to prevent the mauling. In fact, some tigers will wait until you get in the car before they eat you.

Other interesting trivia about year 2010 is that it is exactly 28 years from the end of the internet, and therefore the world. In case you forgot, the internet ends in year 2038 due to an epoch bug in Ancient Mayan calendar. You see, Mayans expressed time in terms of seconds elapsed since the begging of the universe (big bang allegedly occurred on January 1, 1970). It’s not the most convenient method, but at least it’s consistent. Unfortunately the proud Mayans were short sighted (like literally – genetic defect caused by to inbreeding) so they used a 32 bit integer to store the time in most of their software.

In the year 2038 this integer will overflow causing a wrong date to be displayed in unpatched systems. Nothing else is expected to happen, but since the Mayans were ancient most people believe that they had some insight into the inner workings of the universe, and picked the 32 bit integer for a reason. That it was not just a poor design choice but rather a prophetic move. They knew the world will cease to exist after 2038 and so a larger integer was not needed.

A bit like early software developers in 60’s, 70’s and 80’s knew that the world ends in 2000 and so used 2 digits to denote a year. It was not lack of competence and lack of foresight but an infallible prophecy. But we don’t talk about that anymore because it didn’t come true.

Speaking of prophecies, wasn’t there another ancient civilization that had a calendar that ends in 2012? I’m almost certain it was either Norwegians, Canadians or Lesbians. Their prophecy is also true… Wait… Why are you snickering? Lesbians are the inhabitants of the Lesbos island in the Agean Sea – I really don’t know why you find it so funny.

Anyway, just for fun I recommend watching Strange Days today. You know, the movie that is set in the near future of December 1999. Bonus points if you have watched this movie for the first time when 1999 was still considered “the future”.

Happy new year folks! Stay safe tonight and watch out for Raptors. They can open doors.

Why is separation between data and system files not a standard OS feature

Tuesday, December 29th, 2009

I have a quick question, and maybe someone can enlighten me as to why things are the way they are. A good computing practice is to partition your drive into at least two parts. You put your data and settings on one partition, and your OS and software on the other one. The idea behind this is that you can re-install or upgrade the OS at any time without actually worrying about wiping out your data from the drive. This is nothing new, right?

In fact most software developers instinctively understand this problem. Most modern software has some limited support for the rare occasion when shit breaks and you need to remove it, and reinstall it from scratch. Its common for applications to store their cache, settings and saved states in some hidden directory in the users’ private profile. That directory does not get removed during routine un-installation unless you specifically request it, or go and delete it manually. This is commonplace.

Smart people go one step beyond this and put all that stuff on a separate partition. But it is tricky because the very process of partitioning drive is usually less than user friendly. Windows for example doesn’t even give you an option when you install it. Linux does, but it usually makes a big mess of the whole procedure. Most installers have two options:

  1. Dude, I don’t give a fuck – in which you let the installer do what it wants, which is usually create one big partition for / and one for swap
  2. Dude, I love partitioning drives – in which you get to do the tedious and boring busy work yourself

At least this was my experience while installing Ubuntu. And I’m using Ubuntu as an example, because this is as mainstream as you can possibly get with Linux. It’s the go-to distro starter for most people, largely due to the fact it is easy to install and configure. I haven’t really installed any Linux in the past year (I just upgrade existing boxes), so maybe things changed since then. The point is, that the “easy”, automatic installation option in just about every popular OS is almost always “put all my shit on a single partition”.

Why is that? Why can’t we build installers that partitions the drive automatically and separates data from system files by default? After all, most people are lazy and so they will instinctively gravitate toward the solution that requires least work. So why don’t we do some of the heavy lifting for them and set up their system the right way from the get-go?

I know, I know – there are some logistic problems here. For one, you probably don’t want to make decisions about your users’ hard drive. You don’t want them to wake up one day and go “I had a 300GB drive, but I can only see 200GB here – WTF?”. So maybe you could just present the user with a nice slider that let’s them pick between “I will be downloading a lot of pr0n and music” or “I install a lot of games and shit”. Moving the slider then adjust a nice pie chart that provides a much needed visual aid that explains the the ratio between “your shit” and “your computer’s shit” areas of the drive.

The second issue is detecting a data partition. If a user already has one in place, you want to leave it alone. This is a bit tricky to resolve, but I’m confident it’s basically a matter of standardization. Basically, you pick a partition and stick with it. So for your given OS, second (or third, or whatever) partition is always data. If the user originally installed the OS using the “I don’t give a fuck” preset that partition is guaranteed to be there. If they did it manually, then they can go fuck themselves and use the advanced installed features to figure that shit out. Once you standardize, it’s easy. Just assume data is there, and maybe ask user if he wants to wipe it or not.

My point is that this doable, but I don’t really see it being done by anyone anywhere. The only exception here is Chrome OS which takes this concept to the extreme, and moves your data off the hard drive and to the cloud. Chrome will be by far the easiest OS to maintain. If shit goes south, you can just re-image the whole drive on the spot. No backups, no troubleshooting, no bullshit.

We could easily get the traditional, non-cloud-based OS’s to a point where they can be restored just as easily. Press a button, wait 5 minutes, start with a fresh system and all your data intact. In fact a lot of hardware vendors already have this halfway implemented. Some Dell models for example have a hidden system recovery partition. You can boot into it, and it will run Norton Ghost and overwrite your drive with a factory default image. Of course this utility will wipe all your data in the process, so it is still considered a last-resort solution. But there is no reason why it needs to be like that. If implemented properly, this could evolve to be a non-destructive maintenance task that can be done few times a year to keep the machine in a good shape.

I’ve been wondering about this particular issue for a few years now. I’m secretly hoping that Chrome with it’s cloud based storage will finally push OS developers in the right direction and will make them start thinking about finally separating system and data files by default. Or maybe not.

Linux: how do I find the devce name of my USB drive?

Monday, December 28th, 2009

Around the time I reviewed Chromium OS, I managed to totally b0rk one of my thumb drives. I somehow botched the dd command, and the device became unusable. When I plugged it in, nothing would happen. Or rather nothing on the UI side. My KDE would simply ignore the drive and pretend it was not there. I didn’t want to just throw out the USB stick, so I decided to figure out what device name gets assigned to it, and then repartition it again.

How do you do that? The simplest method is to watch the log files. When you plug in a USB the device, your system should make a note of it in /var/log/messages. So you should do the following:

tail -f /var/log/messages

In case you didn’t know, the tail command prints out the last few lines of a text file, and the -f argument basically means “follow”. So tail will basically pring any new lines that are appended into the console in real time. Once you issue this command, just plug in your device. Your output should look something like this:

Dec  1 12:56:44 malekith kernel: [13631.153753] usb 2-1: new high speed USB device using ehci_hcd and address 4
Dec  1 12:56:44 malekith kernel: [13631.288125] usb 2-1: configuration #1 chosen from 1 choice
Dec  1 12:56:44 malekith kernel: [13631.288669] scsi5 : SCSI emulation for USB Mass Storage devices
Dec  1 12:56:49 malekith kernel: [13636.295004] scsi 5:0:0:0: Direct-Access     Kingston DT 101 II        1.00 PQ: 0 ANSI: 2
Dec  1 12:56:49 malekith kernel: [13636.295900] sd 5:0:0:0: Attached scsi generic sg3 type 0
Dec  1 12:56:49 malekith kernel: [13636.306962] sd 5:0:0:0: [sdc] 7831552 512-byte logical blocks: (4.00 GB/3.73 GiB)
Dec  1 12:56:49 malekith kernel: [13636.308590] sd 5:0:0:0: [sdc] Write Protect is off
Dec  1 12:56:51 malekith kernel: [13636.315523]  sdc: sdc1
Dec  1 12:56:51 malekith kernel: [13637.905840] sd 5:0:0:0: [sdc] Attached SCSI removable disk

Check out the second to last line – it says sdc1. What does that mean? That means that my b0rken thumb drive is assigned to the /dev/sdc1 device. Now that I know that I can easily run fdsk on the device to format it and rebuild the partition table that was messed up by a botched dd command.

It’s that easy. I’m putting it here for future reference more than anything else.