| FDISK(8) | System Manager's Manual | FDISK(8) |
fdisk — partition
table maintenance program
fdisk |
[-evy] [-A |
-g | -i |
-u] [-b
blocks[@offset[:type]]]
[-l blocks |
-c cylinders
-h heads
-s sectors]
[-f file]
disk |
fdisk |
-R [-evy]
disk [file] |
fdisk creates and edits MBR and GPT
partition tables. These tables are used by the boot process of some
platforms to find the OpenBSD kernel and, when
present, are used by the kernel to find the
disklabel(5).
Caution is advised when editing these tables since some platforms rely on specific configurations created at install time.
The options are as follows:
-A-b into a
single OpenBSD partition. The available space is
maximized by deleting all existing partition entries except for partition
types APFS ISC, APFS, APFS Recovery, BIOS Boot, HiFive FSBL, HiFive BBL
and partitions with the ‘Required’ GPT attribute set.
If APFS ISC, APFS, or APFS Recovery partitions are detected
then existing EFI system partitions are also preserved. If the preserved
EFI system partition has fewer blocks than the number requested with
-b, the modified GPT is discarded.
-b
blocks[@offset[:type]]-b is only available in combination
with -A, -g, or
-i.
If -A or -g is
specified, only the blocks value is used.
-c
cylinders -h
heads -s
sectorsfdisk to use. By default
the disk size and geometry are obtained from the default
disklabel(5) constructed by the kernel for
disk. See disklabel(5) and
disklabel(8).-e-f
file-g-b.-i-b. The bootcode is initialized
as described in -u.-l
count-R
disk [file]fdisk -v (e.g. the
fdisk* files in /var/backups) or compact GPT partition descriptions of the
form
<id>:<type>[<start>:<size>]<attributes><name>where a new partition UUID is always generated and <attributes><name> is optional. For example:
0: EFI Sys [64:66560] 0x0 EFI
System AreaIf <start> is 0 it is set to the first usable LBA of the largest chunk of free space.
If file is not provided,
fdisk attempts to fully restore a GPT if either
a primary or secondary GPT exists on disk.
-u-f) the MBR, except for the partition entries, is
replaced by the first block of the file. If no bootcode file is present,
zeros are used.
Not available when editing a GPT.
-v-yfdisk creates or modifies the partition table of
disk. disk can be a full
pathname, e.g. /dev/rsd0c, a raw partition name,
e.g. sd0c, or just the disk name, e.g.
sd0.When called without options, fdisk prints
the partition table of disk.
If disk has a GPT a terse version of its contents is printed:
# fdisk sd0 Disk: sd0 Usable LBA: 64 to 500118128 [500118192 Sectors] #: type [ start: size ] ------------------------------------------------------------------------ 1: EFI Sys [ 64: 960 ] 3: OpenBSD [ 1024: 500117105 ]
When disk does not have a GPT, the first block of disk is printed as an MBR:
# fdisk sd0
Disk: sd0 geometry: 121601/255/63 [1953525168 Sectors]
Offset: 0 Signature: 0xAA55
Starting Ending LBA Info:
#: id C H S - C H S [ start: size ]
------------------------------------------------------------------------
0: 0B 0 1 1 - 26108 0 63 [ 63: 419425020 ] FAT32
1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
*3: A6 26108 1 1 - 121600 254 63 [ 419425083: 1534094982 ] OpenBSD
NOTE: Partition entry #3 of this MBR is flagged as bootable.
NOTE: The S field in the C/H/S values is “1 based”, but the LBA "start" field is “0 based”.
The -v option causes more information to
be printed:
# fdisk -v sd0
Primary GPT:
Disk: sd0 Usable LBA: 64 to 500118128 [500118192 Sectors]
GUID: f0418899-4976-4604-a783-3ebe135a8f12
#: type [ start: size ]
guid name
------------------------------------------------------------------------
1: EFI Sys [ 64: 960 ]
d0834013-dab8-44df-a5e4-123148f17e03 EFI System Area
3: OpenBSD [ 1024: 500117105 ]
cd356d77-8369-44b4-996e-79e8b9a47bfe OpenBSD Area
Secondary GPT:
Disk: sd0 Usable LBA: 64 to 500118128 [500118192 Sectors]
GUID: f0418899-4976-4604-a783-3ebe135a8f12
#: type [ start: size ]
guid name
------------------------------------------------------------------------
1: EFI Sys [ 64: 960 ]
d0834013-dab8-44df-a5e4-123148f17e03 EFI System Area
3: OpenBSD [ 1024: 500117105 ]
cd356d77-8369-44b4-996e-79e8b9a47bfe OpenBSD Area
MBR:
Disk: sd0 geometry: 31130/255/63 [500118192 Sectors]
Offset: 0 Signature: 0xAA55
Starting Ending LBA Info:
#: id C H S - C H S [ start: size ]
-------------------------------------------------------------------------------
0: EE 0 0 2 - 31130 233 63 [ 1: 500118191 ] EFI GPT
1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
When fdisk enters interactive command
mode, it copies the partition table from disk into
memory and performs all edits on that copy. The partition table on
disk is modified only by write or
quit commands.
The prompt contains information about the state of the edit process.
disk*:1>Where disk is the name of the disk being edited, ‘*’ means that the partition table has been modified, but not yet written to disk and 1 is the edit level when operating on the MBR or GPT. This number is 2 when editing an extended partition in the MBR, 3 when editing an extended partition within the edit level 2 extended partition, and so on.
The list of commands and their functions is given below. Commands may be abbreviated. The first command matching the abbreviation is selected.
?help.helpmanualreinit
[gpt | mbr]By default an MBR partition table is initialized. If
gpt is specified a GPT partition table is
initialized, including the protective MBR.
setpid
#edit
# | desc# (MBR or GPT) triggers interactive editing of the partition.
desc (GPT only) immediately modifies the
partition. desc is in the compact format supported
by the -R command line argument.
The offset and size of the entry may be specified in CHS mode (MBR only), by using sector offsets and sizes, or by using the units ‘b’, ‘k’, ‘m’, ‘g’, or ‘t’ to indicate bytes, kilobytes, megabytes, gigabytes, or terabytes. The special size value ‘*’ causes the partition to be sized to use the remainder of the disk.
flag
# [value]update-f) the MBR, except for the partition entries, is
replaced by the first block of the file. If no bootcode file is present,
zeros are used.
Not available when editing a GPT.
select
#Not available when editing a GPT.
swap
# #print
[unit]writeexitfdisk terminates.quitfdisk terminates.abortfdisk.disklabel(5), boot(8), boot_amd64(8), boot_i386(8), boot_macppc(8), disklabel(8)
| June 29, 2025 | Debian |