fdisk - ArchWiki
fdisk - ArchWiki
org/title/Fdisk
fdisk
util-linux fdisk (https://git.kernel.org/cgit/utils/util-linux/util-linux.git/) is a dialogue-driven Related articles
command-line utility that creates and manipulates partition tables and partitions on a hard disk.
Hard disks are divided into partitions and this division is described in the partition table. File systems
gdisk
This article covers fdisk(8) (https://man.archlinux.org/man/fdisk.8) and its related
sfdisk(8) (https://man.archlinux.org/man/sfdisk.8) utility. GNU Parted
Partitioning
Note: fdisk supports GPT since util-linux (https://archlinux.org/packages/?name=ut
dd
il-linux) 2.23. [1] (https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/commit/?id
=766d5156c43b784700d28d1c1141008b2bf35ed7) Alternatively, gptfdisk (https://archli
nux.org/packages/?name=gptfdisk) may be used; see gdisk for more information.
Tip: For basic partitioning functionality with a curses-based user interface, cfdisk(8) (https://man.archlinux.org/man/c
fdisk.8) can be used.
1 Installation
fdisk and its associated utilities are provided by the util-linux (https://archlinux.org/packages/?name=util-linux)
package, which is a dependency of the base (https://archlinux.org/packages/?name=base) meta package.
2 List partitions
To list partition tables and partitions on a block device, you can run the following, where device is a name like /dev/sda ,
/dev/nvme0n1 , /dev/mmcblk0 , etc.:
# fdisk -l /dev/sda
Note: If the device is not specified, fdisk will list all partitions in /proc/partitions .
For both GPT and MBR you can use sfdisk to save the partition layout of your device to a file with the -d / --dump option. Run the
following command for device /dev/sda :
The file should look something like this for a single ext4 partition that is 1 GiB in size:
sda.dump
label: gpt
label-id: AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE
device: /dev/sda
unit: sectors
first-lba: 34
last-lba: 1048576
sector-size: 512
Before beginning, you may wish to backup your current partition table and scheme.
fdisk performs partition alignment automatically on a 2048 512-byte sector (1 MiB) block size base which should be compatible with
all Advanced Format HDDs and the vast majority of SSDs if not all. This means that the default settings will give you proper
alignment.
1 of 4 2/13/25, 2:56 PM
fdisk - ArchWiki https://wiki.archlinux.org/title/Fdisk
To use fdisk, run the program with the name of the block device you want to change/edit. This example uses /dev/sda :
# fdisk /dev/sda
This opens the fdisk dialogue where you can type in commands.
Tip:
▪ Check that your NVMe drives and Advanced Format hard disk drives are using the optimal logical sector size before
partitioning.
▪ Consider performing SSD memory cell clearing before partitioning an SSD.
To create a new partition table and clear all current partition data type g at the prompt for a GUID Partition Table (GPT) or o for
an MBR partition table. Skip this step if the table you require has already been created.
Note: See Partitioning#Partition scheme for considerations concerning the size and location of partitions.
fdisk does not ask for the partition type ID and uses 'Linux filesystem' by default; you can change it later.
▪ absolute terms from the start of the disk. E.g. 40M as a first sector specifies a position 40 MiB from the start of the disk.
▪ relative terms by preceding the size with +size or -size . E.g. +2G to specify a point 2 GiB after the start sector, or -200M to
specify a point 200 MiB before the last available sector.
Pressing the Enter key with no input specifies the default value, which is the start of the largest available block for the first sector
and the end of the same block for the last sector.
Note:
▪ When partitioning it is always a good idea to follow the default value for a partition's first sector. Additionally, make sure to
specify partition sizes with the +size{M,G,T,P} notation and do not use sizes smaller than 1 MiB. Such partitions will always
be aligned according to the device properties.
▪ EFI system partition requires the partition type EFI System .
▪ GRUB requires a BIOS boot partition with partition type BIOS boot when installing GRUB to a GPT partitioned disk on a
BIOS-based system.
Tip: On a disk with an MBR partition table leave at least 33 512-byte sectors (16.5 KiB) of free unpartitioned space at the end of
the disk to allow converting between MBR and GPT.
Repeat this procedure until you have the partitions you desire.
2 of 4 2/13/25, 2:56 PM
fdisk - ArchWiki https://wiki.archlinux.org/title/Fdisk
Press t to change the type of a partition. You can use an alias for common partition types:
Tip:
5 Moving partitions
Warning: Partitions can only be moved while offline. Because moving a partition requires the whole partition to be rewritten on
disk, it is a slow and potentially hazardous operation. Backups are strongly recommended! According sfdisk(8) § OPTIONS (h
ttps://man.archlinux.org/man/sfdisk.8#OPTIONS), "this operation is risky and not atomic."
In order to move a partition, you need to have free space available where the partition will be moved. If necessary, you can make
room by shrinking your partitions and the filesystems on them. See Parted#Shrinking partitions. To relocate a partition:
Where sectors is the number of sectors to move the partition (the + indicates moving it forward), device is the device that
holds the partition, and number is the partition number. Note that if you add a new partition in the middle or at the beginning of
your disk, you will likely want to renumber the partitions. See #Sort partitions or the "extra functionality" mode of fdisk.
# sfdisk -r /dev/sda
After sorting the partitions if you are not using Persistent block device naming, it might be required to adjust the /etc/fstab
and/or the /etc/crypttab configuration files.
Note: The kernel must read the new partition table for the partitions (e.g. /dev/sda1 ) to be usable. Reboot the system or tell the
kernel to reread the partition table (https://serverfault.com/questions/36038/reread-partition-table-without-rebooting) (i.e.
partprobe /dev/sda ).
7 See also
▪ Managing partitions in Linux with fdisk (https://www.redhat.com/sysadmin/partitions-fdisk)
3 of 4 2/13/25, 2:56 PM
fdisk - ArchWiki https://wiki.archlinux.org/title/Fdisk
4 of 4 2/13/25, 2:56 PM