]> git.ipfire.org Git - thirdparty/util-linux.git/blame - disk-utils/fdisk.8
cfdisk: print "wrong order" warning after startup, colorize info messages
[thirdparty/util-linux.git] / disk-utils / fdisk.8
CommitLineData
6dbe3af9 1.\" Copyright 1992, 1993 Rickard E. Faith (faith@cs.unc.edu)
2b6fc908 2.\" Copyright 1998 Andries E. Brouwer (aeb@cwi.nl)
6efb4b12 3.\" Copyright 2012 Davidlohr Bueso <dave@gnu.org>
811d2ecc 4.\" Copyright (C) 2013 Karel Zak <kzak@redhat.com>
6dbe3af9 5.\" May be distributed under the GNU General Public License
811d2ecc 6.TH FDISK 8 "September 2013" "util-linux" "System Administration"
eb2be4fd 7
6dbe3af9 8.SH NAME
232dc924 9fdisk \- manipulate disk partition table
eb2be4fd 10
6dbe3af9 11.SH SYNOPSIS
57bc4707 12.B fdisk
f49ccec2 13[options]
57bc4707 14.I device
2b6fc908 15.sp
57bc4707 16.B fdisk \-l
57bc4707 17.RI [ device ...]
eb2be4fd 18
6dbe3af9 19.SH DESCRIPTION
278f63c0 20.B fdisk
811d2ecc 21is a dialog-driven program for creation and manipulation of partition tables.
870a6df5 22It understands GPT, MBR, Sun, SGI and BSD partition tables.
278f63c0 23
870a6df5 24Block devices can be divided into one or more logical disks called
2b6fc908 25.IR partitions .
a1939d70
BS
26This division is recorded in the
27.IR "partition table" ,
811d2ecc 28usually found in sector 0 of the disk.
a1939d70 29(In the BSD world one talks about `disk slices' and a `disklabel'.)
2b6fc908 30
870a6df5 31All partitioning is driven by device I/O limits (the topology) by default.
6dbe3af9 32.B fdisk
870a6df5
BS
33is able to optimize the disk layout for a 4K-sector size and use an alignment offset on
34modern devices for MBR and GPT. It is always a good idea to follow \fBfdisk\fR's defaults
811d2ecc 35as the default values (e.g. first and last partition sectors) and partition
870a6df5 36sizes specified by the +<size>{M,G,...} notation are always aligned according
811d2ecc 37to the device properties.
6dbe3af9 38
811d2ecc 39Note that
870a6df5
BS
40.BR partx (8)
41provides a rich interface for scripts to print disk layouts,
42.B fdisk
43is mostly designed for humans. Backward compatibility in the output of
811d2ecc 44.B fdisk
870a6df5 45is not guaranteed. The input (the commands) should always be backward compatible.
6dbe3af9
KZ
46
47.SH OPTIONS
48.TP
b06c1ca6 49\fB\-b\fR, \fB\-\-sector\-size\fR \fIsectorsize\fP
870a6df5
BS
50Specify the sector size of the disk. Valid values are 512, 1024, 2048, and 4096.
51(Recent kernels know the sector size. Use this option only on old kernels or
eb2be4fd 52to override the kernel's ideas.) Since util-linux-2.17, \fBfdisk\fR differentiates
a1939d70 53between logical and physical sector size. This option changes both sector sizes to
7f152745 54.IB sectorsize .
6dbe3af9 55.TP
e3a4aaa7 56\fB\-c\fR, \fB\-\-compatibility\fR[\fI=mode\fR]
455fe9a0 57Specify the compatibility mode, 'dos' or 'nondos'. The default is non-DOS
a1939d70 58mode. For backward compatibility, it is possible to use the option without
eb2be4fd
BS
59the \fImode\fR argument -- then the default is used. Note that the optional
60\fImode\fR argument cannot be separated from the \fB-c\fR option by a space,
e3a4aaa7 61the correct form is for example '-c=dos'.
78498b7b 62.TP
e3a4aaa7 63\fB\-h\fR, \fB\-\-help\fR
eb2be4fd 64Display a help text and exit.
a1939d70 65.TP
e3a4aaa7 66\fB\-L\fR, \fB\-\-color\fR[\fI=when\fR]
870a6df5
BS
67Colorize the output in interactive mode. The optional argument \fIwhen\fP can
68be \fBauto\fR, \fBnever\fR or \fBalways\fR. The default is \fBauto\fR.
80a1712f 69.TP
e3a4aaa7 70\fB\-l\fR, \fB\-\-list\fR
eb63b9b8
KZ
71List the partition tables for the specified devices and then exit.
72If no devices are given, those mentioned in
73.I /proc/partitions
870a6df5 74(if that file exists) are used.
6dbe3af9 75.TP
fff8ad58
KZ
76.BR \-o , " \-\-output " \fIlist\fP
77Specify which output columns to print. Use
78.B \-\-help
79to get a list of all supported columns.
80
81The default list of columns may be extended if \fIlist\fP is
82specified in the format \fI+list\fP (e.g. \fB-o +UUID\fP).
83.TP
e3a4aaa7
KZ
84\fB\-s\fR, \fB\-\-getsz\fR
85Print the size in 512-byte sectors of each given block device. This option is DEPRECATED
9564e46c 86in favour of
870a6df5 87.BR blockdev (1).
2b6fc908 88.TP
e3a4aaa7 89\fB\-t\fR, \fB\-\-type\fR \fItype\fR
870a6df5
BS
90Enable support only for disklabels of the specified \fItype\fP, and disable
91support for all other types.
565b7da6 92.TP
e3a4aaa7 93\fB\-u\fR, \fB\-\-units\fR[\fI=unit\fR]
a1939d70
BS
94When listing partition tables, show sizes in 'sectors' or in 'cylinders'. The
95default is to show sizes in sectors. For backward compatibility, it is possible
eb2be4fd
BS
96to use the option without the \fIunit\fR argument -- then the default is used.
97Note that the optional \fIunit\fR argument cannot be separated from the \fB-u\fR
98option by a space, the correct form is for example '-u=cylinders'.
e3a4aaa7
KZ
99
100.TP
4b4e391a 101\fB\-C\fR, \fB\-\-cylinders\fR \fInumber\fR
e3a4aaa7
KZ
102Specify the number of cylinders of the disk.
103I have no idea why anybody would want to do so.
104.TP
4b4e391a 105\fB\-H\fR, \fB\-\-heads\fR \fInumber\fR
e3a4aaa7
KZ
106Specify the number of heads of the disk. (Not the physical number,
107of course, but the number used for partition tables.)
108Reasonable values are 255 and 16.
109.TP
4b4e391a 110\fB\-S\fR, \fB\-\-sectors\fR \fInumber\fR
e3a4aaa7
KZ
111Specify the number of sectors per track of the disk.
112(Not the physical number, of course, but the number used for
113partition tables.) A reasonable value is 63.
114
22853e4a 115.TP
e3a4aaa7 116\fB\-V\fR, \fB\-\-version\fR
eb2be4fd 117Display version information and exit.
24505fb2 118
811d2ecc
KZ
119.SH DEVICES
120The
121.I device
122is usually /dev/sda, /dev/sdb or so. A device name refers to the entire disk.
123Old systems without libata (a library used inside the Linux kernel to support
124ATA host controllers and devices) make a difference between IDE and SCSI disks.
125In such cases the device name will be /dev/hd* (IDE) or /dev/sd* (SCSI).
126
127The
128.I partition
129is a device name followed by a partition number. For example, /dev/sda1 is the
130first partition on the first hard disk in the system. See also Linux kernel
131documentation (the Documentation/devices.txt file).
132
fd211531
KZ
133.SH SIZES
134The "last sector" dialog accepts partition size specified by number of sectors
135or by +<size>{K,B,M,G,...} notation.
136
137If the size is prefixed by '+' then it is interpreted as relative to the
138partition first sector. In this case the size is expected in bytes and the
139number may be followed by the multiplicative suffixes KiB=1024, MiB=1024*1024,
140and so on for GiB, TiB, PiB, EiB, ZiB and YiB. The "iB" is optional, e.g. "K"
141has the same meaning as "KiB".
142
143The relative sizes are always aligned according to device I/O limits. The
144+<size>{K,B,M,G,...} notation is recommended.
145
146For backward compatibility fdisk also accepts the suffixes KB=1000,
147MB=1000*1000, and so on for GB, TB, PB, EB, ZB and YB. These 10^N suffixes
148are deprecated.
149
a30e4ef4
KZ
150.SH SCRIPT FILES
151.B fdisk
152allows to read (by 'I' command) sfdisk compatible script files. The script is
153applied to in-memory partition table, and then it is possible to modify the
154partition table before you write it to the device.
155.PP
156And vice-versa it is possible to write the current in-memory disk layout
157to the script file by command 'O'.
158.PP
159The script files are compatible between cfdisk, sfdisk, fdisk and another
160libfdisk applications. For more details see
161.BR sfdisk (8).
162
811d2ecc
KZ
163.SH DISK LABELS
164.B GPT (GUID Partition Table)
165.RS
870a6df5
BS
166GPT is modern standard for the layout of the partition table. GPT uses 64-bit
167logical block addresses, checksums, UUIDs and names for partitions and an
168unlimited number of partitions (although the number of partitions is
811d2ecc
KZ
169usually restricted to 128 in many partitioning tools).
170
171Note that the first sector is still reserved for a
172.B protective MBR
870a6df5
BS
173in the GPT specification. It prevents MBR-only partitioning tools
174from mis-recognizing and overwriting GPT disks.
811d2ecc 175
870a6df5 176GPT is always a better choice than MBR, especially on modern hardware with a UEFI
811d2ecc
KZ
177boot loader.
178.RE
179
180.B DOS-type (MBR)
181.RS
870a6df5 182A DOS-type partition table can describe an unlimited number of partitions. In sector 0
811d2ecc
KZ
183there is room for the description of 4 partitions (called `primary'). One of
184these may be an extended partition; this is a box holding logical partitions,
185with descriptors found in a linked list of sectors, each preceding the
186corresponding logical partitions. The four primary partitions, present or not,
870a6df5 187get numbers 1-4. Logical partitions are numbered starting from 5.
811d2ecc
KZ
188
189In a DOS-type partition table the starting offset and the size of each
190partition is stored in two ways: as an absolute number of sectors (given in 32
191bits), and as a
192.B Cylinders/Heads/Sectors
193triple (given in 10+8+6 bits). The former is OK -- with 512-byte sectors this
194will work up to 2 TB. The latter has two problems. First, these C/H/S fields
195can be filled only when the number of heads and the number of sectors per track
196are known. And second, even if we know what these numbers should be, the 24
197bits that are available do not suffice. DOS uses C/H/S only, Windows uses
870a6df5 198both, Linux never uses C/H/S. The
811d2ecc 199.B C/H/S addressing is deprecated
0d0d12ad 200and may be unsupported in some later fdisk version.
811d2ecc 201
870a6df5 202.B Please, read the DOS-mode section if you want DOS-compatible partitions.
811d2ecc 203.B fdisk
870a6df5 204does not care about cylinder boundaries by default.
811d2ecc
KZ
205.RE
206
870a6df5 207.B BSD/Sun-type
811d2ecc 208.RS
870a6df5 209A BSD/Sun disklabel can describe 8 partitions, the third of which should be a `whole
811d2ecc
KZ
210disk' partition. Do not start a partition that actually uses its first sector
211(like a swap partition) at cylinder 0, since that will destroy the disklabel.
870a6df5 212Note that a
811d2ecc 213.B BSD label
870a6df5 214is usually nested within a DOS partition.
811d2ecc
KZ
215.RE
216
217.B IRIX/SGI-type
218.RS
870a6df5 219An IRIX/SGI disklabel can describe 16 partitions, the eleventh of which should be an entire
811d2ecc
KZ
220`volume' partition, while the ninth should be labeled `volume header'. The
221volume header will also cover the partition table, i.e., it starts at block
222zero and extends by default over five cylinders. The remaining space in the
223volume header may be used by header directory entries. No partitions may
224overlap with the volume header. Also do not change its type or make some
225filesystem on it, since you will lose the partition table. Use this type of
226label only when working with Linux on IRIX/SGI machines or IRIX/SGI disks under
227Linux.
228.RE
229
870a6df5 230A sync() and an ioctl(BLKRRPART) (rereading the partition table from disk)
811d2ecc
KZ
231are performed before exiting when the partition table has been updated.
232
233.SH "DOS mode and DOS 6.x WARNING"
870a6df5
BS
234.B Note that all this is deprecated. You don't have to care about things like
235.B geometry and cylinders on modern operating systems. If you really want
236.B DOS-compatible partitioning then you have to enable DOS mode and cylinder
237.B units by using the '-c=dos -u=cylinders' fdisk command-line options.
811d2ecc
KZ
238
239The DOS 6.x FORMAT command looks for some information in the first sector of
240the data area of the partition, and treats this information as more reliable
241than the information in the partition table. DOS FORMAT expects DOS FDISK to
242clear the first 512 bytes of the data area of a partition whenever a size
243change occurs. DOS FORMAT will look at this extra information even if the /U
244flag is given -- we consider this a bug in DOS FORMAT and DOS FDISK.
245
ba5ad6a4 246The bottom line is that if you use \fBfdisk\fR or \fBcfdisk\fR to change the
870a6df5
BS
247size of a DOS partition table entry, then you must also use
248.BR dd "(1) to " "zero the first 512 bytes"
811d2ecc 249of that partition before using DOS FORMAT to format the partition. For
870a6df5
BS
250example, if you were using \fBfdisk\fR to make a DOS partition table entry for
251/dev/sda1, then (after exiting \fBfdisk\fR and rebooting Linux so that the
811d2ecc
KZ
252partition table information is valid) you would use the command "dd
253if=/dev/zero of=/dev/sda1 bs=512 count=1" to zero the first 512 bytes of the
254partition.
255
256.B fdisk
870a6df5 257usually obtains the disk geometry automatically. This is not necessarily the
811d2ecc 258physical disk geometry (indeed, modern disks do not really have anything like a
870a6df5 259physical geometry, certainly not something that can be described in the simplistic
811d2ecc
KZ
260Cylinders/Heads/Sectors form), but it is the disk geometry that MS-DOS uses for
261the partition table.
262
263Usually all goes well by default, and there are no problems if Linux is the
264only system on the disk. However, if the disk has to be shared with other
265operating systems, it is often a good idea to let an fdisk from another
266operating system make at least one partition. When Linux boots it looks at the
267partition table, and tries to deduce what (fake) geometry is required for good
268cooperation with other systems.
269
270Whenever a partition table is printed out in DOS mode, a consistency check is
271performed on the partition table entries. This check verifies that the
272physical and logical start and end points are identical, and that each
273partition starts and ends on a cylinder boundary (except for the first
274partition).
275
276Some versions of MS-DOS create a first partition which does not begin
277on a cylinder boundary, but on sector 2 of the first cylinder.
278Partitions beginning in cylinder 1 cannot begin on a cylinder boundary, but
279this is unlikely to cause difficulty unless you have OS/2 on your machine.
280
281For best results, you should always use an OS-specific partition table
282program. For example, you should make DOS partitions with the DOS FDISK
870a6df5 283program and Linux partitions with the Linux fdisk or Linux cfdisk programs.
4ffbedba 284.SH COLORS
496c979a 285Implicit coloring can be disabled by an empty file \fI/etc/terminal-colors.d/fdisk.disable\fR.
811d2ecc 286
496c979a
KZ
287See
288.BR terminal-colors.d (5)
289for more details about colorization configuration. The logical color names
290supported by
291.B fdisk
292are:
293.TP
294.B header
295The header of the output tables.
296.TP
297.B help-title
298The help section titles.
299.TP
300.B warn
301The warning messages.
302.TP
303.B welcome
304The welcome message.
4ffbedba 305
811d2ecc
KZ
306.SH AUTHORS
307.MT kzak@redhat.com
308Karel Zak
309.ME
310.br
311.MT dave@gnu.org
312Davidlohr Bueso
313.ME
314.br
315.PP
316The original version was written by
317Andries E. Brouwer, A. V. Le Blanc and others.
318
24505fb2 319.SH ENVIRONMENT
68e422ec
KZ
320.IP LIBFDISK_DEBUG=all
321enables libfdisk debug output.
322.IP LIBBLKID_DEBUG=all
323enables libblkid debug output.
324.IP LIBSMARTCOLS_DEBUG=all
325enables libsmartcols debug output.
24505fb2 326
612721db
KZ
327.SH "SEE ALSO"
328.BR cfdisk (8),
c64061c9 329.BR sfdisk (8),
63cccae4 330.BR mkfs (8),
811d2ecc 331.BR partx (8)
eb2be4fd 332
86d62711 333.SH AVAILABILITY
601d12fb
KZ
334The fdisk command is part of the util-linux package and is available from
335ftp://ftp.kernel.org/pub/linux/utils/util-linux/.