Perl programmer for hire: download my resume (PDF).
John Bokma MexIT
freelance Perl programmer

Partitioning: planning and how to

Tuesday, August 5, 2008 | 0 comments

The first time I had installed Ubuntu on the Dell Vostro 200 ST, I just had selected the option to use the entire hard disk in the installation program. This gives two partitions: one dedictad to swap, and one for the remainder.

Since the computer is being used for software development, I decided to do it right this time. I already knew that it was a good idea to dedicate a separate parition to the /home directory, and also knew that I might want to have more than 3 paritions. And after using Google for some time, and a careful study of the print-outs I had made, I had quite a good idea (I hope) of what I wanted.

Planning Partitions

After having read Karsten's excellent Linux Partitioning mini-FAQ I came up with the following parition scheme for the 320 GB Samsung HD321KJ Spinpoint in my Dell Vostro 200 ST:

The recommendations for /boot and / (root) are taken from the "suggested laptop/desktop configuration". For swap space I decided to use 2 GiB. The Dell Vostro has currently 2 GiB of memory, and using twice the amount of memory; 4 GiB or even 8 GiB - I might want to upgrade to 4 GiB in the future - sounded like overkill to me. I also decided to go with a large /tmp parition. For the other partitions I followed (again) more or less the advice by Karsten M. Self.

Note: currently, I have a root (/) partition of about 512 MiB because I ran into upgrading issues with the 250 MiB one. While it might have been possible to keep the 250 MiB one, I decided that it was too much hassle and did a fresh install when Ubuntu 8.10 was released with a slightly different partition scheme.

The reason for a separate /tmp and /var partition is that I want both to be bounded by a known limit, instead of, for example, log files in /var growing and growing, eating up more and more of the available space.

I decided to dedicate the first three out of four maximum possible primary partitions to the first 3 paritions in the above list. The fourth possible primary parition would become the extended partition in order to contain the 5 other paritions; called logical partitions because they are allocated in the extended parition:

Partitioning using fdisk

During the installation of Ubuntu one can select the Manual option in the "Prepare disk space" step. However, since I wanted finer control over the actual size of each partition - it was not clear if 2 GB means 2 GiB (2,147,483,648 bytes) or 2 GB (2,000,000,000 bytes) - I decided to use fdisk to partition.

So I inserted a CD with Ubuntu 8.04.1 desktop AMD64 in the computer, rebooted it, and pressed F12 to go to the boot menu. In the boot menu I selected CD and shortly after I was presented with a menu with languages to select from. I picked the default (English) and got another menu. I selected the first option: "Try Ubuntu without any change to your computer".

I had already checked the CD for defects (via the same menu, recommended). Moreover, if your computer is brand new I strongly suggest to select the "Test Memory" option, and let it run for several hours. Yes, that's right; several hours.

My computer, a Dell Vostro 200 ST, has a USB-SATA race condition; it now and then hangs during booting. If you have a Dell computer, and you experience boot problems, make sure to read: Fixing the Vostro hang issue after installation. If you have this problem while booting from CD, just turn off the computer, and try again.

After a short while the desktop appeared (if not, and your computer is a Dell, see the previous note). From the Application drop down menu (top left) I opened the Accessories submenu from which I selected the Terminal entry.

In the Terminal I typed:

ubuntu@ubuntu:~$ sudo fdisk /dev/sda

and was greeted with:

The number of cylinders for this disk is set to 38913.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help):

Next I entered "p" (without the quotes) to get information on the size of a cylinder:

Disk /dev/sda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000080

This information was followed by an overview of the current partitions (the p command prints the partition table). I used the d command to delete all the old paritions.

Next, I decided how many cylinders of 8225280 bytes were required for each of the aformentioned partition sizes. For example, for 125 MiB: 125 * 1024 * 1024 / 8225280 = 125 * 1024 * 2 / 16065 gives (rounded to two digits): 15.94. Since I want for each partition at least the given amount I round up (ceil) the number of cylinders. The table below gives the required number of cylinders for each partition except for the extended and final partition, because both use all available space (will be explained below).

devicetypemount onsizecylinders
/dev/sda1primary 1/boot125 MiB16
/dev/sda2primary 2/250 MiB32
/dev/sda3primary 3swap2 GiB262
/dev/sda4primary 4 extended-remainderremainder
/dev/sda5logical 1/tmp20 GiB2611
/dev/sda6logical 2/usr10 GiB1306
/dev/sda7logical 3/var4 GiB523
/dev/sda8logical 4/usr/local4 GiB523
/dev/sda9logical 5/homeremainderremainder

