Difference between revisions of "Partitioning"

From ArchWiki
Jump to: navigation, search
m (Gdisk Usage Summary: rm red link)
(Undo revision 457996 by Althathwe (talk) yes it does)
 
(256 intermediate revisions by 49 users not shown)
Line 1: Line 1:
 
[[Category:File systems]]
 
[[Category:File systems]]
 +
[[Category:Boot process]]
 +
[[Category:System recovery]]
 +
[[ar:Partitioning]]
 
[[es:Partitioning]]
 
[[es:Partitioning]]
 +
[[fa:پارتیشن بندی]]
 +
[[hu:Partitioning]]
 
[[it:Partitioning]]
 
[[it:Partitioning]]
[[ja:Partitioning]]
+
[[ja:パーティショニング]]
 +
[[pl:Partitioning]]
 
[[ru:Partitioning]]
 
[[ru:Partitioning]]
[[zh-cn:Partitioning]]
+
[[zh-CN:Partitioning]]
{{Article summary start}}
+
{{Related articles start}}
{{Article summary text|An overview of disk partitioning tools, best practices, and additional considerations.}}
+
{{Related|File systems}}
{{Article summary heading|Related}}
+
{{Related|fdisk}}
{{Article summary wiki|fstab}}
+
{{Related|parted}}
{{Article summary wiki|LVM}}
+
{{Related|fstab}}
{{Article summary wiki|Swap}}
+
{{Related|LVM}}
{{Article summary wiki|Format a device}}
+
{{Related|Swap}}
{{Article summary wiki|File Systems}}
+
{{Related|Arch boot process}}
{{Article summary end}}
+
{{Related|Unified Extensible Firmware Interface}}
''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]].
+
{{Related articles end}}
 +
