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:
- / needs to be mounted for the system to boot -- but other than /bin, /boot, /dev, /etc, /initrd, /lib, /root, and sbin, other directory trees don't have to be mounted. Increase your chances for a clean boot by reducing the inodes at risk. You are also then able to mount other partitions nosuid and/or noexec and/or read-only, for additional security. The entire partition can be duplicated elsewhere on- or off-line for additional security.
- /tmp -- highly variable. Don't risk your root partition, isolate this content. Mount noexec and/or nosuid for added protection.
- /var -- likewise, highly variable. Mount noexec and/or nosuid for added protection.
- /usr -- Largely stable. Can be mounted read-only except for package upgrades.
- /usr/local -- Largely stable, and not part of the packaging system. Can be mounted read-only, possibly nosuid.
- /home -- Variable content, usually most sensitive data both in terms of security and integrity. Can be mounted nosuid.
- A rescue partition -- A secondary boot partition sized 50-200+ MiB, containing a set of tools to use for recovering a system. In the event you hose your primary installation. Useful also for certain sorts of maintenance (filesystem conversions). Noramlly unmounted.
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.
- /: A minimal installation can fit in 30 MB or less. If you're using more than ~250 MB, you've probably included something in your root partition you don't strictly need. Root filesystem requirements have been increasing dramatically in recent years for those using their distribution's stock kernel, as a typical set of kernel modules (2.6 kernel) exceeds 50 MiB and will undoubtedly grow further. Largely static (though it should be writable), executable, suid, local.
- /tmp: Values suggested should work for most systems. /tmp is system temporary storage. If you've got specific applications with very large temporary storage requirements (e.g.: database, analytic tools, multimedia), you're better off allocating storage to these needs specifically. PCMCIA users note that most PCMCIA utilities expect to find /tmp to allow creation of device files. I've hacked my /etc/init.d/pcmcia file to provide for this by temporarily remounting the partition. Some software (data analysis, CD/DVD authoring, video) requires large amounts of temporary storage, from 750 MiB to several GiB. Size accordingly. Variable, non-executable, non-suid, nodev, local.
- /var: if you're running extensive services (news, mail, website), you may want to increase this allotment significantly. Often various /var/spool subdirectories become their own partitions. Such partitions may consume hundreds of MBs to multiple GBs. Some services (mail, news) benefit by specific mount options and/or filesystem tuning, notably noatime, and large inode counts (to allow for many files). Highly variable, non-executable (?), non-suid, nodev, local.
- /usr: A minimal installation can fit in a few hundred MB or less. Likewise, if you have to install all packages and docs, you may find 3GB is too thin, consider doubling the allocation. Tune to your needs. Static, executable, suid, nodev, networkable.
- /usr/local: This is where software installed directly by you, outside of the Debian packaging system, goes. Tarballs, binary non-deb installations, and locally built software. Again, if you're installing lots of stuff or very large packages, you could easily utilize several GB of space. Many modern distros provide pretty much any software you could want (installed under /usr), so this partition may be pretty sparsely used. Static, executable, non-suid (?), networkable.
- /home: User directories, sometimes also where services such as websites, ftp sites, and databases are parked. On workstations and shared, directly-accessed systems, usually the largest single (or aggregate) storage area. In special-purpose or embedded systems may be little more than a vestige directory on the root filesystem. Variable, non-suid, nodev, networkable.
- /usr/src, /usr/local/src: depending on space constraints and variability, you may want to create these as separate partitions. Variable, non-executable, non-suid, nodev, networkable.
- OtherOS: If you have a multi-boot system, you'll want to allocate space for other OSs as appropriate. Tools such as VMWare or Xen, and Samba may allow you to both run and access these partitions natively from within Linux.
- Sub-partitioning: I've run in the past a set of (now) very small drives -- 2/2.4 GB each. As a result I've split out several subdirectories of /usr and parked them on other partitions. While this is possible, it's probably generally best not to subdivide your filesystems overly much -- it does increase system complexity and management. Unless this is required by space constraints, I'd suggest not doing it. But if you need the option, it's there.
- Large filesystems: With single-disk sizes in excess of
300 GB available now or in the near future, more generous
partitioning schemes are possible. My suggestion is to generally
follow the guidelines suggested above. Even a "kitchen sink"
installation is unlikely to require more than 6-10 GB storage for
/usr. A /usr/local partition might call for a
larger allocation, particularly if large third-party applications
are being installed. I would apply most of the discretionary
storage as suits system needs. For example:
- /home for a personal workstation.
- File storage for a fileserver.
- Mail, Usenet, or print spools for heavily taxed servers of respective function.
- Database and/or website storage for a large database or web server.
Filesystem Layout
The following are simply my preferences and/or recommendations.
- /opt -> /usr/local I recommend creating /opt as a symlink to /usr/local as this rationalizes space and conforms to typical third-party application preferences. Some applications like to go under /usr/local, others under /opt. This link supports both transparently.
- /net This is a mount point for networked drives. Any SMB, NFS, or other partitions show up here.
- /mount Now required by FHS, the starting mount point for removable media and temporary mount points. Usually contains /mount/floppy, /mnt/cdrom, etc. Keeps your / partition cleaner and makes system backups a bit more rational.
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:
- Elimination of /usr/doc and /usr/src, split-out partitions I'd created on account of an overflowing /usr partition.
- Increased size of /usr from 1.2GB to 1.9GB.
- Decreased size of /usr/local from 1.5 GB to 1.2 GB. Elimination of some data stored there made this possible.
- Increased size of /var from ~300 MB to ~580 MB.
- Increased size of /tmp from 100 MB to 250 MB.
- /mnt/misc1 became /usr/local/data, and shrank from 1 GB to 375 MB. This is largely used as a /home overflow via symlinks.
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.