Home | Mail | Resume | Karsten M. Self

Linux Partitioning mini-FAQ



Karsten M. Self (karsten@linuxmafia.com)
Written: Monday, September 18, 2000
Modified: Tue Dec 28 19:24:30 PST 2010

NOTE: Some of the information in this page is dated though I've updated it for my latest desktop with 1 TiB storage and a 128 SSD laptop as of December, 2010. Server-side experience with various storage configurations including RAID, LVM, NFS, and upwards of 40 TiB storage is also reflected, if dimly ;-)

What's happening is that both disks and distros are getting bigger. While you can run GNU/Linux in as little as 1.7 MiB, a typical generous desktop install now will want about 6-24 GiB just for system files. Filesystem bloat seems to be about 100% every 3-4 years. As always, YMMV.

Getting partitioning right from the get-go is helpful, as modifying partition and filesystem sizes is still fairly painful. Even with partition/filesystem editors, data loss can happen (make backups), and not all filesystems are supported (as of 2010, resizing an ext4 filesystem wasn't). You'll likely have to back-up, delete partitions, repartition, create new filesystems, and restore data -- typically a process requiring much of a day, during which your system isn't usable. If in doubt, keep your system simpler (fewer partitions), and use a more complex configuration once you have experience and understand the costs/benefits.

Finally: it's becoming increasingly popular for both personal and enterprise systems to perform only minimal partitioning: boot, root, swap, and perhaps /tmp or /scratch on a larger box. I'm somewhat old-school and prefer more partitions for reasons of control and redundancy. The downside is managing more partitions and possibly finding yourself squeezed for space. There's no specific need to follow they guidelines here, though you might see some benefits (and costs) from doing so.

The following is my recommended partitioning for a typical workstation/server Debian GNU/Linux x86 box. You can also find useful guidelines the Filesystem Hierarchy Standard (FHS), part of the debian-policy package, and the Large Disk HOWTO.

Note that I'm using the SI binary prefix notation for storage capacity/size, except as given in program output, e.g.: KiB, MiB, GiB, TiB.

Basic recommendation

    /                   64 - 750+ MiB      (Stock kernel modules are ~100 MiB +)
    /tmp                50 MiB - 2+ GiB     (1 GiB+ to 18 GiB for some CDROM/DVD burning SW)
    /var                4+ GiB             (3 GiB + for Debian users)
    /usr                8 - 16  GiB        (10+ for a generous install)
    /usr/local          1 - 2+  GiB        (Really depends on what you put there)
    /home               remainder          (Music/video generally biggest)

As of Debian 5.0, minimum installation disk requirements are about 500 MiB, with 5 GiB recommended for a desktop install. I'd bump that up to 12-16 GiB, and maybe even 20 GiB allowing for ample space to grow your system data usage. Realize that you're likely going to install more software over time, that that software may grow in size, and and that features you're not directly aware of such as internationalization, documentation, kernel modules, OpenOffice.org modules, and other back-office stuff can account for a surprising amount of space.

Why Partition at All?

A question that's frequently asked is what the use of partitioning is in the first place. After all, doesn't partitioning date back to times when a disk of a hundred, or even tens, of mebibytes, was considered large? Yes, somewhat, but there are other reasons:

Among other considerations you might want to take into account are:

Primary, Extended, & Logical partitions (x86 only)

The PC BIOS disk partitioning model is based on 1-4 primary partitions, one of which may be an extended partition, which may then contain additional logical partitions.

Linux really doesn't care where you put your system, with some exceptions.

MS WinXX prefers a single primary partition, though multiple primaries are possible as an undocumented feature. Some boot managers can remap partitions; see your boot manager's documentation if you plan to follow this course. Suit your preferences if you're multi-booting.

I recommend creating three primary partitions, a fourth as an extended partition, and the remainder as logical partitions within the fourth (extended) partition. /boot usually goes on the first partition and is marked bootable, though as with most things, you have other options. Second primary partition is / (root), then swap, then extended. YMMV.

You also have the option of using logical volume management (LVM). This is a means of abstracting out the underlying physical storage from the filesystem on top of it. Both logical volumes and the filesystems on them may be resized (with varying degrees of pain). I find this leads to complexity and doesn't always provide the benefits desired, but strongly recommend the LVM HOWTO for those interested in this approach.

As disk sizes increase, BIOS limitations on older (largely pre-2002) hardware may restrict what can be seen directly. Once booted, a Linux kernel can usually sort things out, but you may need to keep your boot configuration within the first smallish partition of your drive. I generally recommend a smallish /boot partition on the first primary partition for this reason. For specifics, please see the Large Disk HOWTO.

Swap

I generally go with 3x physical RAM, in two or three separate swap partitions. Allocating more swap than you have RAM for now means your swap and RAM will be more equitably matched as you bulk up RAM later. This is more swap than you'll probably want to be using on a typical basis (e.g.: if you're filling all your swap, something's wrong). But if you need it, it provides you a buffer when the system does go into a memory-overrun condition. Typically, things will get so slow that you'll notice something's wrong. The extra swap should buy you time to shut down the offending process(es). Other sources say to provide 2x physical RAM. Putting swap partitions on multiple drives (spindles), particular SATA, PATA, or SCSI drives, will automatically stripe swap for you, for increased performance. Many suspend-to-disk systems will use swap space for the restore image.

Note that a system which is swapping heavily does not suffer from too much swap, but from too little RAM (or poorly written software consuming too much RAM). Having swap means your system does run, slowly, while you address the problem. Not having swap means your programs (and possibly your entire system) crash. There was a historic penalty in overallocating swap due to the need to address the swap itself (in real memory). To the best of my knowledge this no longer applies.

For those who question the need for any swap at all, I very strongly recommend kernel hacker Martin Pool's essay Is swap space obsolete?

How many partitions

First: You only need one. Many systems are configured with just a filesystem + swap partition. Anything other than this affords control and flexibility.

Another religious issue. I start with the scheme illustrated above because:

At this point, you may choose to add additional partitions if desired to match local storage, application, or hardware needs and/or limitations.

Allocation variations

I provide some guidelines to usage patterns and mounting options, as well as whether the partition is typically capable of being served over a network.

Static means that partition contents change little. Variable means they change a lot.

Mount options typically restrict features of the partition, including whether it can support executables, SUID files, and/or device files. While content on "static" partitions can change, it typically doesn't over a normal use cycle, and is modified only during system upgrades. Debian provides options to allow remounting partitions as writable and/or read-only during the upgrade process, see this debian-devel post for more information.

Note that while mount options can restrict settings, it's possible to "remount" a partition in place, and that this doesn't produce system warnings or messages. Think of this as protection against stupid mistakes and low-grade mischief, but not a significant bar to a determined cracker.

Networkable partitions can generally be shared among several systems. The distinction is that certain data, particularly those generating much I/O, or have data pertaining to local hardware and configurations, should be local to the system.

Filesystem Layout

The following are simply my preferences and/or recommendations.

My own current filesystems and utilization

Update, Dec, 2010: /usr has been bumped to 12GB on my primary system, largely a result of growing library, internationalization (i18n), and documentation storage. And I'm runing an all-SSD system, which is really amazing....

Update, May, 2008.

Further updates pending from my new desktop...

(April, 2001): Time changes all things. After a year and a half or so of running the configuration dating from my November, 1999 completion of a Red Hat-to-Debian conversion of the box, space was getting a bit pinched. I spent a day doing some partition rationalization to provide more usable space. Though sizes haven't changed much (mostly a slightly larger /usr, a slightly smaller /usr/local, and a fewer partitions overall, this gives me a bit more breathing room.

My current desktop configuration

The primary changes are:

Utilization

Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/hda3               152247     33526    110859  24% /
/dev/hda6               249871      2004    234967   1% /tmp
/dev/sda7               585008    457456     97836  83% /var
/dev/hda5               495960     87588    382772  19% /var/spool/news
/dev/sdb2              1929100   1518288    312816  83% /usr
/dev/sda5              1209572    574152    573976  51% /usr/local
/dev/hda7               378711    213496    145662  60% /usr/local/data
/dev/hda2              1007992    584132    372656  62% /home
/dev/hda1               157044    119252     37792  76% /mnt/dos

Partitioning

Disk /dev/hda: 128 heads, 63 sectors, 620 cylinders
Units = cylinders of 8064 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1             1        39    157216+   6  FAT16
/dev/hda2            40       293   1024128   83  Linux
/dev/hda3   *       294       332    157248   83  Linux
/dev/hda4           333       620   1161216    5  Extended
/dev/hda5           333       459    512032+  83  Linux
/dev/hda6           460       523    258016+  83  Linux
/dev/hda7           524       620    391072+  83  Linux


Disk /dev/sda: 255 heads, 63 sectors, 261 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sda1             1        17    136521   82  Linux swap
/dev/sda2            18       261   1959930    5  Extended
/dev/sda5            18       170   1228941   83  Linux
/dev/sda6           171       187    136521   82  Linux swap
/dev/sda7           188       261    594373+  83  Linux


Disk /dev/sdb: 255 heads, 63 sectors, 261 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1        17    136521   82  Linux swap
/dev/sdb2            18       261   1959930   83  Linux

/etc/fstab

# /etc/fstab: static file system information.
#
# <file system>   <mount point>     <type>    <options>          <dump>   <pass>
/dev/hda3       /               ext2 defaults,errors=remount-ro         0 1

proc            /proc           proc defaults                           0 0

/dev/hda6       /tmp            ext2 defaults,nosuid,nodev              0 2
/dev/sda7       /var            ext2 defaults,nosuid,nodev              0 2
/dev/hda5       /var/spool/news ext2 defaults,nosuid,noexec,nodev       0 2
/dev/sdb2       /usr            ext2 defaults,rw,nodev                  0 2
/dev/sda5       /usr/local      ext2 defaults,rw,nosuid,nodev           0 2
/dev/hda7       /usr/local/data ext2 defaults,nosuid,nodev              2 2 
/dev/hda2       /home           ext2 defaults,nosuid,nodev              0 2

/dev/hdc        /mnt/cdrom      iso9660 noauto,user,ro,nodev,nosuid     2 2
/dev/fd0        /mnt/floppy     auto noauto,gid=disk,umask=007,rw,user  2 2
/dev/hda1       /mnt/dos    vfat auto,user,nosuid,nodev,gid=6,umask=002 2 2 

/dev/sda1       none            swap    sw          0       0
/dev/sdb1       none            swap    sw          0       0
/dev/sda6       none            swap    sw          0       0

A suggested laptop/desktop configuration

For a Thinkpad T42p with a 60 GiB internal drive, running Debian lenny/sid:

Filesystems are now all ext3fs, though you might keep your /boot filesystem as ext2 -- journaling buys you very little on a small filesystem usually mounted read-only, and the journal file itself eats up considerable space.

Utilization

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda2               242566    188356     41686  82% /
/dev/hda1               121483     32283     82927  29% /boot
/dev/hda5               961824     81420    831544   9% /tmp
/dev/hda6             11534936   9647048   1301940  89% /usr
/dev/hda7              3845088   3325876    323892  92% /var
/dev/hda8               242534     92243    137769  41% /usr/local
/dev/hda9               242534      6176    223836   3% /system2
/dev/hda10            38556920  29833736   6764592  82% /home
      

Partitioning

Disk /dev/hda: 60.0 GB, 60011642880 bytes
16 heads, 63 sectors/track, 116280 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1         249      125464+  83  Linux
/dev/hda2             250         746      250488   83  Linux
/dev/hda3             747        4622     1953504   82  Linux swap / Solaris
/dev/hda4            4623      116280    56275632    5  Extended
/dev/hda5            4623        6561      977224+  83  Linux
/dev/hda6            6562       29813    11718976+  83  Linux
/dev/hda7           29814       37564     3906472+  83  Linux
/dev/hda8           37565       38061      250456+  83  Linux
/dev/hda9           38062       38558      250456+  83  Linux
/dev/hda10          38559      116280    39171856+  83  Linux
      

/etc/fstab

# /etc/fstab: static file system information.
#
# file system    mount point   type    options                  dump pass
/dev/hda2        /             ext3    defaults                 0    1
/dev/hda1        /boot         ext3    ro,nosuid,nodev          0    2

/dev/hda3        none          swap    sw                       0    0
proc             /proc         proc    defaults                 0    0

/dev/fd0         /media/floppy auto    noauto,rw,sync,user,exec 0    0
/dev/cdrom       /media/cdrom  iso9660 noauto,ro,user,exec      0    0

/dev/hda5        /tmp          ext2    rw,nosuid,nodev          0    2
/dev/hda6        /usr          ext3    rw,nodev                 0    2
/dev/hda7        /var          ext3    rw,nosuid,nodev          0    2
/dev/hda8        /usr/local    ext3    rw,nodev                 0    2
/dev/hda9        /system2      ext3    rw,nosuid,nodev          0    2
/dev/hda10       /home         ext3    rw,nosuid,nodev          0    2
      

© 2000-2008 Karsten M. Self (karsten@linuxmafia.com)
Last updated Tue Dec 28 19:24:30 PST 2010 1/p>

Distribution terms: To be determined, but leaning generally toward GNU GPL, the GNU Free Documentation License. Most likely not the Open Publication License. Input welcomed.