One Linux topic on which everybody seems to have an opinion is partitioning. “What’s the best way to partition my system?” newbies ask, and if they do so in a public Linux forum frequented by experienced penguin techies, they are bound to get at least a dozen answers, many of them completely different from each other.
So what is the best way? Simple. Whichever way you find works best for you.
When I first started out with Linux, I didn’t know either, and I did a lot of reading on the subject, and as a result I created a partitioning scheme that works best for me, and that’s still more or less what I stick with.
With my recent Ubuntu installation I didn’t do any manual partitioning, mostly because for one, I wasn’t planning on dual-booting that laptop with anything else, and for another, I wanted to accept the defaults so that I could see what Ubuntu does on its own.
However, when I’m setting up a Slackware machine, I have a method that I follow.
One word of caution. If you’re setting up your partitions presumably to hold a Linux installation, write down what you’re designating what (i.e., “hda1 = Windows”, “hda5 = swap”, “hda7 = root”, et al) so that you have it to refer to when you’re installing later. Nothing quite like coming to the point in the install where it asks you “where do you want to mount your home directory?” and you don’t remember which partition you created with /home in mind.
Been there, done that.
I use cfdisk
Slackware’s default partitioning tool is called cfdisk. If you’re in possession of a Slackware installation CD, and you boot from it, cfdisk is accessible simply by typing “cfdisk” and hitting enter.
This isn’t a graphical partitioning tool, so if you’re interested in that, you may wish to stick to another tool with which you are more familiar. But bear with me… cfdisk is pretty easy to use, so don’t be daunted by its interface. It’s menu-driven, and you can do most of what you need with the arrow keys on your keyboard.
I’m not going to go into the gory details of how to do every minute thing with cfdisk; if you’re reading this, and you’re interested in partitioning schemes, I’m going to go out on a limb and say that I’m safe in assuming that you can probably figure out the basics… it’s not a difficult program to master.
But here’s the way I have a typical dual-boot arrangement set up.
Windows likes to be on the first partition, so (as in my screenshot example), I typically create that partition first. The size of the partition depends largely upon what your needs are… I don’t use the Windows 2000 installation on my desktop machine very much, so I only have around 9.5GB allocated to the partition on which Windows lives. Also, at the time I set up this machine, I had only a single 120GB hard drive in it (it’s an older computer) and space was a bit tight for me.
So I created a 9.5GB partition at the beginning of the drive, selected the filesystem type to be “NTFS” and moved on to the next partition, which, as you can see from the screenshot, is designated “Linux swap”.
The swap arguments
This one gets people up in a tizzy, and I’m really not sure why. As a general rule of thumb, you want your swap partition as close to the beginning of the drive as possible, reason being that it’s going to be faster for read/writes. Face it, if you’re going to be swapping, you want it to be quick, right?
So, as you can see from my screenshot, I followed that rule and created my swap partition right after the Windows partition. The only reason I didn’t create the swap first was because (as I mentioned above), Windows thinks it has to be first, so it has to cut in line in front of everything, even your Linux swap partition.
Well, that’s not the contentious part. The part everyone seems to squawk about is the size of the swap partition.
The rule of thumb for swap partition size is, for desktop systems, you should be allocating twice the space as your system has physical RAM. So if you have 2GB of RAM in your box, make your swap partition 4GB so that you aren’t in danger of crashing if you have a huge pile of memory-intensive apps running.
I don’t do that, as you can tell from my screenshot. I’ve been running Slackware as my main desktop for years, and even though I have only 1GB of RAM in my main desktop right now, I can honestly say that I don’t know what I’d have to be doing in order to crash this box for lack of swap space.
I don’t normally see this machine use ANY swap. Maybe Slackware’s more efficient at handling memory… I really don’t know. But the normal amount of swap space usage is 0Mb, and if I have a TON of stuff running and open and doing lots of things, it might use 15 or 20 Mb, that’s about it. By the rule of thumb, since I have 1GB of physical memory in this computer, I should have made my swap partition 2GB at a minimum, but I see that as just a waste of hard drive space.
One thing I might point out here. If, by whatever means, I happen to be swapping THAT MUCH out of physical memory into disk paging, this box would be running so slowly as to be nigh unusable.
So, your mileage may vary, folks. Follow the rule of thumb if you want to be safe; I’ve never allocated more than 512Mb of space to a Linux swap partition on a desktop or laptop machine, and I’ve never, ever had problems running that way. So the choice is yours.
To read in much more detail on the subject, there’s a great article on Linux.com that discusses what swap is, how it works, and how you should do it, linked here for your convenience: All about Linux swap space.