附注:please use the first argument of the template to provide more detailed indications.

Partitioning a hard drive allows one to logically divide the available space into sections that can be accessed independently of one another. Partition information is stored within a hard drive's GUID Partition Table or Master Boot Record.

An entire hard drive may be allocated to a single partition, or one may divide the available storage space across multiple partitions. A number of scenarios require creation multiple partitions: dual- or multi-booting, for example, or maintaining a swap partition. In other cases, partitioning is used as a means of logically separating data, such as creating separate partitions for audio and video files. Common partitioning schemes are discussed in detail below.

Users may create up to four primary partitions per hard drive. If additional partitions are required, a single extended partition can be created instead (that is, up to three primary partitions and one extended partition). An extended partition can be further divided into an unlimited number of logical partitions.

/boot

If kept on a separate partition, /boot does not require a journaled file system. A separate /boot partition is needed if installing a software RAID0 (stripe) system.

警告: 除了/boot，启动系统必须的分区为: /bin, /etc, /lib 和 /sbin。和/boot不同，这些目录必须位于/。

/home

The /home directory contains user-specific configuration files (the so-called "dot files"). Optionally, it can also hold any type of media (videos, music, etc), and if you use Wine, the games/programs will be installed in ~/.wine/ by default. So please take this into account if you chose to create a separate home partition.

