March 21, 2019

Linux Partitions: A Primer - page 4

Setting Up Your Partitions

  • June 20, 2002
  • By Dee-Ann LeBlanc

You create Linux partitions during the installation process. How many you make depends on quite a number of factors, but I have some general advice that I tend to give anyone that asks me. Let's start with the general ones that all Linux machines must have and work from there.

All Linux boxes need a root partition (/), and a swap partition. Typically speaking, you want the boot partition as close to the start of the drive as possible, so on the lowest cylinder number, which means that if you only used these two partitions you would put root on the drive first—making root /dev/hda1 and swap /dev/hda2. The swap partition, in general, should be either the same size as your machine's memory (RAM), or up to twice that size, depending on who you talk to. Root's size depends on how much room your particular Linux distribution requires.

You can make more than two partitions, and in most cases you should. At the very least, I tend to advise making a boot partition (/boot) as well, and placing that on the drive first. That way, if something in your root partition gets damaged, at the very least you'll be able to boot the machine to try to fix it. Another popular addition is a home partition (/home), so that if you want to completely reinstall the machine you can wipe everything but leave home untouched—though keep in mind that if you do this, you need to create user accounts in the same order as you had the last time or your permissions will be quite messed up in /home.

When you're dealing with servers, there are even more partitions you might want to create. A temporary partition (/tmp) will make sure that temp files can't fill up your filesystem, and also protects the root and boot portions from potential damage since temporary files are changed so often. For the same reason, on a server machine you might want to create a separate /var partition, since that's where your log files, mail, and other such items are kept and constantly changed.

If you're using a network and want to keep certain items on a central machine, then you might create a separate /usr partition on the server and then mount it using NFS onto all of your Linux boxes. You might do the same with /home, so everyone has access to their full home directories no matter what machine they log into.

There's lots more you can do here as well. If you use Samba to access files from Windows, Macintosh, and other machines on your network, then they too will ultimately show up as partitions plugged into your filesystem.

As you can see, Linux deals with drives and partitions quite differently from other non-Unix operating systems. It takes a bit of getting used to, but once you understand the basic concepts life gets a lot easier. The nice thing is that you don't have to remember what drive you have particular types of data on! There's still lots more to learn but this primer should get you started on the basics. From there, look into SMB, NFS, mounting, devices, and more.

Dee-Ann LeBlanc has been writing about computers since 1994, when she did her first computer book. Since then, she's written 10 books, over forty articles, a number of courses, and twelve presentations (which she also presented), with most of these works involving Linux. Her latest book is Linux Routing from New Riders, and you can find out more at http://www.Dee-AnnLeBlanc.com/.

Artwork provided by Bryan Hoff (http://www.themeparkmultimedia.com/)

Most Popular LinuxPlanet Stories