1FDISK(8)                     System Administration                    FDISK(8)
2
3
4

NAME

6       fdisk - manipulate disk partition table
7

SYNOPSIS

9       fdisk [options] device
10
11       fdisk -l [device...]
12

DESCRIPTION

14       fdisk is a dialog-driven program for creation and manipulation of
15       partition tables. It understands GPT, MBR, Sun, SGI and BSD partition
16       tables.
17
18       Block devices can be divided into one or more logical disks called
19       partitions. This division is recorded in the partition table, usually
20       found in sector 0 of the disk. (In the BSD world one talks about `disk
21       slices' and a `disklabel'.)
22
23       All partitioning is driven by device I/O limits (the topology) by
24       default. fdisk is able to optimize the disk layout for a 4K-sector size
25       and use an alignment offset on modern devices for MBR and GPT. It is
26       always a good idea to follow fdisk's defaults as the default values
27       (e.g., first and last partition sectors) and partition sizes specified
28       by the +/-<size>{M,G,...} notation are always aligned according to the
29       device properties.
30
31       CHS (Cylinder-Head-Sector) addressing is deprecated and not used by
32       default. Please, do not follow old articles and recommendations with
33       fdisk -S <n> -H <n> advices for SSD or 4K-sector devices.
34
35       Note that partx(8) provides a rich interface for scripts to print disk
36       layouts, fdisk is mostly designed for humans. Backward compatibility in
37       the output of fdisk is not guaranteed. The input (the commands) should
38       always be backward compatible.
39

OPTIONS

41       -b, --sector-size sectorsize
42           Specify the sector size of the disk. Valid values are 512, 1024,
43           2048, and 4096. (Recent kernels know the sector size. Use this
44           option only on old kernels or to override the kernel’s ideas.)
45           Since util-linux-2.17, fdisk differentiates between logical and
46           physical sector size. This option changes both sector sizes to
47           sectorsize.
48
49       -B, --protect-boot
50           Don’t erase the beginning of the first disk sector when creating a
51           new disk label. This feature is supported for GPT and MBR.
52
53       -c, --compatibility[=mode]
54           Specify the compatibility mode, 'dos' or 'nondos'. The default is
55           non-DOS mode. For backward compatibility, it is possible to use the
56           option without the mode argument — then the default is used. Note
57           that the optional mode argument cannot be separated from the -c
58           option by a space, the correct form is for example -c=dos.
59
60       -h, --help
61           Display a help text and exit.
62
63       -L, --color[=when]
64           Colorize the output. The optional argument when can be auto, never
65           or always. If the when argument is omitted, it defaults to auto.
66           The colors can be disabled; for the current built-in default see
67           the --help output. See also the COLORS section.
68
69       -l, --list
70           List the partition tables for the specified devices and then exit.
71
72           If no devices are given, the devices mentioned in /proc/partitions
73           (if this file exists) are used. Devices are always listed in the
74           order in which they are specified on the command-line, or by the
75           kernel listed in /proc/partitions.
76
77       -x, --list-details
78           Like --list, but provides more details.
79
80       --lock[=mode]
81           Use exclusive BSD lock for device or file it operates. The optional
82           argument mode can be yes, no (or 1 and 0) or nonblock. If the mode
83           argument is omitted, it defaults to "yes". This option overwrites
84           environment variable $LOCK_BLOCK_DEVICE. The default is not to use
85           any lock at all, but it’s recommended to avoid collisions with
86           udevd or other tools.
87
88       -n, --noauto-pt
89           Don’t automatically create a default partition table on empty
90           device. The partition table has to be explicitly created by user
91           (by command like 'o', 'g', etc.).
92
93       -o, --output list
94           Specify which output columns to print. Use --help to get a list of
95           all supported columns.
96
97           The default list of columns may be extended if list is specified in
98           the format +list (e.g., -o +UUID).
99
100       -s, --getsz
101           Print the size in 512-byte sectors of each given block device. This
102           option is DEPRECATED in favour of blockdev(8).
103
104       -t, --type type
105           Enable support only for disklabels of the specified type, and
106           disable support for all other types.
107
108       -u, --units[=unit]
109           When listing partition tables, show sizes in 'sectors' or in
110           'cylinders'. The default is to show sizes in sectors. For backward
111           compatibility, it is possible to use the option without the unit
112           argument — then the default is used. Note that the optional unit
113           argument cannot be separated from the -u option by a space, the
114           correct form is for example '*-u=*cylinders'.
115
116       -C, --cylinders number
117           Specify the number of cylinders of the disk. I have no idea why
118           anybody would want to do so.
119
120       -H, --heads number
121           Specify the number of heads of the disk. (Not the physical number,
122           of course, but the number used for partition tables.) Reasonable
123           values are 255 and 16.
124
125       -S, --sectors number
126           Specify the number of sectors per track of the disk. (Not the
127           physical number, of course, but the number used for partition
128           tables.) A reasonable value is 63.
129
130       -w, --wipe when
131           Wipe filesystem, RAID and partition-table signatures from the
132           device, in order to avoid possible collisions. The argument when
133           can be auto, never or always. When this option is not given, the
134           default is auto, in which case signatures are wiped only when in
135           interactive mode. In all cases detected signatures are reported by
136           warning messages before a new partition table is created. See also
137           wipefs(8) command.
138
139       -W, --wipe-partitions when
140           Wipe filesystem, RAID and partition-table signatures from a newly
141           created partitions, in order to avoid possible collisions. The
142           argument when can be auto, never or always. When this option is not
143           given, the default is auto, in which case signatures are wiped only
144           when in interactive mode and after confirmation by user. In all
145           cases detected signatures are reported by warning messages before a
146           new partition is created. See also wipefs(8) command.
147
148       -V, --version
149           Display version information and exit.
150

DEVICES

152       The device is usually /dev/sda, /dev/sdb or so. A device name refers to
153       the entire disk. Old systems without libata (a library used inside the
154       Linux kernel to support ATA host controllers and devices) make a
155       difference between IDE and SCSI disks. In such cases the device name
156       will be /dev/hd* (IDE) or /dev/sd* (SCSI).
157
158       The partition is a device name followed by a partition number. For
159       example, /dev/sda1 is the first partition on the first hard disk in the
160       system. See also Linux kernel documentation (the
161       Documentation/admin-guide/devices.txt file).
162

SIZES

164       The "last sector" dialog accepts partition size specified by number of
165       sectors or by +/-<size>{K,B,M,G,...} notation.
166
167       If the size is prefixed by '+' then it is interpreted as relative to
168       the partition first sector. If the size is prefixed by '-' then it is
169       interpreted as relative to the high limit (last available sector for
170       the partition).
171
172       In the case the size is specified in bytes than the number may be
173       followed by the multiplicative suffixes KiB=1024, MiB=1024*1024, and so
174       on for GiB, TiB, PiB, EiB, ZiB and YiB. The "iB" is optional, e.g., "K"
175       has the same meaning as "KiB".
176
177       The relative sizes are always aligned according to device I/O limits.
178       The +/-<size>{K,B,M,G,...} notation is recommended.
179
180       For backward compatibility fdisk also accepts the suffixes KB=1000,
181       MB=1000*1000, and so on for GB, TB, PB, EB, ZB and YB. These 10^N
182       suffixes are deprecated.
183

SCRIPT FILES

185       fdisk allows reading (by 'I' command) sfdisk(8) compatible script
186       files. The script is applied to in-memory partition table, and then it
187       is possible to modify the partition table before you write it to the
188       device.
189
190       And vice-versa it is possible to write the current in-memory disk
191       layout to the script file by command 'O'.
192
193       The script files are compatible between cfdisk(8), sfdisk(8), fdisk and
194       other libfdisk applications. For more details see sfdisk(8).
195

DISK LABELS

197       GPT (GUID Partition Table)
198           GPT is modern standard for the layout of the partition table. GPT
199           uses 64-bit logical block addresses, checksums, UUIDs and names for
200           partitions and an unlimited number of partitions (although the
201           number of partitions is usually restricted to 128 in many
202           partitioning tools).
203
204           Note that the first sector is still reserved for a protective MBR
205           in the GPT specification. It prevents MBR-only partitioning tools
206           from mis-recognizing and overwriting GPT disks.
207
208           GPT is always a better choice than MBR, especially on modern
209           hardware with a UEFI boot loader.
210
211       DOS-type (MBR)
212           A DOS-type partition table can describe an unlimited number of
213           partitions. In sector 0 there is room for the description of 4
214           partitions (called `primary'). One of these may be an extended
215           partition; this is a box holding logical partitions, with
216           descriptors found in a linked list of sectors, each preceding the
217           corresponding logical partitions. The four primary partitions,
218           present or not, get numbers 1-4. Logical partitions are numbered
219           starting from 5.
220
221           In a DOS-type partition table the starting offset and the size of
222           each partition is stored in two ways: as an absolute number of
223           sectors (given in 32 bits), and as a Cylinders/Heads/Sectors triple
224           (given in 10+8+6 bits). The former is OK — with 512-byte sectors
225           this will work up to 2 TB. The latter has two problems. First,
226           these C/H/S fields can be filled only when the number of heads and
227           the number of sectors per track are known. And second, even if we
228           know what these numbers should be, the 24 bits that are available
229           do not suffice. DOS uses C/H/S only, Windows uses both, Linux never
230           uses C/H/S. The C/H/S addressing is deprecated and may be
231           unsupported in some later fdisk version.
232
233           Please, read the DOS-mode section if you want DOS-compatible
234           partitions. fdisk does not care about cylinder boundaries by
235           default.
236
237       BSD/Sun-type
238           A BSD/Sun disklabel can describe 8 partitions, the third of which
239           should be a `whole disk' partition. Do not start a partition that
240           actually uses its first sector (like a swap partition) at cylinder
241           0, since that will destroy the disklabel. Note that a BSD label is
242           usually nested within a DOS partition.
243
244       IRIX/SGI-type
245           An IRIX/SGI disklabel can describe 16 partitions, the eleventh of
246           which should be an entire `volume' partition, while the ninth
247           should be labeled `volume header'. The volume header will also
248           cover the partition table, i.e., it starts at block zero and
249           extends by default over five cylinders. The remaining space in the
250           volume header may be used by header directory entries. No
251           partitions may overlap with the volume header. Also do not change
252           its type or make some filesystem on it, since you will lose the
253           partition table. Use this type of label only when working with
254           Linux on IRIX/SGI machines or IRIX/SGI disks under Linux.
255
256           A sync() and an ioctl(BLKRRPART) (rereading the partition table
257           from disk) are performed before exiting when the partition table
258           has been updated.
259

DOS MODE AND DOS 6.X WARNING

261       Note that all this is deprecated. You don’t have to care about things
262       like geometry and cylinders on modern operating systems. If you really
263       want DOS-compatible partitioning then you have to enable DOS mode and
264       cylinder units by using the '-c=dos -u=cylinders' fdisk command-line
265       options.
266
267       The DOS 6.x FORMAT command looks for some information in the first
268       sector of the data area of the partition, and treats this information
269       as more reliable than the information in the partition table. DOS
270       FORMAT expects DOS FDISK to clear the first 512 bytes of the data area
271       of a partition whenever a size change occurs. DOS FORMAT will look at
272       this extra information even if the /U flag is given — we consider this
273       a bug in DOS FORMAT and DOS FDISK.
274
275       The bottom line is that if you use fdisk or cfdisk to change the size
276       of a DOS partition table entry, then you must also use dd(1) to zero
277       the first 512 bytes of that partition before using DOS FORMAT to format
278       the partition. For example, if you were using fdisk to make a DOS
279       partition table entry for /dev/sda1, then (after exiting fdisk and
280       rebooting Linux so that the partition table information is valid) you
281       would use the command dd if=/dev/zero of=/dev/sda1 bs=512 count=1 to
282       zero the first 512 bytes of the partition.
283
284       fdisk usually obtains the disk geometry automatically. This is not
285       necessarily the physical disk geometry (indeed, modern disks do not
286       really have anything like a physical geometry, certainly not something
287       that can be described in the simplistic Cylinders/Heads/Sectors form),
288       but it is the disk geometry that MS-DOS uses for the partition table.
289
290       Usually all goes well by default, and there are no problems if Linux is
291       the only system on the disk. However, if the disk has to be shared with
292       other operating systems, it is often a good idea to let an fdisk from
293       another operating system make at least one partition. When Linux boots
294       it looks at the partition table, and tries to deduce what (fake)
295       geometry is required for good cooperation with other systems.
296
297       Whenever a partition table is printed out in DOS mode, a consistency
298       check is performed on the partition table entries. This check verifies
299       that the physical and logical start and end points are identical, and
300       that each partition starts and ends on a cylinder boundary (except for
301       the first partition).
302
303       Some versions of MS-DOS create a first partition which does not begin
304       on a cylinder boundary, but on sector 2 of the first cylinder.
305       Partitions beginning in cylinder 1 cannot begin on a cylinder boundary,
306       but this is unlikely to cause difficulty unless you have OS/2 on your
307       machine.
308
309       For best results, you should always use an OS-specific partition table
310       program. For example, you should make DOS partitions with the DOS FDISK
311       program and Linux partitions with the Linux fdisk or Linux cfdisk(8)
312       programs.
313

COLORS

315       Implicit coloring can be disabled by an empty file
316       /etc/terminal-colors.d/fdisk.disable.
317
318       See terminal-colors.d(5) for more details about colorization
319       configuration. The logical color names supported by fdisk are:
320
321       header
322           The header of the output tables.
323
324       help-title
325           The help section titles.
326
327       warn
328           The warning messages.
329
330       welcome
331           The welcome message.
332

ENVIRONMENT

334       FDISK_DEBUG=all
335           enables fdisk debug output.
336
337       LIBFDISK_DEBUG=all
338           enables libfdisk debug output.
339
340       LIBBLKID_DEBUG=all
341           enables libblkid debug output.
342
343       LIBSMARTCOLS_DEBUG=all
344           enables libsmartcols debug output.
345
346       LIBSMARTCOLS_DEBUG_PADDING=on
347           use visible padding characters.
348
349       LOCK_BLOCK_DEVICE=<mode>
350           use exclusive BSD lock. The mode is "1" or "0". See --lock for more
351           details.
352

AUTHORS

354       Karel Zak <kzak@redhat.com>, Davidlohr Bueso <dave@gnu.org>
355
356       The original version was written by Andries E. Brouwer, A. V. Le Blanc
357       and others.
358

SEE ALSO

360       cfdisk(8), mkfs(8), partx(8), sfdisk(8)
361

REPORTING BUGS

363       For bug reports, use the issue tracker at
364       https://github.com/karelzak/util-linux/issues.
365

AVAILABILITY

367       The fdisk command is part of the util-linux package which can be
368       downloaded from Linux Kernel Archive
369       <https://www.kernel.org/pub/linux/utils/util-linux/>.
370
371
372
373util-linux 2.37.2                 2021-08-16                          FDISK(8)
Impressum