Disks and Partitions

Ok, I’ve recovered from my paranoia. Let’s get this sucker installed. Now, there are some nice easy graphical programs for writing images to disk. If you want to take this route, install usb-creator-gtk, but the cool kids are going to do this the low level way from the command line. The program we are going to use is dd. dd is short for data destroyer, due to its ability to destroy all the data on your computer if used incorrectly (well ok, it’s not really short for data destroyer, but the real reason for its odd name has been lost in the mists of time). Now, on linux, all hardware is represented as files that you can read from and write to (if such things make sense e.g. you can play music by copying a suitable music file to the soundcard device file). The same is true of our sd card. Now, you may be thinking, so what? Surely all disks are accessed as files, that’s how come I can copy files from one disk to another. However, what you accessing isn’t the disk directly but a filesystem on one partition of the disk, which has been mounted on the computer’s file hierarchy. To understand what I mean, it might help to briefly explain how a disk looks to the computer.

A formatted disk, like our sd card, is commonly made up of various parts that can be accessed and modified with software. The first part is the MBR (master boot record), which is where information about the rest of the disk stored, including how to boot (start the computer) from it. The rest of the disk is divided into sections called partitions, where these partitions are and how big they are is stored in the MBR. Each disk can have (for historical reasons) four primary partitions. These primary partitions can be normal partitions or extended partitions. Extended partitions can hold additional logical partitions to enable you to get over the four primary partitions limit. Primary partitions are numbered first and the first logical partition is partition five, even if all four primary partitions haven’t been used. In the old days there were rules about what data could be stored where, but nowadays (assuming you are using a common modern operating system and boot loader), the choice is pretty arbitrary.

There are many reasons you might partition a disk into several pieces. The most common reason in a home environment is to ensure that there is space on the disk that is always reserved. This might be so that a laptop can perform a suspend to disk (where it writes the contents of ram to disk and then turns itself off so that when it is turned back on it can resume exactly as it was) or so that you don’t accidentally fill up all your harddisk space, including that needed by the operating system to perform basic functions (though modern harddisks are so huge this isn’t really a concern any more in the home environment) or to allow two different operating systems to coexist on the same disk (though virtualisation, running one operating system inside another, has made this less common, too.)

If you want to have a look at how your computer is currently partitioned fire up “sudo gparted” (if it isn’t installed run “sudo apt-get install gparted” first). Be careful not to change anything else you could completely hose your computer. This is how the first hard drive in my computer is set up:

As you can see I have three primary partitions: one containing my Ubuntu installation, one an old windows installation and one which is an extended partition that contains a logical partition that is a swap partition (swap space is used as virtual ram when you run out of real ram). As I’m only using three partitions, the extended partition isn’t actually necessary and the swap partition could have been created as a primary partition.

Series Navigation<< Verifying the Downloaded Operating SystemFile Systems >>

One Reply to “Disks and Partitions”

Leave a Reply

Your email address will not be published. Required fields are marked *