[[w:Disk partitioning|Partitioning]] a hard drive divides the available space into sections that can be accessed independently. An entire drive may be allocated to a single partition, or multiple ones for cases such as dual-booting, maintaining a [[swap]] partition, or to logically separate data such as audio and video files.
  
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.  
+
The required information is stored in a [[#Partition table]] scheme such as MBR or GPT.
  
Each partition should be formatted to a [[File Systems|file system type]] before being used.
+
Partition tables are created and modified using one of many [[#Partitioning tools]] which must be compatible to the chosen scheme of partitioning table. Available tools include [[fdisk]] and [[parted]].
  
== Partition type ==
+
Once created, a partition must be formatted with an appropriate [[file system]] (''swap'' excepted) before data can be written to it.
  
Partitioning a hard disk drive defines specific memory storage areas. These are called partitions. Each partition behaves as a separate disk and is formatted with a specific filesystem type (see below).
+
== Partition table ==
  
=== On MBR ===
+
{{Note|To print/list existing tables (of a specific device), run {{ic|parted ''/dev/sda'' print}} or {{ic|fdisk -l ''/dev/sda''}}, where {{ic|''/dev/sda''}} is a device name.}}
  
There are 3 types of disk partitions:
+
There are two main types of partition table available: Master Boot Record (MBR), and GUID Partition Table (GPT). These are described below along with a discussion on how to choose between the two. A third, less common alternative is using a partitionless disk, which is also discussed.
 +
 
 +
=== Master Boot Record ===
 +
 
 +
The [[Wikipedia:Master boot record|Master Boot Record]] (MBR) is the first 512 bytes of a storage device. It contains an operating system bootloader and the storage device's partition table. It plays an important role in the [[boot process]] under [[wikipedia:BIOS|BIOS]] systems. See [[Wikipedia:Master boot record#Disk partitioning]] for the MBR structure.
 +
 
 +
{{Note|The MBR is not located in a partition; it is located at the first sector of the device (physical offset 0), preceding the first partition. (The boot sector present on a partitionless device or within an individual partition is called a [[w:Volume boot record|Volume boot record]] instead.)}}
 +
 
 +
==== Master Boot Record (partition table) ====
 +
 
 +
There are 3 types of partitions in the MBR scheme:
  
 
* Primary
 
* Primary
Line 32: Line 49:
 
** Logical
 
** Logical
  
'''Primary''' partitions can be bootable and are limited to four partitions per disk or RAID volume. If a partitioning scheme requires more than four partitions, an '''extended''' partition containing '''logical''' partitions is used. Extended partitions can be thought of as containers for logical partitions. A hard disk can contain no more than one extended partition. The extended partition is also counted as a primary partition so if the disk has an extended partition, only three additional primary partitions are possible (i.e. three primary partitions and one extended partition). The number of logical partitions residing in an extended partition is unlimited. A system that dual boots with Windows will require that Windows reside in a primary partition.
+
'''Primary''' partitions can be bootable and are limited to four partitions per disk or RAID volume. If the MBR partition table requires more than four partitions, then one of the primary partitions needs to be replaced by an '''extended''' partition containing '''logical''' partitions within it.  
 +
 
 +
Extended partitions can be thought of as containers for logical partitions. A hard disk can contain no more than one extended partition. The extended partition is also counted as a primary partition so if the disk has an extended partition, only three additional primary partitions are possible (i.e. three primary partitions and one extended partition). The number of logical partitions residing in an extended partition is unlimited. A system that dual boots with Windows will require for Windows to reside in a primary partition.
 +
 
 +
The customary numbering scheme is to create primary partitions ''sda1'' through ''sda3'' followed by an extended partition ''sda4''. The logical partitions on ''sda4'' are numbered ''sda5'', ''sda6'', etc.
 +
 
 +
==== Master Boot Record (bootstrap code) ====
 +
 
 +
The first 446 bytes of MBR are '''bootstrap code area'''. On BIOS systems it usually contains the first stage of the boot loader.
 +
 
 +
=== GUID Partition Table ===
 +
 
 +
[[Wikipedia:GUID Partition Table|GUID Partition Table]] (GPT) is a partitioning scheme that is part of the [[Unified Extensible Firmware Interface]] specification; it uses [[Wikipedia:Globally unique identifier|globally unique identifiers]] (GUIDs), or UUIDs in linux world, to define partitions and [[Wikipedia:GUID Partition Table#Partition type GUIDs|partition types]]. It is designed to succeed the [[#Master Boot Record]] partitioning scheme method.
 +
 
 +
=== Choosing between GPT and MBR ===
 +
 
 +
GUID Partition Table (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 the recent developments to the formatting tools ''fdisk'' (MBR) and ''gdisk'' (GPT), it is equally easy to get good dependability and performance for GPT or MBR.
 +
 
 +
Some points to consider when choosing:
 +
 
 +
* To dual-boot with Windows (both 32-bit and 64-bit) using Legacy BIOS, the MBR scheme is required.
 +
* To dual-boot Windows 64-bit using [[UEFI]] mode instead of BIOS, the GPT scheme is required.
 +
* If you are installing on older hardware, especially on old laptops, consider choosing MBR because its BIOS might not support GPT.
 +
* If you are partitioning a disk of 2 TiB or larger, you need to use GPT.
 +
* It is recommended to always use GPT for [[UEFI]] boot, as some UEFI implementations do not support booting to the MBR while in UEFI mode.
 +
* If none of the above apply, choose freely between GPT and MBR. Since GPT is more modern, it is recommended in this case.
 +
 
 +
Some advantages of GPT over MBR are:
 +
 
 +
* Provides a unique disk GUID and unique [[Persistent block device naming#by-partuuid|partition GUID]] ({{ic|PARTUUID}}) for each partition - A good filesystem-independent way of referencing partitions and disks.
 +
* Provides a filesystem-independent [[Persistent block device naming#by-partlabel|partition name]] ({{ic|PARTLABEL}}).
 +
* Arbitrary number of partitions - depends on space allocated for the partition table - No need for extended and logical partitions. By default the GPT table contains space for defining 128 partitions. However if you want to define more partitions, you can allocate more space to the partition table (currently only ''gdisk'' is known to support this feature).
 +
* Uses 64-bit LBA for storing Sector numbers - maximum addressable disk size is 2 ZiB. MBR is limited to addressing 2 TiB of space per drive.
 +
* Stores a backup header and partition table at the end of the disk that aids in [[fdisk#Recover GPT header|recovery]] in case the primary ones are damaged.
 +
* CRC32 checksums to detect errors and corruption of the header and partition table.
 +
 
 +
{{Note|For GRUB to boot from a GPT-partitioned disk on a BIOS-based system, a [[GRUB#GUID_Partition_Table_.28GPT.29_specific_instructions|BIOS boot partition]] is required. Please note that this partition is unrelated to the {{ic|/boot}} mountpoint, and will be used by GRUB directly. Do not create a filesystem on it, and do not mount it.}}
 +
 
 +
The section on [[#Partitioning tools]] contains a table indicating which tools are available for creating and modifying GPT and MBR tables.
 +
 
 +
=== Partitionless disk ===
  
The customary numbering scheme is to create primary partitions {{ic|sda1}} through {{ic|sda3}} followed by an extended partition {{ic|sda4}}. The logical partitions on {{ic|sda4}} are numbered {{ic|sda5}}, {{ic|sda6}}, etc.
+
Partitionless disk (a.k.a. superfloppy) refers to using a storage device without using a partition table, having one file system occupying the whole storage device.
  
=== On GPT ===
+
==== Btrfs partitioning ====
  
There is only one type of partition, '''Primary'''. The amount of partitions per disk or RAID volume is unlimited.
+
[[Btrfs]] can occupy an entire data storage device and replace the [[#Master Boot Record|MBR]] or [[#GUID Partition Table|GPT]] partitioning schemes. See the [[Btrfs#Partitionless Btrfs disk]] instructions for details.
  
 
== Partition scheme ==
 
== Partition scheme ==
  
There are no strict rules for partitioning a hard drive, although one may follow the general guidance given below. A disk partitioning scheme is determined by various issues such as desired flexibility, speed, security, as well as the limitations imposed by available disk space. It is essentially personal preference. If you would like to dual boot Arch Linux and a Windows operating system please see [[Windows and Arch Dual Boot]].
+
There are no strict rules for partitioning a hard drive, although one may follow the general guidance given below. A disk partitioning scheme is determined by various issues such as desired flexibility, speed, security, as well as the limitations imposed by available disk space. It is essentially personal preference. If you would like to dual boot Arch Linux and a Windows operating system please see [[Dual boot with Windows]].
 +
 
 +
{{Note|
 +
* [[UEFI]] systems require an [[EFI System Partition]].
 +
* BIOS systems that are partitioned with [[#GUID Partition Table|GPT]] require a [[GRUB#GUID Partition Table (GPT) specific instructions|BIOS boot partition]] if [[GRUB]] is used as the bootloader.
 +
* If using [[Btrfs]], subvolumes can be treated as partitions. See the [[Btrfs#Mounting subvolumes]] section.
 +
}}
  
 
=== Single root partition ===
 
=== Single root partition ===
  
This scheme is the simplest and should be enough for most use cases. A [[swapfile]] can be created and easily resized as needed. It usually makes sense to start by considering a single / partition and then separate out others based on specific use cases like raid, encryption, a shared media partition, etc.
+
This scheme is the simplest and should be enough for most use cases. A [[swapfile]] can be created and easily resized as needed. It usually makes sense to start by considering a single {{ic|/}} partition and then separate out others based on specific use cases like RAID, encryption, a shared media partition, etc.
  
 
=== Discrete partitions ===
 
=== Discrete partitions ===
Line 52: Line 115:
 
Separating out a path as a partition allows for the choice of a different filesystem and mount options. In some cases like a media partition, they can also be shared between operating systems.
 
Separating out a path as a partition allows for the choice of a different filesystem and mount options. In some cases like a media partition, they can also be shared between operating systems.
  
=== Mount points ===
+
Below are some example layouts that can be used when partitioning, and the following subsections detail a few of the directories which can be placed on their own separate partition and then [[mount]]ed at mount points under {{ic|/}}. See {{man|7|file-hierarchy}} for a full description of the contents of these directories.
  
The following mount points are possible choices for separate partitions, you can make your decision based on actual needs.
+
==== / ====
  
==== Root partition ====
+
The root directory is the top of the hierarchy, the point where the primary filesystem is mounted and from which all other filesystems stem. All files and directories appear under the root directory {{ic|/}}, even if they are stored on different physical devices. The contents of the root filesystem must be adequate to boot, restore, recover, and/or repair the system. Therefore, certain directories under {{ic|/}} are not candidates for separate partitions.
  
The root directory is the top of the hierarchy, the point where the primary filesystem is mounted and from which all other filesystems stem. All files and directories appear under the root directory '''/''', even if they are stored on different physical devices. The contents of the root filesystem must be adequate to boot, restore, recover, and/or repair the system. Therefore, certain directories under '''/'''are not candidates for separate partitions.  
+
The {{ic|/}} partition or root partition is necessary and it is the most important. The other partitions can be replaced by it.
  
The '''/''' partition or root partition is necessary and it is the most important. The other partitions can be replaced by it.
+
{{Warning|Directories essential for booting (except for {{ic|/boot}}) '''must''' be on the same partition as {{ic|/}} or mounted in early userspace by the [[initramfs]]. These essential directories are: {{ic|/etc}} and {{ic|/usr}} [http://freedesktop.org/wiki/Software/systemd/separate-usr-is-broken].}}
  
{{Warning|Directories essential for booting (not '''/boot''') '''must''' be on the same partition as ''' /''' or mounted in early userspace by the [[initramfs]]. These essential directories are: '''/bin''', '''/etc''', '''/lib''', '''/sbin''' and '''/usr''' [http://freedesktop.org/wiki/Software/systemd/separate-usr-is-broken].}}
+
{{ic|/}} traditionally contains the {{ic|/usr}} directory, which can grow significantly depending upon how much software is installed. 15–20 GB should be sufficient for most users with modern hard disks. If you plan to store a swap file here, you might need a larger partition size.
  
 
==== /boot ====
 
==== /boot ====
  
The '''/boot''' directory contains the kernel and ramdisk images as well as the bootloader configuration file and bootloader stages. It also stores data that is used before the kernel begins executing user-space programs. '''/boot''' is not required for normal system operation, but only during boot and kernel upgrades (when regenerating the initial ramdisk).
+
The {{ic|/boot}} directory contains the kernel and ramdisk images as well as the bootloader configuration file and bootloader stages. It also stores data that is used before the kernel begins executing user-space programs. {{ic|/boot}} is not required for normal system operation, but only during boot and kernel upgrades (when regenerating the initial ramdisk).
  
A separate '''/boot''' partition is needed if installing a software RAID0 (stripe) system.
+
A separate {{ic|/boot}} partition is needed if installing a software RAID0 (stripe) system.
 +
 
 +
{{Note|It is recommended to mount [[ESP]] to {{ic|/boot}} if booting using UEFI boot loaders that do not contain drivers for other filesystems. Such loaders are for example [[EFISTUB]] and [[systemd-boot]].}}
 +
 
 +
A suggested size for {{ic|/boot}} is 200 MiB unless using [[UEFI]], in which case greater than 512 MiB is needed.
  
 
==== /home ====
 
==== /home ====
  
The '''/home''' directory contains user-specific configuration files, caches, application data and media files.
+
The {{ic|/home}} directory contains user-specific configuration files, caches, application data and media files.
  
Separating out '''/home''' allows '''/''' to be re-partitioned separately, but note that you can still reinstall Arch with '''/home''' untouched even if it isn't separate - the other top-level directories just need to be removed, and then pacstrap can be run.
+
Separating out {{ic|/home}} allows {{ic|/}} to be re-partitioned separately, but note that you can still reinstall Arch with {{ic|/home}} untouched even if it is not separate—the other top-level directories just need to be removed, and then pacstrap can be run.
  
You should not share home directories between users on different distributions, because they use incompatible software versions and patches. Instead, consider sharing a media partition or at least using different home directories on the same '''/home''' partition.
+
You should not share home directories between users on different distributions, because they use incompatible software versions and patches. Instead, consider sharing a media partition or at least using different home directories on the same {{ic|/home}} partition. The size of this partition varies.
  
 
==== /var ====
 
==== /var ====
  
The '''/var''' directory stores variable data such as spool directories and files, administrative and logging data, [[pacman]]'s cache, the [[Arch Build System|ABS]] tree, etc. It is used, for example, for caching and logging, and hence frequently read or written. Keeping it in a separate partition avoids running out of disk space due to flunky logs, etc.  
+
The {{ic|/var}} directory stores variable data such as spool directories and files, administrative and logging data, [[pacman]]'s cache, the [[ABS]] tree, etc. It is used, for example, for caching and logging, and hence frequently read or written. Keeping it in a separate partition avoids running out of disk space due to flunky logs, etc.
  
It exists to make it possible to mount '''/usr'''as read-only. Everything that historically went into '''/usr''' that is written to during system operation (as opposed to installation and software maintenance) must reside under '''/var'''.
+
It exists to make it possible to mount {{ic|/usr}} as read-only. Everything that historically went into {{ic|/usr}} that is written to during system operation (as opposed to installation and software maintenance) must reside under {{ic|/var}}.
  
{{Note|'''/var''' contains many small files. The choice of file system type should consider this fact if a separate partition is used.}}
+
{{Note|{{ic|/var}} contains many small files. The choice of file system type should consider this fact if a separate partition is used.}}
 +
 
 +
{{ic|/var}} will contain, among other data, the [[ABS]] tree and the [[pacman]] cache. Retaining these packages is helpful in case a package upgrade causes instability, requiring a [[downgrade]] to an older, archived package. The pacman cache in particular will grow as the system is expanded and updated, but it can be safely cleared if space becomes an issue. 8–12 GB on a desktop system should be sufficient for {{ic|/var}}, depending on how much software will be installed.
 +
 
 +
==== /data ====
 +
 
 +
One can consider mounting a "data" partition to cover various files to be shared by all users. Using the {{ic|/home}} partition for this purpose is fine as well. The size of this partition varies.
  
 
==== /tmp ====
 
==== /tmp ====
  
This is already a separate partition by default, by virtue of being mounted as '''tmpfs''' by systemd.
+
This is already a separate partition by default, by virtue of being mounted as ''tmpfs'' by systemd; therefore, there is no need to create a partition for it.
  
 
==== Swap ====
 
==== Swap ====
  
A [[swap]] partition provides memory that can be used as virtual RAM. A [[swapfile]] should be considered too, as they have almost no performance overhead compared to a partition but are much easier to resize as needed. A swap partition can ''potentially'' be shared between operating systems, but not if hibernation is used.
+
A [[swap]] partition provides memory that can be used as virtual RAM. A [[swap file]] should be considered too, as they don't have any performance overhead compared to a partition but are much easier to resize as needed. A swap partition can ''potentially'' be shared between operating systems, but not if hibernation is used.
  
{{Note|The old rule of matching the swap partition size with the available RAM when using [[Suspend_to_Disk|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.[http://tuxonice.net/features]}}
+
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 is outdated. For example, on average desktop 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. See [[Suspend and hibernate]] to hibernate into a swap partition or file.
  
==== How big should my partitions be? ====
+
=== Example layouts ===
  
{{Note|The below are simply recommendations; there is no hard rule dictating partition size.}}
+
==== UEFI/GPT example layout ====
The size of the partitions depends on personal preference, but the following information may be helpful:
+
{| class="wikitable"
 +
! Mount point
 +
! Partition
 +
! [[w:GUID_Partition_Table#Partition_type_GUIDs|Partition type (GUID)]]
 +
! Bootable flag
 +
! Suggested size
 +
|-
 +
| /boot
 +
| /dev/sd'''x'''1
 +
| [[EFI System Partition]]
 +
| Yes
 +
| 260–512 MiB
 +
|-
 +
| [SWAP]
 +
| /dev/sd'''x'''2
 +
| Linux [[swap]]
 +
| No
 +
| More than 512 MiB
 +
|-
 +
| /
 +
| /dev/sd'''x'''3
 +
| Linux
 +
| No
 +
| Remainder of the device
 +
|}
  
; '''/boot''' - 200 MB : A '''/boot''' partition requires only about 100 MB, but if multiple kernels/boot images are likely to be in use, 200 or 300 MB is a better choice.
+
==== MBR/BIOS example layout ====
; '''/''' - 15-20 GB : The root filesystem ('''/''') traditionally contains the '''/usr''' directory, which can grow significantly depending upon how much software is installed. 15-20 GB should be sufficient for most users with modern hard disks.
+
; '''/var''' - 8-12 GB : The '''/var''' filesystem will contain, among other data, the [[Arch Build System|ABS]] tree and the [[pacman]] cache. Keeping cached packages is useful and versatile as it provides the ability to downgrade. As a result, '''/var''' tends to grow in size. The pacman cache in particular will grow as the system is expanded and updated. It can, however, be safely cleared if space becomes an issue. 8-12 GB on a desktop system should be sufficient for '''/var''', depending on how much software will be installed.
+
; '''/home''' - [varies] : The '''/home''' filesystem is typically where user data, downloads, and multimedia reside. On a desktop system, '''/home''' is typically the largest filesystem on the drive by a large margin.
+
; '''swap''' - [varies] : 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.
+
; '''/data''' - [varies] : One can consider mounting a "data" partition to cover various files to be shared by all users.  Using the /home partition for this purpose is fine as well.
+
  
{{Note|If available, an extra 25% of space added to each filesystem will provide a cushion for future expansion and help protect against fragmentation.}}
+
{| class="wikitable"
 +
! Mount point
 +
! Partition
 +
! [[w:Partition type|Partition type]]
 +
! Bootable flag
 +
! Suggested size
 +
|-
 +
| [SWAP]
 +
| /dev/sd'''x'''1
 +
| Linux [[swap]]
 +
| No
 +
| More than 512 MiB
 +
|-
 +
| /
 +
| /dev/sd'''x'''2
 +
| Linux
 +
| Yes
 +
| Remainder of the device
 +
|}
 +
 
 +
==== UEFI separate /home example layout ====
 +
 
 +
{| class="wikitable"
 +
! Mount point
 +
! Partition
 +
! [[w:GUID_Partition_Table#Partition_type_GUIDs|Partition type (GUID)]]
 +
! Bootable flag
 +
! Suggested size
 +
|-
 +
| /boot
 +
| /dev/sd'''x'''1
 +
| [[EFI System Partition]]
 +
| Yes
 +
| More than 512 MiB
 +
|-
 +
| /
 +
| /dev/sd'''x'''2
 +
| Linux
 +
| No
 +
| 15 - 20 GiB
 +
|-
 +
| [SWAP]
 +
| /dev/sd'''x'''3
 +
| Linux [[swap]]
 +
| No
 +
| More than 512 MiB
 +
|-
 +
| /home
 +
| /dev/sd'''x'''4
 +
| Linux
 +
| No
 +
| Remainder of the device
 +
|}
  
 
== Partitioning tools ==
 
== Partitioning tools ==
  
*{{App|fdisk|Terminal partitioning tools included in Linux.|https://www.kernel.org/|{{Pkg|util-linux}}}}
+
The following programs are used to create and/or manipulate device partition tables and partitions. See the linked articles for the exact commands to be used.
*{{App|cfdisk|Terminal partitioning tool written with ncurses libraries.|https://www.kernel.org/|{{Pkg|util-linux}}}}
+
 
{{Warning|The first partition created by ''cfdisk'' starts at sector 63, instead of the usual 2048. This can lead to reduced performance on SSD and advanced format (4k sector) drives. It will cause problems with [[GRUB2#msdos-style error message|GRUB2]]. GRUB legacy and Syslinux should work fine.}}
+
This table will help you to choose utility for your needs:
*{{App|gdisk|[[GPT]] version of fdisk.|http://www.rodsbooks.com/gdisk/|{{Pkg|gptfdisk}}}}
+
 
*{{App|cgdisk|GPT version of cfdisk.|http://www.rodsbooks.com/gdisk/|{{Pkg|gptfdisk}}}}
+
{| class="wikitable"
*{{App|GNU Parted|Terminal partitioning tool.|http://www.gnu.org/software/parted/parted.html|{{pkg|parted}}}}
+
!
 +
! MBR
 +
! GPT
 +
|-
 +
! Dialog
 +
| fdisk <br> parted
 +
| fdisk <br> gdisk <br> parted
 +
|-
 +
! Pseudo-graphics
 +
| cfdisk
 +
| cfdisk <br> cgdisk
 +
|-
 +
! Non-interactive
 +
| sfdisk <br> parted
 +
| sfdisk <br> sgdisk <br> parted
 +
|-
 +
! Graphical
 +
| GParted <br> partitionmanager
 +
| GParted <br> partitionmanager
 +
|}
 +
 
 +
{{Warning|To partition devices, use a partitioning tool compatible to the chosen type of partition table. Incompatible tools may result in the destruction of that table, along with existing partitions or data.}}
 +
 
 +
=== fdisk/gdisk ===
 +
 
 +
These group of tools fall under ''fdisk'' or ''gdisk'' and are described in the [[fdisk]] article.
 +
 
 +
*{{App|[[fdisk]]|Dialog-driven program for creation and manipulation of partition tables.|https://www.kernel.org/pub/linux/utils/util-linux/|{{Pkg|util-linux}}}}
 +
*{{App|[[cfdisk]]|Curses-based variant of fdisk.|https://www.kernel.org/pub/linux/utils/util-linux/|{{Pkg|util-linux}}}}
 +
*{{App|[[sfdisk]]|Scriptable variant of fdisk.|https://www.kernel.org/pub/linux/utils/util-linux/|{{Pkg|util-linux}}}}
 +
*{{App|[[gdisk]]|[[#GUID Partition Table|GPT]] alternative to fdisk.|http://www.rodsbooks.com/gdisk/|{{Pkg|gptfdisk}}}}
 +
*{{App|[[cgdisk]]|Curses-based variant of gdisk.|http://www.rodsbooks.com/gdisk/|{{Pkg|gptfdisk}}}}
 +
*{{App|[[sgdisk]]|Scriptable variant of gdisk.|http://www.rodsbooks.com/gdisk/sgdisk-walkthrough.html|{{Pkg|gptfdisk}}}}
 +
 
 +
=== GNU Parted ===
 +
 
 +
These group of tools are described in the [[GNU Parted]] article.
 +
 
 +
*{{App|[[GNU Parted]]|Terminal partitioning tool.|https://www.gnu.org/software/parted/parted.html|{{pkg|parted}}}}
 
*{{App|[[GParted]]|Graphical tool written in GTK.|http://gparted.sourceforge.net/|{{Pkg|gparted}}}}
 
*{{App|[[GParted]]|Graphical tool written in GTK.|http://gparted.sourceforge.net/|{{Pkg|gparted}}}}
*{{App|Partitionmanager|Graphical tool written in QT.|http://sourceforge.net/projects/partitionman/|{{AUR|partitionmanager}}}}
 
*{{App|QtParted|Similar to Partitionmanager, available in [[AUR]].|http://qtparted.sourceforge.net/|{{AUR|qtparted}}}}
 
  
== Partition Alignment ==
+
=== partitionmanager ===
  
=== High-level overview ===
+
*{{App|Partitionmanager|Graphical tool written in Qt.|http://sourceforge.net/projects/partitionman/|{{Pkg|partitionmanager}}}}
  
'''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.
+
== Partition alignment ==
  
{{Note|
+
{{Deletion|Gets a little technical to just say that fdisk/parted handle it automatically.}}
* 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.
+
* 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.
+
Proper partition alignment is essential for optimal performance and longevity. This is due to the [[wikipedia:Block (data storage)|block]] nature of every I/O operation on the hardware level as well as file system level. The key to alignment is partitioning to (at least) the given ''block size'', which depends on the used hardware. If the partitions are not aligned to begin at multiples of the ''block size'', aligning the file system is a pointless exercise because everything is skewed by the start offset of the partition.
  
=== Choosing between GPT and MBR ===
+
=== Hard disk drives ===
  
[[GUID Partition Table]] (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.  
+
Historically, hard drives were addressed by indicating the ''cylinder'', the ''head'', and the ''sector'' at which data was to be read or written (also known as [[wikipedia:Cylinder-head-sector|CHS addressing]]). These represented the radial position (cylinder), the axial position (drive head: platter and side), and the azimuth (sector) of the data respectively. Nowadays, with [[wikipedia:Logical block addressing|logical block addressing]], the entire hard drive is addressed as one continuous stream of data and the term [[wikipedia:Disk sector|sector]] designates the smallest addressable unit.
  
The choice basically boils down to this:
+
The standard ''sector size'' is 512B, but modern high-capacity hard drives use greater value, commonly 4KiB. Using values greater than 512B is referred to as the [[Advanced Format]].
* If using GRUB legacy as the bootloader, one must use MBR.
+
* To dual-boot with Windows, one must use MBR.
+
** A special exception to this rule: dual-booting Windows 64-bit 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.
+
  
=== Using GPT - modern method ===
+
=== Solid state drives ===
  
==== Gdisk Usage Summary====
+
{{Expansion|The EBS should be the same as the value reported by {{ic|/sys/class/block/sd''X''/queue/discard_granularity}}.}}
  
Using GPT, the utility for editing the partition table is called {{ic|gdisk}}. It 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 [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=601813 less user-friendly] for aligning partitions. A summary of the typical usage of {{ic|gdisk}}:
+
Solid state drives are based on [[wikipedia:Flash memory|flash memory]], and thus differ significantly from hard drives. While reading remains possible in a random access fashion, erasure (hence rewriting and random writing) is possible only by [[wikipedia:Flash_memory#Block_erasure|whole blocks]]. Additionally, the ''erase block size'' (EBS) are significantly greater than regular ''block size'', for example 128KiB vs. 4KiB, so it is necessary to align to multiples of EBS. Some [[NVMe]] drives should be aligned to 4KiB, but not all. To find the sector size of your SSD, see [[Advanced Format#How to determine if HDD employ a 4k sector]].
  
* Install {{ic|gdisk}} through the {{Pkg|gptfdisk}} package.
+
=== Verify alignment ===
* Start {{ic|gdisk}} against your drive.
+
* If the drive is brand new or if you are wanting to start over, create a new empty GUID partition table with the {{Keypress|o}} command.
+
* Create a new partition with the {{Keypress|n}} 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 {{ic|<nowiki>+x{M,G}</nowiki>}} format to extend the partition {{ic|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, {{ic|Linux/Windows data}} (code {{ic|0700}}), should be fine for most use. Press {{Keypress|L}} to show the codes list. If planning to use LVM select Linux LVM (8e00).
+
* Assign other partitions in a like fashion.
+
* Write the table to disk and exit via the {{Keypress|w}} command.
+
* Format the new partitions with a [[File Systems|file system]].
+
  
{{Note|
+
[[fdisk|fdisk/gdisk]] and [[parted#Alignment|parted]] handle alignment automatically.
* To boot from a GPT partitioned disk on a BIOS based system you have to create, preferably at the disk's beginning, a [[GRUB2#GUID Partition Table (GPT) specific instructions|BIOS boot partition]] with no filesystem and with the partition type as {{ic|BIOS boot}} or {{ic|bios_grub}} partition (gdisk type code {{ic|EF02}}) for booting from the disk using [[GRUB]]. For [[Syslinux]], you do not need to create this bios_grub partition, but you need to have separate {{ic|/boot}} partition and enable {{ic|Legacy BIOS Bootable partition}} attribute for that partition (using gdisk).
+
* [[GRUB Legacy]] does not support GPT, users must use [[BURG]], [[GRUB]] or [[Syslinux]].
+
}}
+
{{Warning|If planning to dual boot with Windows in BIOS mode (this is the only available option for 32-bit Windows versions and 64-bit Windows XP), do '''not''' use GPT since Windows does '''not''' support booting from a GPT disk in BIOS systems! You will need to use MBR partitioning and boot in BIOS mode, as described below. This limitation does not apply if booting a modern 64-bit Windows version in UEFI mode.}}
+
  
=== Using MBR - legacy method ===
+
See [[GNU Parted#Check alignment]].
  
Using MBR, the utility for editing the partition table is called {{ic|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.
+
== Tips and tricks ==
  
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.
+
==== Converting MBR to GPT ====
  
==== Fdisk usage summary ====
+
See [[fdisk#Convert between MBR and GPT]].
  
* Start {{ic|fdisk}} against your drive.
+
==== GPT Kernel Support ====
* If the drive is brand new or if you are wanting to start over, create a new empty DOS partition table with the {{Keypress|o}} command.
+
 
* Create a new partition with the {{Keypress|n}} command (primary type/1st partition).
+
The {{ic|CONFIG_EFI_PARTITION}} option in the kernel config enables GPT support in the kernel (despite the name, EFI PARTITION). This option must be built in the kernel and not compiled as a loadable module. This option is required even if GPT disks are used only for data storage and not for booting. This option is enabled by default in Arch's {{Pkg|linux}} and {{Pkg|linux-lts}} kernels in the [core] repo. In case of a custom kernel, enable this option by doing {{ic|1=CONFIG_EFI_PARTITION=y}}.
* Use the {{ic|+xG}} format to extend the partition {{ic|x}} gigabytes.
+
* Change the partition's system id from the default type of Linux ({{ic|type 83}}) to the desired type via the {{Keypress|t}} 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 {{Keypress|l}} command.
+
* Assign other partitions in a like fashion.
+
* Write the table to disk and exit via the {{Keypress|w}} command.
+
* Format the new partitions with a [[File Systems|file system]].
+
  
 
== See also ==
 
== See also ==
 
+
* [[Wikipedia:Disk partitioning]]
*[[Ext4#Creating ext4 partitions from scratch|Creating ext4 partitions from scratch]]
+
* [[Wikipedia:Binary prefix]]
*[[Wikipedia:Disk partitioning]]
+
* [http://thestarman.pcministry.com/asm/mbr/DiskTerms.htm Understanding Disk Drive Terminology]
 +
* [http://kb.iu.edu/data/aijw.html What is a Master Boot Record (MBR)?]
 +
* Rod Smith's page on [http://www.rodsbooks.com/gdisk/whatsgpt.html What's a GPT?] and [http://rodsbooks.com/gdisk/booting.html Booting OSes from GPT]
 +
* [http://www.ibm.com/developerworks/linux/library/l-gpt/index.html?ca=dgr-lnxw07GPT-Storagedth-lx&S_TACT=105AGY83&S_CMP=grlnxw07 Make the most of large drives with GPT and Linux - IBM Developer Works]
 +
* [http://www.microsoft.com/whdc/device/storage/GPT_FAQ.mspx Microsoft's Windows and GPT FAQ]
 +
* [http://www.thomas-krenn.com/en/wiki/Partition_Alignment Partition Alignment] (with examples)

Latest revision as of 10:41, 29 November 2016

Partitioning a hard drive divides the available space into sections that can be accessed independently. An entire drive may be allocated to a single partition, or multiple ones for cases such as dual-booting, maintaining a swap partition, or to logically separate data such as audio and video files.

The required information is stored in a #Partition table scheme such as MBR or GPT.

Partition tables are created and modified using one of many #Partitioning tools which must be compatible to the chosen scheme of partitioning table. Available tools include fdisk and parted.

Once created, a partition must be formatted with an appropriate file system (swap excepted) before data can be written to it.

Partition table

Note: To print/list existing tables (of a specific device), run parted /dev/sda print or fdisk -l /dev/sda, where /dev/sda is a device name.

There are two main types of partition table available: Master Boot Record (MBR), and GUID Partition Table (GPT). These are described below along with a discussion on how to choose between the two. A third, less common alternative is using a partitionless disk, which is also discussed.

Master Boot Record

The Master Boot Record (MBR) is the first 512 bytes of a storage device. It contains an operating system bootloader and the storage device's partition table. It plays an important role in the boot process under BIOS systems. See Wikipedia:Master boot record#Disk partitioning for the MBR structure.

Note: The MBR is not located in a partition; it is located at the first sector of the device (physical offset 0), preceding the first partition. (The boot sector present on a partitionless device or within an individual partition is called a Volume boot record instead.)

Master Boot Record (partition table)

There are 3 types of partitions in the MBR scheme:

  • Primary
  • Extended
    • Logical

Primary partitions can be bootable and are limited to four partitions per disk or RAID volume. If the MBR partition table requires more than four partitions, then one of the primary partitions needs to be replaced by an extended partition containing logical partitions within it.

Extended partitions can be thought of as containers for logical partitions. A hard disk can contain no more than one extended partition. The extended partition is also counted as a primary partition so if the disk has an extended partition, only three additional primary partitions are possible (i.e. three primary partitions and one extended partition). The number of logical partitions residing in an extended partition is unlimited. A system that dual boots with Windows will require for Windows to reside in a primary partition.

The customary numbering scheme is to create primary partitions sda1 through sda3 followed by an extended partition sda4. The logical partitions on sda4 are numbered sda5, sda6, etc.

Master Boot Record (bootstrap code)

The first 446 bytes of MBR are bootstrap code area. On BIOS systems it usually contains the first stage of the boot loader.

GUID Partition Table

GUID Partition Table (GPT) is a partitioning scheme that is part of the Unified Extensible Firmware Interface specification; it uses globally unique identifiers (GUIDs), or UUIDs in linux world, to define partitions and partition types. It is designed to succeed the #Master Boot Record partitioning scheme method.

Choosing between GPT and MBR

GUID Partition Table (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 the recent developments to the formatting tools fdisk (MBR) and gdisk (GPT), it is equally easy to get good dependability and performance for GPT or MBR.

Some points to consider when choosing:

  • To dual-boot with Windows (both 32-bit and 64-bit) using Legacy BIOS, the MBR scheme is required.
  • To dual-boot Windows 64-bit using UEFI mode instead of BIOS, the GPT scheme is required.
  • If you are installing on older hardware, especially on old laptops, consider choosing MBR because its BIOS might not support GPT.
  • If you are partitioning a disk of 2 TiB or larger, you need to use GPT.
  • It is recommended to always use GPT for UEFI boot, as some UEFI implementations do not support booting to the MBR while in UEFI mode.
  • If none of the above apply, choose freely between GPT and MBR. Since GPT is more modern, it is recommended in this case.

Some advantages of GPT over MBR are:

  • Provides a unique disk GUID and unique partition GUID (PARTUUID) for each partition - A good filesystem-independent way of referencing partitions and disks.
  • Provides a filesystem-independent partition name (PARTLABEL).
  • Arbitrary number of partitions - depends on space allocated for the partition table - No need for extended and logical partitions. By default the GPT table contains space for defining 128 partitions. However if you want to define more partitions, you can allocate more space to the partition table (currently only gdisk is known to support this feature).
  • Uses 64-bit LBA for storing Sector numbers - maximum addressable disk size is 2 ZiB. MBR is limited to addressing 2 TiB of space per drive.
  • Stores a backup header and partition table at the end of the disk that aids in recovery in case the primary ones are damaged.
  • CRC32 checksums to detect errors and corruption of the header and partition table.
Note: For GRUB to boot from a GPT-partitioned disk on a BIOS-based system, a BIOS boot partition is required. Please note that this partition is unrelated to the /boot mountpoint, and will be used by GRUB directly. Do not create a filesystem on it, and do not mount it.

The section on #Partitioning tools contains a table indicating which tools are available for creating and modifying GPT and MBR tables.

Partitionless disk

Partitionless disk (a.k.a. superfloppy) refers to using a storage device without using a partition table, having one file system occupying the whole storage device.

Btrfs partitioning

Btrfs can occupy an entire data storage device and replace the MBR or GPT partitioning schemes. See the Btrfs#Partitionless Btrfs disk instructions for details.

Partition scheme

There are no strict rules for partitioning a hard drive, although one may follow the general guidance given below. A disk partitioning scheme is determined by various issues such as desired flexibility, speed, security, as well as the limitations imposed by available disk space. It is essentially personal preference. If you would like to dual boot Arch Linux and a Windows operating system please see Dual boot with Windows.

Note:

Single root partition

This scheme is the simplest and should be enough for most use cases. A swapfile can be created and easily resized as needed. It usually makes sense to start by considering a single / partition and then separate out others based on specific use cases like RAID, encryption, a shared media partition, etc.

Discrete partitions

Separating out a path as a partition allows for the choice of a different filesystem and mount options. In some cases like a media partition, they can also be shared between operating systems.

Below are some example layouts that can be used when partitioning, and the following subsections detail a few of the directories which can be placed on their own separate partition and then mounted at mount points under /. See file-hierarchy(7) for a full description of the contents of these directories.

/

The root directory is the top of the hierarchy, the point where the primary filesystem is mounted and from which all other filesystems stem. All files and directories appear under the root directory /, even if they are stored on different physical devices. The contents of the root filesystem must be adequate to boot, restore, recover, and/or repair the system. Therefore, certain directories under / are not candidates for separate partitions.

The / partition or root partition is necessary and it is the most important. The other partitions can be replaced by it.

Warning: Directories essential for booting (except for /boot) must be on the same partition as / or mounted in early userspace by the initramfs. These essential directories are: /etc and /usr [1].

/ traditionally contains the /usr directory, which can grow significantly depending upon how much software is installed. 15–20 GB should be sufficient for most users with modern hard disks. If you plan to store a swap file here, you might need a larger partition size.

/boot

The /boot directory contains the kernel and ramdisk images as well as the bootloader configuration file and bootloader stages. It also stores data that is used before the kernel begins executing user-space programs. /boot is not required for normal system operation, but only during boot and kernel upgrades (when regenerating the initial ramdisk).

A separate /boot partition is needed if installing a software RAID0 (stripe) system.

Note: It is recommended to mount ESP to /boot if booting using UEFI boot loaders that do not contain drivers for other filesystems. Such loaders are for example EFISTUB and systemd-boot.

A suggested size for /boot is 200 MiB unless using UEFI, in which case greater than 512 MiB is needed.

/home

The /home directory contains user-specific configuration files, caches, application data and media files.

Separating out /home allows / to be re-partitioned separately, but note that you can still reinstall Arch with /home untouched even if it is not separate—the other top-level directories just need to be removed, and then pacstrap can be run.

You should not share home directories between users on different distributions, because they use incompatible software versions and patches. Instead, consider sharing a media partition or at least using different home directories on the same /home partition. The size of this partition varies.

/var

The /var directory stores variable data such as spool directories and files, administrative and logging data, pacman's cache, the ABS tree, etc. It is used, for example, for caching and logging, and hence frequently read or written. Keeping it in a separate partition avoids running out of disk space due to flunky logs, etc.

It exists to make it possible to mount /usr as read-only. Everything that historically went into /usr that 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 file system type should consider this fact if a separate partition is used.

/var will contain, among other data, the ABS tree and the pacman cache. Retaining these packages is helpful in case a package upgrade causes instability, requiring a downgrade to an older, archived package. The pacman cache in particular will grow as the system is expanded and updated, but it can be safely cleared if space becomes an issue. 8–12 GB on a desktop system should be sufficient for /var, depending on how much software will be installed.

/data

One can consider mounting a "data" partition to cover various files to be shared by all users. Using the /home partition for this purpose is fine as well. The size of this partition varies.

/tmp

This is already a separate partition by default, by virtue of being mounted as tmpfs by systemd; therefore, there is no need to create a partition for it.

Swap

A swap partition provides memory that can be used as virtual RAM. A swap file should be considered too, as they don't have any performance overhead compared to a partition but are much easier to resize as needed. A swap partition can potentially be shared between operating systems, but not if hibernation is used.

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 is outdated. For example, on average desktop 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. See Suspend and hibernate to hibernate into a swap partition or file.

Example layouts

UEFI/GPT example layout

Mount point Partition Partition type (GUID) Bootable flag Suggested size
/boot /dev/sdx1 EFI System Partition Yes 260–512 MiB
[SWAP] /dev/sdx2 Linux swap No More than 512 MiB
/ /dev/sdx3 Linux No Remainder of the device

MBR/BIOS example layout

Mount point Partition Partition type Bootable flag Suggested size
[SWAP] /dev/sdx1 Linux swap No More than 512 MiB
/ /dev/sdx2 Linux Yes Remainder of the device

UEFI separate /home example layout

Mount point Partition Partition type (GUID) Bootable flag Suggested size
/boot /dev/sdx1 EFI System Partition Yes More than 512 MiB
/ /dev/sdx2 Linux No 15 - 20 GiB
[SWAP] /dev/sdx3 Linux swap No More than 512 MiB
/home /dev/sdx4 Linux No Remainder of the device

Partitioning tools

The following programs are used to create and/or manipulate device partition tables and partitions. See the linked articles for the exact commands to be used.

This table will help you to choose utility for your needs:

MBR GPT
Dialog fdisk
parted
fdisk
gdisk
parted
Pseudo-graphics cfdisk cfdisk
cgdisk
Non-interactive sfdisk
parted
sfdisk
sgdisk
parted
Graphical GParted
partitionmanager
GParted
partitionmanager
Warning: To partition devices, use a partitioning tool compatible to the chosen type of partition table. Incompatible tools may result in the destruction of that table, along with existing partitions or data.

fdisk/gdisk

These group of tools fall under fdisk or gdisk and are described in the fdisk article.

  • fdisk — Dialog-driven program for creation and manipulation of partition tables.
https://www.kernel.org/pub/linux/utils/util-linux/ || util-linux
  • cfdisk — Curses-based variant of fdisk.
https://www.kernel.org/pub/linux/utils/util-linux/ || util-linux
  • sfdisk — Scriptable variant of fdisk.
https://www.kernel.org/pub/linux/utils/util-linux/ || util-linux
http://www.rodsbooks.com/gdisk/ || gptfdisk
  • cgdisk — Curses-based variant of gdisk.
http://www.rodsbooks.com/gdisk/ || gptfdisk
  • sgdisk — Scriptable variant of gdisk.
http://www.rodsbooks.com/gdisk/sgdisk-walkthrough.html || gptfdisk

GNU Parted

These group of tools are described in the GNU Parted article.

https://www.gnu.org/software/parted/parted.html || parted
  • GParted — Graphical tool written in GTK.
http://gparted.sourceforge.net/ || gparted

partitionmanager

  • Partitionmanager — Graphical tool written in Qt.
http://sourceforge.net/projects/partitionman/ || partitionmanager

Partition alignment

Tango-edit-cut.pngThis section is being considered for removal.Tango-edit-cut.png

Reason: Gets a little technical to just say that fdisk/parted handle it automatically. (Discuss in Talk:Partitioning#)

Proper partition alignment is essential for optimal performance and longevity. This is due to the block nature of every I/O operation on the hardware level as well as file system level. The key to alignment is partitioning to (at least) the given block size, which depends on the used hardware. If the partitions are not aligned to begin at multiples of the block size, aligning the file system is a pointless exercise because everything is skewed by the start offset of the partition.

Hard disk drives

Historically, hard drives were addressed by indicating the cylinder, the head, and the sector at which data was to be read or written (also known as CHS addressing). These represented the radial position (cylinder), the axial position (drive head: platter and side), and the azimuth (sector) of the data respectively. Nowadays, with logical block addressing, the entire hard drive is addressed as one continuous stream of data and the term sector designates the smallest addressable unit.

The standard sector size is 512B, but modern high-capacity hard drives use greater value, commonly 4KiB. Using values greater than 512B is referred to as the Advanced Format.

Solid state drives

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: The EBS should be the same as the value reported by /sys/class/block/sdX/queue/discard_granularity. (Discuss in Talk:Partitioning#)

Solid state drives are based on flash memory, and thus differ significantly from hard drives. While reading remains possible in a random access fashion, erasure (hence rewriting and random writing) is possible only by whole blocks. Additionally, the erase block size (EBS) are significantly greater than regular block size, for example 128KiB vs. 4KiB, so it is necessary to align to multiples of EBS. Some NVMe drives should be aligned to 4KiB, but not all. To find the sector size of your SSD, see Advanced Format#How to determine if HDD employ a 4k sector.

Verify alignment

fdisk/gdisk and parted handle alignment automatically.

See GNU Parted#Check alignment.

Tips and tricks

Converting MBR to GPT

See fdisk#Convert between MBR and GPT.

GPT Kernel Support

The CONFIG_EFI_PARTITION option in the kernel config enables GPT support in the kernel (despite the name, EFI PARTITION). This option must be built in the kernel and not compiled as a loadable module. This option is required even if GPT disks are used only for data storage and not for booting. This option is enabled by default in Arch's linux and linux-lts kernels in the [core] repo. In case of a custom kernel, enable this option by doing CONFIG_EFI_PARTITION=y.

See also