While keeping it on a separate partition can be useful in case you reinstall, some prefer to start fresh (because that's usually the reason for a reinstall), instead of reusing old, and possibly deprecated or problematic, configuration files. The main advantage is that, in very rare cases, if the root partition becomes too full, it will not impact your web browser, media player, torrent client, etc. They will keep working uninhibited, and will keep saving new changes to their setting files or to their cache.

A home partition can also be shared with other installed Linux distributions, but this is not recommended because of possible incompatibilities between user-specific configuration files. The only exception is if each distribution has its own user dir on the shared home partition.

Swap

The swap partition provides memory that can be used as virtual RAM. It is recommended for PCs with 1GB or less of physical RAM.

Historically, the general rule for swap partition size was to allocate twice the amount of physical RAM. As computers have gained ever larger memory capacities, this rule has become deprecated. On machines with up to 512MB RAM, the 2x rule is usually adequate. If a sufficient amount of RAM (more than 1024MB) is available, it may be possible to have a smaller swap partition or even eliminate it. With more than 2 GB of physical RAM, one can generally expect good performance without a swap partition. There is always an option to create a swap file after the system is setup.

Note: The old rule of matching the swap partition size with the available RAM when using suspend-to-disk no longer applies. The default suspend method uses an image the size of 40% of the currently available RAM by default. Even with TuxOnIce the atomic copy generally only takes about 70% after compression.[2]

/usr

The /usr directory stores file that are shared by all users. A /usr partition can be useful because it can be shared with others Linux OS.

/var

It exists to make it possible to mount/usras read-only. Everything that historically went into/usrthat is written to during system operation (as opposed to installation and software maintenance) must reside under/var.

Note:/var contains many small files. The choice of filesystem type (see below) should consider this fact if a separate partition is used.

/tmp

Directory for programs that require temporary storage of files such as.lck, which can be used to prevent multiple instances of their respective program until a task is completed. Upon completion, the.lckfile will be automatically removed. Programs must not assume that any files or directories in/tmpare preserved between invocations of the program and files and directories located under/tmpwill typically be deleted whenever the system is booted.

Partition Alignment

High-level Overview

Proper partition alignment is essential for optimal performance and longevity. The key to alignment is partitioning to (at least) the EBS (erase block size) of the SSD.

Note: The EBS is largely vendor specific; a Google search on the model of interest would be a good idea! The Intel X25-M for example is thought to have an EBS of 512 KiB, but Intel has yet to publish anything officially to this end.

Note: If one does not know the EBS of one's SSD, use a size of 512 KiB. Those numbers are greater or equal than almost all of the current EBS. Aligning partitions for such an EBS will result in partitions also aligned for all lesser sizes. This is how Windows 7 and Ubuntu "optimize" partitions to work with SSD.

If the partitions are not aligned to begin at multiples of the EBS (512 KiB for example), aligning the file system is a pointless exercise because everything is skewed by the start offset of the partition. Traditionally, hard drives were addressed by indicating the cylinder, the head, and the sector at which data was to be read or written. These represented the radial position, the drive head (= platter and side) and the axial position of the data respectively. With LBA (logical block addressing), this is no longer the case. Instead, the entire hard drive is addressed as one continuous stream of data.

Using GPT - Modern Method

GPT is an alternative, contemporary partitioning style. It is intended to replace the old Master Boot Record (MBR) system. GPT has several advantages over MBR, which has quirks dating back to MS-DOS times. With recent developments to the formatting tools fdisk (MBR) and gdisk (GPT), it is equally easy to use GPT or MBR and get maximum performance.

A special exception to this rule: dual-booting Windows Vista/7 64 bit, and using UEFI instead of BIOS, one must use GPT.

If none of the above apply, choose freely between GPT and MBR. Since GPT is more modern, it is recommended in this case.

Gdisk Usage Summary

The GPT-able tool equivalent to fdisk, gdisk, can perform partition alignment automatically on a 2048 sector (or 1024KiB) block size base which should be compatible with the vast majority of SSDs if not all. GNU parted also supports GPT, but is less user-friendly for aligning partitions. A summary of the typical usage of gdisk:

If the SSD is brand new or if wanting to start over, create a new empty GUID partition table (aka GPT) with the Template:Keypress command.

Create a new partition with the Template:Keypress command (primary type/1st partition).

Assuming the partition is new, gdisk will pick the highest possible alignment. Otherwise, it will pick the largest power of two that divides all partition offsets.

If choosing to start on a sector before the 2048th gdisk will automatically shift the partition start to the 2048th disk sector. This is to ensure a 2048-sectors alignment (as a sector is 512B, this is a 1024KiB alignment which should fit any SSD NAND erase block).

Use the +x{M,G} format to extend the partition x megabytes or gigabytes, if choosing a size that is not a multiple of the alignment size (1024kiB), gdisk will shrink the partition to the nearest inferior multiple.

Select the partition's type id, the default, Linux/Windows data (code 0700), should be fine for most use. Press Template:Keypress to show the codes list.

Warning: If planning to use the GPT partitioned SSD as a boot-disk on a BIOS based system (most systems except Apple computers and some very rare motherboard models with Intel chipset) one may have to create, preferably at the disk's beginning, a 2 MiB partition with no filesystem and with the partition type as BIOS boot or bios_grub partition (gdisk type code EF02) for booting from the disk using GRUB. For Syslinux, one does not need to create a separate 2 MiB bios_grub partition, but one needs to have separate /boot partition and enable Legacy BIOS Bootable partition attribute for that partition (using gdisk). See GPT for more information.

Warning: GRUB legacy does not support GUID partitioning scheme, users must use burg, GRUB or Syslinux.

Warning: If planning to dual boot with Windows (XP, Vista or 7) do NOT use GPT since they do NOT support booting from a GPT disk in BIOS systems! Users need to use the legacy MBR method described below for dual-boot in BIOS systems! This limitation does not apply if booting in UEFI mode and using Windows Vista (64bits) or 7 (64bits). For 32-bit Windows Vista and 7, and 32 and 64-bit Windows XP, users need to use MBR partitioning and boot in BIOS mode only.

Using MBR - Legacy Method

Using MBR, the utility for editing the partition table is called fdisk. Recent versions of fdisk have abandoned the deprecated system of using cylinders as the default display unit, as well as MS-DOS compatibility by default. The latest fdisk automatically aligns all partitions to 2048 sectors, or 1024 KiB, which should work for all EBS sizes that are known to be used by SSD manufacturers. This means that the default settings will give you proper alignment.

Note that in the olden days, fdisk used cylinders as the default display unit, and retained an MS-DOS compatibility quirk that messed with SSD alignment. Therefore one will find many guides around the internet from around 2008-2009 making a big deal out of getting everything correct. With the latest fdisk, things are much simpler, as reflected in this guide.

Fdisk Usage Summary

Start fdisk.

If the SSD is brand new, create a new empty DOS partition table with the Template:Keypress command.

Create a new partition with the Template:Keypress command (primary type/1st partition).

Use the +xG format to extend the partition x gigabytes.

Change the partition's system id from the default type of Linux (type 83) to the desired type via the Template:Keypress command. This is an optional step should the user wish to create another type of partition for example, swap, NTFS, LVM, etc. Note that a complete listing of all valid partition types is available via the Template:Keypress command.

When finished, users may format their newly created partitions with mkfs.x /dev/sdXN where x is the filesystem, X is the drive letter, and N is the partition number.
The following example will format the first partition on the first disk to ext4 using the defaults specified in /etc/mke2fs.conf:

# mkfs.ext4 /dev/sda1

Warning: Using the mkfs command can be dangerous as a simple mistake can result in formatting the WRONG partition and in data loss! TRIPLE check the target of this command before hitting the Enter key!