Introduction
Everybody’s got an opinion, and I’m no different. After reading Trent’s piece yesterday, I thought I’d add my two cents as my partitioning scheme is quite complex (though I can think of several ways to make it worse). For newbies, some of this is unlikely something to try, but you might want to read anyway to get an idea of what can be done.
For starters, I have 1GB of physical RAM, and 4GB of swap space split over two drives. I have two 120GB drives that I use for my primary system that are split into 8 partitions (and a logical ninth). Most of these partitions mirror (RAID-1) each other so that if one drive fails, the other maintains the system until I can replace it. You may note that the swaps are not mirrored, but both swaps and the md08 array are encrypted. Like Trent, I intended a dual boot with Windows, so the first partition on sda is NTFS. (Of course, I haven’t actually had a Windows OS on that partition in about two years, but it’s nice to know I have it if I find a game that won’t play nice in Wine.) Also note that /boot is a mirrored partition, which keeps the data safe, but upon bootup the boot loader (LILO/GRUB) accesses only one of the two drives (i.e., sda3, not md3).
| # cfdisk /dev/sda | ||||
| Name | Flags | Part Type | FS Type | Size (MB) |
|---|---|---|---|---|
| sda1 | Boot | Primary | NTFS | 10001.95 |
| sda2 | Primary | Linux swap | 1998.75 | |
| sda3 | Boot | Primary | Linux raid autodetect | 254.99 |
| sda5 | Boot | Logical | Linux raid autodetect | 12000.69 |
| sda6 | Logical | Linux raid autodetect | 501.75 | |
| sda7 | Logical | Linux raid autodetect | 13999.43 | |
| sda8 | Logical | Linux raid autodetect | 1497.01 | |
| sda9 | Logical | Linux raid autodetect | 79777.00 |
| # cfdisk /dev/sdb | ||||
| Name | Flags | Part Type | FS Type | Size (MB) |
|---|---|---|---|---|
| sdb1 | Boot | Primary | Linux ReiserFS | 10001.95 |
| sdb2 | Primary | Linux swap | 1998.75 | |
| sdb3 | Boot | Primary | Linux raid autodetect | 254.99 |
| sdb5 | Boot | Logical | Linux raid autodetect | 12000.69 |
| sdb6 | Logical | Linux raid autodetect | 501.75 | |
| sdb7 | Logical | Linux raid autodetect | 13999.43 | |
| sdb8 | Logical | Linux raid autodetect | 1497.01 | |
| sdb9 | Logical | Linux raid autodetect | 79777.00 |
| # df -h | |||||
| Filesystem | Size | Used | Avail | Use% | Mounted on |
|---|---|---|---|---|---|
| /dev/root | 479M | 111M | 368M | 24% | / |
| /dev/md3 | 244M | 45M | 199M | 19% | /mnt/md03_boot |
| /dev/md5 | 12G | 9.9G | 1.3G | 89% | /mnt/md05_alt |
| /dev/md7 | 14G | 7.3G | 5.8G | 56% | /mnt/md07_apps |
| /dev/mapper/cryptvar | 1.4G | 1.1G | 344M | 76% | /mnt/md08_var |
| /dev/md9 | 75G | 72G | 2.7G | 97% | /mnt/md09_home |
| # cat /proc/swaps | ||||
| Filename | Type | Size | Used | Priority |
|---|---|---|---|---|
| /dev/mapper/cryptswapa | partition | 1951888 | 52340 | -1 |
| /dev/mapper/cryptswapb | partition | 1951888 | 0 | -2 |
Some Explanations
My computer uses its swap space greedily despite my setting swappiness at 20. I often have a lot of memory intensive apps and commands going at once, so I use a lot of swap space. I also expect an upgrade in the future, so the large size is in preparation for that. The general rule of thumb is to have at least as much swap as your physical memory, if not double. This, however, is really geared towards laptops. Many use the suspend-to-disc feature which copies the contents of the physical memory to swap, then turns off the RAM to save battery life. This obviously requires as much unused swap space as used memory. So if you have nearly a full amount of RAM being used, and if that’s the case you’re probably using almost as much swap, you need nearly double the amount of physical memory in swap to accommodate the RAM’s data in order to suspend.
Author’s Note: A commenter has brought to my attention a rather serious error in the following paragraph that I dragged through to other parts of the article, including the conclusion. To fix it, I’ve opted for leaving the original paragraphs in place in their entirety though struck out, with revisions, where necessary, following the originals. I apologize profusely for the error, and my humiliation is profound. I considered a lengthy explanation of where that all came from, but it would sound too much like making excuses and backpedaling. So suffice it to say it’s not a bad idea to keep swap on a separate hard disk from the rest of your system, and also that when something doesn’t ring quite true, you should heed your inner voice and double check it before making notes, much less use those notes as a basis for published work. =D Again, terribly sorry, and please ignore the following struck passages.
With regards to location, it is best to keep your swap space at the beginning of your drive, but this isn’t so much about being at the beginning of the drive, as at the beginning of a platter, and being on a platter alone. Swap inevitably has far more read/writes than typical storage and operations, so you want the seek arm to travel the least amount of distance from rest to swap space and back. More importantly, you want the first seek arm working on swap while the others below it have access to the rest of your data. Otherwise, you would frequently have a situation where one arm is reading data from one side of the disc, and then because the computer wants to store it in swap for a while, writes to another part of the disc, this process would simply be repeated over and over for the whole size of the file. It’s much preferable to have the reads coming from one arm, and the writes going with another. For similar reasons, you don’t want your swap split onto two platters which is why the beginning of a platter is suggested. One could choose to create a swap partition at the beginning of the second platter of one’s hard drive and have the same results, but that takes a certain level of knowledge about the exact starting point of the second platter which most people won’t bother to find. It’s easiest to keep swap at or near the beginning of the drive so you can be fairly confident you’re in good shape. What isn’t suggested often, however, is to keep any rarely used partitions near the beginning as well to avoid read/writes with the same arm.
For example, my dual HDDs have four platters (each) which makes each platter about 30GB, and this works out to swap being on the first platter by itself most of the time as my first partitions are Windows/spare (which are generally unused), the swaps, /boot (which is only used at boot time), and a partition I call slackalt that serves as a nearly complete copy of my working Slackware system. I use the alternate for when I break something on my primary system, and booting into a system nearly identical to my own to do repairs is much preferable to using a live CD of a foreign system. (This partition can also serve as a location for installing alternate Linux distros when the mood takes me to experiment.)

I suggest that you learn some more about how a hard drive is actually constructed, then return to this page and revise parts of your post.
The heads in a hard disk do not move in an independant fashion, and the last thing you would want to do would be to keep related things on one platter, even if you could.
By: Itsme on August 6, 2009
at 18:07
You are, of course, correct. I’ll do something about it in the near future. Thanks.
By: Patrick on August 10, 2009
at 17:52
Altered. Pray I do not alter it further.
By: Patrick on August 11, 2009
at 10:45