Unix/Linux Disk Partitioning GuideWritten by pollock@acm.orgBackgroundOne of the most critical decisions when installing Unix or Linux is how to best make use of limited disk space. Even with today's large hard disks, servers with hundreds of gigabytes of pictures, video, sound, database, and other data are common. Multi-user machines may require protection such as read-only partitions, disk quotas, etc.
Note that in this document I often say partition when
technically I mean There are many reasons for partitioning a large hard disk into several smaller partitions. For a home user with a single small-ish disk (today's large disks are tomorrow's small ones), a single Linux partition (plus swap, and maybe one for Windows in a dual-booted system) can be a reasonable choice. But multiple partitions provide additional safety and performance benefits, so I always prefer to create several partitions.
Until around 2008, there was very little to gain by not using a
standard layout.
However modern systems now support many
Standard Unix systems are traditionally limited to 8 Of course just because you can partition a disk doesn't mean you should! The more partitions you create, the more there is to manage. If you guess wrong on the space required, you may have to later grow a partition (not the big deal it used to be). So you shouldn't make extra partitions unless you consider the extra work they create to be worth the additional protections they provide. Here are some reasons to create extra partitions. If you choose not to follow some vendor-recommended standard disk layout, see which of these apply to your situation to decide which partitions to create:
Some reasons not to partition a disk include:
When Things Go Wrong
A problem with having many partitions is that you can run out of
space in one partition while another has excess capacity.
When the partition plan fails you may have to create a new plan,
backup all existing data in archives, re-format the disk, and
restore all the data.
Obviously this should be avoided if at all possible.
(Newer partitioning tools such as a live CD for
# mkdir /var/nifty; ln -s /var/nifty /opt/nifty
The problem with this approach is that too many such symlinks
(sometimes referred to as a symlink farm) can
make maintenance difficult.
Quotas, backups, logging, and monitoring can all be affected.
So adding such symlinks should be considered a Modern Unix systems have virtual partitions called logical volumes or LVM. A logical volume should be thought of the same way traditional partitions and slices are. However, a volume can be composed of one or more physical partitions, possibly on separate drives. When a volume runs out of space, you can just add more disk space to an existing volume to grow it. Then any filesystem in that volume can be grown as well. Although logical volumes may be grown (or shrunk) much more easily than with traditional partitions, using volumes well still requires careful planning of both the logical partitions and the underlying physical partitions. (See about LVM for more information.)
A frequently asked question is how large should the
XYZ partition be?
Unfortunately there is no simple answer.
Consider a partition for Other partitions have similar considerations. You may need no separate partition at all, a very small one, or a huge one. If you have a separate partition for your database files, how much data do you plan to keep on-line? For a web server's files, is this a home user's hobby web server, or a training site with gigabytes of video clips? If you don't have a separate partition to hold crash dumps these end up in the swap partition, so that must be at least as big as your physical RAM. (This is needed to support hibernate too.)
Consider sizing partitions on a mail server.
The critical partition will be the one holding the user's
mail.
This may be stored in mailbox files in If using some sort of LVM, it is usually not difficult to grow and shrink partitions later so there is little reason to worry about getting the size wrong. Still you should be able to make a reasonable estimate on the initial size of your partitions:
A final consideration is that there are modern alternatives to per server disks (or DAS). Using storage technologies such as NAS and SAN may mean your servers have no disks or just a small disk for booting only. Even with these technologies you still need to plan the number and purpose of filesystems. Organizing your storage well depends on available budget, technology, and local expertise.
If you plan to use Solaris The best advice today is to keep the boot disk small and simple, using a standard layout. (But not the default layout for Solaris 10, it is known to not work as of 4/2008 for most disks!) Use other disks (or use a SAN or NAS if possible) for additional filesystems as needed. Keep in mind the max number of partitions possible on a disk for a given OS. If you only have one disk (possibly because you're using hardware RAID), the most flexible disk map will reserve one slice/partition for LVM. Then you can create additional filesystems later as needed without re-formatting the disk.
Tools for partitioning DOS/MBR disks include
Only a few of those tools have been updated to support
EFI/GPT disks.
However you can use If the partition table on a disk gets corrupted (and you don't have a backup) you can use gpart (not [g]parted) to scan a disk and guess the partition map. This be then be written to the MBR to recover the disk.
Choosing number and type of partitions:
16MB for swap (minimum), rest for
One of the most critical decisions when installing Unix or Linux is
how to best make use of limited disk space.
Even with today's large hard disks, servers with hundreds of gigabytes
of pictures, video, sound, database, and other data are common.
Multi-user machines may require protection such as read-only partitions,
disk quotas, etc.
Sizing partitions is not easy, and there are few standard answers.
Make swap at least as large as the physical RAM.
A partitioning scheme (commonly called a partition map, partition plan, or disk layout) for your system must be well documented or it is useless. Later on you will need to refer to this information and it may be difficult to recall details six or twelve months from now.
Your partition map should be neatly typed
and include a description of your disk partitioning map
and the scenario it is based on.
(That is the scenario might be
You must justify the choices you make.
(For example, for a student server: You should summarize your partition map in a short table, something like these examples:
Partitioning Map for 4 GiB hard disk,
|
Part # | Mount Point | Size | Notes |
---|---|---|---|
1 | / (root) |
3 GB | ... |
2 | swap | 256 MB | (assuming 128 MB of RAM) |
3 | /home |
100 MB | ... |
52 | /tmp | 100 MB | ... |
6 | /var |
100 MB | ... |
... | ... | ... | ... |
Part # / LV name |
Mount Point | Size | Notes |
---|---|---|---|
1 | / (root) |
30 GB | ... |
2 | swap | 2 GB | (assuming 2 GB of RAM) |
3 | /boot |
200 MB | ... |
5 | — | 150 GB | Formatted as an LVM physical volume; holds volume group VG1 |
homeLV | /home |
20 GB | Logical volume in VG1 |
tmpLV | /tmp |
10 GB | Logical volume in VG1 |
varLV | /var |
100 GB | Logical volume in VG1 |
optLV | /opt (or /usr/local ) |
20 GB | Logical volume in VG1 |
6 | — | rest of disk | Formatted as an LVM physical volume; holds volume group VG2 |
moviesLV | /movies |
rest of disk | Logical volume in VG2 |
Slice # | Mount Point | Size | Notes |
---|---|---|---|
Primary Solaris Partition | |||
0 | / (root) |
12 GB | ... |
1 | swap | 2 GB | assuming 2 GB of RAM.
Swap normally placed in cylinders on the inside of the disk, as it won't be used much and wasting the best performing area of the disk. If the system is short of RAM, having swap near the outer edge of the disk is better. |
2 | reserved | — | refers to whole partition (for backups) |
3 | unused | — | — |
4 | unused | — | — |
5 | /export |
5 GB | traditional Solaris location for NFS/Samba
shares and user home directories ( /export/home is mounted on
/home viaauto-mounter) |
6 | un-named | 60 GB | SVM pool for softpartitions |
7 | un-named | 32 MB | needed for meta-device DB replicas,
used when (re-)mirroring disks with SVM (OK to reserve this if SVM might ever be used) Each replica needs 4 MB and only 2 or 3 are needed, but wasting 20 MB is okay and some folks recommend this size |
SVM SoftPartitions — grow as needed | |||
— | /var | 4 GB | ... |
— | /var/www (or /www ) |
30 GB | the web site including web content, servlets
and EJBs, databases, ... |
— | /opt | 10 GB | ... |
— | /var/log | 6 GB | only needed if you plan to keep a lot of on-line log data (e.g., weeks to months). Best practice is to leave this as part of root partition (and make that 6 GB larger) |
— | reserved | rest of SVM pool | others as needed later:
/crash-dump, /var/audio-video, /var/mail, /var/spool, /usr/share, ... |
Thanks to Ian Collins, Darren Dunham, and Andrew Gabriel for Solaris partitioning insights.
See also
wikis./display/BigAdmin/BootDiskLayout
and Brief
Notes for Solaris 10 Disk Layout
Part # | Mount Point | Size | Notes |
---|---|---|---|
1 | swap | 2 GB | (assuming 2 GB of RAM) |
2 | / (root) |
4 GB | ... |
3 | /var |
10 GB | ... |
5 | /usr |
10 GB | ... |
6 | /home |
20 GB | ... |
7 | /tmp |
2 GB | Consider RAMfs |
8 | /var/log |
2 GB | ... |
To find out how large the disk is you could look at the label, check the BIOS, or check the system invoice/system description (often obtainable on the Internet using a serial number or service tag number). (In our case, you could also ask a lab tech.)
The version of Fedora Linux we are installing requires over 8 gigabytes,
not counting space you reserve for user home directories,
future additions and updates, log file space, database space, web site,
ftp site, etc.
(Of course, if you don't install everything you can get away with
a minimal system of under 1 GiB.)
To see how much space is required for various directories you could
log into a similar system (such as YborStudent.
)
and use the du
command.
Even Windows systems can benefit from a well thought out partitioning
plan.
Microsoft Best Practice recommends two or more partitions on each
disk.
These include creating a separate swap
partition, that just
holds the pagefile.sys
file, as small as needed (e.g.,
4 GiB), and formatted with FAT32 rather
than NTFS.
/bin/bash
is not static
and in the event of a system problem, if the root shell was bash the
system would be unusable!
This is why the root user's shell on Solaris is
/bin/sh
.
Never change the root user's shell on Solaris or any Unix flavor
unless you know the new shell is static, or unless you know all
needed DLLs are in the root partition.
FDISK) partitions. One of these can hold an extended partition, which in turn can hold many more logical partitions. (There is an OS-imposed limit on the total number of partitions, 15 per disk for Linux.) Note, EFI/GPT disks have virtually unlimited number of partitions, but again there are limits imposed by various operating systems and utilities.
|