Set your computer free

Menu

Partitioning: A Different Perspective with Encryption and RAIDs

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.)

About the Linux Critic

I'm a professional troubleshooter (a.k.a. IT Guy) and I've been using Linux as my main desktop OS for over a decade, at home as well as at work (even though I've worked predominately in Windows shops).

Professionally I work for an IT services company, supporting mostly Windows servers and desktops belonging to our clients and end users.

Personally, I'm a writer, a gamer, and a musician, and I'm also a movie buff. I still love technology though, and I'm always tinkering with computers on my home network.

I'm more technical than the "average user" by quite a ways, but I like to think that there's no reason why Linux and Free/Open Source Software can't find a home on the average user's desktop as a part of their everyday computing life.

I love to play around with technology, and I love to talk about it, so stick around and let me know what you're thinking.

DISCLAIMER: The posts I write and publish on this blog are my own opinions and the opinions of those who contribute to The Linux Critic, and in no way reflect the opinions or official positions of my employer or any of the employers of my contributors.

-- Trent

All content on this blog is copyright (C) Trent Isaacson unless otherwise indicated.