Home | Mail | Resume | Karsten M. Self

Linux Partitioning mini-FAQ



Karsten M. Self (karsten@linuxmafia.com)
Written: Monday, September 18, 2000
Modified: 2008/05/05 13:59:11

NOTE: Some of the information in this page is dated though I've updated it for my latest desktop with 1TB storage as of May, 2008.

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. As always, YMMV.

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. 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 the Filesystem Hierarchy Standard (FHS), part of the debian-policy package, and the the Large Disk HOWTO.

Basic recommendation

    /                   64 - 200+ MB      (Stock kernel modules are 40 MiB +)
    /tmp                50 MB - 2+ GB     (1GB+ for some CDROM/DVD burning SW)
    /var                4+ GB             (1 GiB + for Debian users)
    /usr                4 - 12  GB        (6+ for a generous install)
    /usr/local          1 - 2+  GB        (Really depends on what you put there)
    /home               remainder         (Music/video generally biggest)

Primary, Extended, & Logical partitions (x86 only)

Linux really doesn't care. MS WinXX prefers a single primary partition, though multiple primaries are possible as an undocumented feature. Suit your preferences if you're multi-booting. I tend to create three primary partitions, one extended, and the remainder logical. / usually goes on the first partition and is marked bootable, though as with most things, you have other options. YMMV.

Swap

I go with 3x physical RAM, in two or three separate swap partitions. 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.

For those who question the need for any swap at all, I very strongly recommend kernl 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 utilization 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 only modified during system upgrades. Debian provides options to allow remounting partitions as writable and/or read-only during the upgrade process, see system documentation for more information [Ed: I should be more specific, it's apt related stuff 2001/04/13].

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, 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 60GB 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 Mon May 5 14:11:13 PDT 2008

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.