While experimenting with fdisk, I noticed that when one specifies a size with +size without a postfix, the actual size becomes size + 1 cylinders. This is not what I expected. Since I want to use the +size notation to specify the size of a partition I removed 1 from the number of cylinders for each partition. Below follows a transcript of a complete partitioning session of the 320 GB Samsung HD321KJ Spinpoint (/dev/sda):

ubuntu@ubuntu:~$ sudo fdisk /dev/sda

The number of cylinders for this disk is set to 38913.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-38913, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-38913, default 38913): +15

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (17-38913, default 17):
Using default value 17
Last cylinder or +size or +sizeM or +sizeK (17-38913, default 38913): +31

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (49-38913, default 49):
Using default value 49
Last cylinder or +size or +sizeM or +sizeK (49-38913, default 38913): +261

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Selected partition 4
First cylinder (311-38913, default 311):
Using default value 311
Last cylinder or +size or +sizeM or +sizeK (311-38913, default 38913):
Using default value 38913

Command (m for help): n
First cylinder (311-38913, default 311):
Using default value 311
Last cylinder or +size or +sizeM or +sizeK (311-38913, default 38913): +2610

Command (m for help): n
First cylinder (2922-38913, default 2922):
Using default value 2922
Last cylinder or +size or +sizeM or +sizeK (2922-38913, default 38913): +1305

Command (m for help): n
First cylinder (4228-38913, default 4228):
Using default value 4228
Last cylinder or +size or +sizeM or +sizeK (4228-38913, default 38913): +522

Command (m for help): n
First cylinder (4751-38913, default 4751):
Using default value 4751
Last cylinder or +size or +sizeM or +sizeK (4751-38913, default 38913): +522

Command (m for help): n
First cylinder (5274-38913, default 5274):
Using default value 5274
Last cylinder or +size or +sizeM or +sizeK (5274-38913, default 38913):
Using default value 38913

Command (m for help): a
Partition number (1-9): 1

Command (m for help): t
Partition number (1-9): 3
Hex code (type L to list codes): 82
Changed system type of partition 3 to 82 (Linux swap / Solaris)

Command (m for help): p

Disk /dev/sda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000080

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          16      128488+  83  Linux
/dev/sda2              17          48      257040   83  Linux
/dev/sda3              49         310     2104515   82  Linux swap / Solaris
/dev/sda4             311       38913   310078597+   5  Extended
/dev/sda5             311        2921    20972826   83  Linux
/dev/sda6            2922        4227    10490413+  83  Linux
/dev/sda7            4228        4750     4200966   83  Linux
/dev/sda8            4751        5273     4200966   83  Linux
/dev/sda9            5274       38913   270213268+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
ubuntu@ubuntu:~$

In the above transscript note that:

The installation of Ubuntu 8.04.1 after partitioning

After I had written the modified partition table back to the 320G harddisk drive, I double clicked the Install icon on the Ubuntu desktop. In the fourth step, "Prepare disk space", I selected Manual.

Ubuntu install: prepare partitions.
Ubuntu install: prepare partitions.

Next I edited each partition in order to specify a mount point, and to have it formatted (except for the swap partition). See the above screenshot for the end result. In the above screenshot you can also see a device sdb: a memory card inserted in a USB memory card reader, used to store the screenshots I made, and the text captures of the shell.

After I had clicked the Install button in step 7 of the installation process, I got a warning dialog stating that some of the partitions I had just created are too small.

"Some of the partitions you created are too small" warning.
"Some of the partitions you created are too small" warning.

The warning dialog stated that it wanted the root partition (/) to be at least 2084264448 bytes large. I guessed that at this stage of the installation the installer hadn't figured out yet that the data was going to be spread out over several partitions, so I ignored the warning, and clicked on Continue.

It turned out that I had guessed right. The installation was complete after some time, and I clicked the "Restart now" button and after some more waiting was greeted by the login prompt.

Because my Dell suffers from a USB-SATA race condition, I was curious how often out of 10 the machine would just hang. So at the login screen I shut down the computer, removed the USB card reader, and turned the computer back on. After 7 attempts, each resulting in the boot process getting stuck while showing the Ubuntu splash screen with the "knight rider" progress bar, I decided to reconnect the USB card reader with the memory card inserted and try again. And this time I could login, and fix the issue in software. No idea if I was just lucky, or that connecting the USB card reader with a card inserted did the trick.

Paritioning related

Also today

Please post a comment | read 0 comments | RSS feed