1FDISK(8) System Administration FDISK(8)
2
3
4
6 fdisk - manipulate disk partition table
7
8
10 fdisk [options] device
11
12 fdisk -l [device...]
13
14
16 fdisk is a dialog-driven program for creation and manipulation of par‐
17 tition tables. It understands GPT, MBR, Sun, SGI and BSD partition
18 tables.
19
20 Block devices can be divided into one or more logical disks called par‐
21 titions. This division is recorded in the partition table, usually
22 found in sector 0 of the disk. (In the BSD world one talks about `disk
23 slices' and a `disklabel'.)
24
25 All partitioning is driven by device I/O limits (the topology) by
26 default. fdisk is able to optimize the disk layout for a 4K-sector
27 size and use an alignment offset on modern devices for MBR and GPT. It
28 is always a good idea to follow fdisk's defaults as the default values
29 (e.g. first and last partition sectors) and partition sizes specified
30 by the +/-<size>{M,G,...} notation are always aligned according to the
31 device properties.
32
33 Note that partx(8) provides a rich interface for scripts to print disk
34 layouts, fdisk is mostly designed for humans. Backward compatibility
35 in the output of fdisk is not guaranteed. The input (the commands)
36 should always be backward compatible.
37
38
40 -b, --sector-size sectorsize
41 Specify the sector size of the disk. Valid values are 512,
42 1024, 2048, and 4096. (Recent kernels know the sector size.
43 Use this option only on old kernels or to override the kernel's
44 ideas.) Since util-linux-2.17, fdisk differentiates between
45 logical and physical sector size. This option changes both sec‐
46 tor sizes to sectorsize.
47
48 -B, --protect-boot
49 Don't erase the begin of the first disk sector when create a new
50 disk label. This feature is supported for GPT and MBR.
51
52 -c, --compatibility[=mode]
53 Specify the compatibility mode, 'dos' or 'nondos'. The default
54 is non-DOS mode. For backward compatibility, it is possible to
55 use the option without the mode argument -- then the default is
56 used. Note that the optional mode argument cannot be separated
57 from the -c option by a space, the correct form is for example
58 '-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,
65 never or always. If the when argument is omitted, it defaults
66 to auto. The colors can be disabled; for the current built-in
67 default see the --help output. See also the COLORS section.
68
69 -l, --list
70 List the partition tables for the specified devices and then
71 exit. If no devices are given, those mentioned in /proc/parti‐
72 tions (if that file exists) are used.
73
74 -o, --output list
75 Specify which output columns to print. Use --help to get a list
76 of all supported columns.
77
78 The default list of columns may be extended if list is specified
79 in the format +list (e.g. -o +UUID).
80
81 -s, --getsz
82 Print the size in 512-byte sectors of each given block device.
83 This option is DEPRECATED in favour of blockdev(1).
84
85 -t, --type type
86 Enable support only for disklabels of the specified type, and
87 disable support for all other types.
88
89 -u, --units[=unit]
90 When listing partition tables, show sizes in 'sectors' or in
91 'cylinders'. The default is to show sizes in sectors. For
92 backward compatibility, it is possible to use the option without
93 the unit argument -- then the default is used. Note that the
94 optional unit argument cannot be separated from the -u option by
95 a space, the correct form is for example '-u=cylinders'.
96
97
98 -C, --cylinders number
99 Specify the number of cylinders of the disk. I have no idea why
100 anybody would want to do so.
101
102 -H, --heads number
103 Specify the number of heads of the disk. (Not the physical num‐
104 ber, of course, but the number used for partition tables.) Rea‐
105 sonable values are 255 and 16.
106
107 -S, --sectors number
108 Specify the number of sectors per track of the disk. (Not the
109 physical number, of course, but the number used for partition
110 tables.) A reasonable value is 63.
111
112
113 -w, --wipe when
114 Wipe filesystem, RAID and partition-table signatures from the
115 device, in order to avoid possible collisions. The argument
116 when can be auto, never or always. When this option is not
117 given, the default is auto, in which case signatures are wiped
118 only when in interactive mode. In all cases detected signatures
119 are reported by warning messages before a new partition table is
120 created. See also wipefs(8) command.
121
122
123 -W, --wipe-partition when
124 Wipe filesystem, RAID and partition-table signatures from a
125 newly created partitions, in order to avoid possible collisions.
126 The argument when can be auto, never or always. When this
127 option is not given, the default is auto, in which case signa‐
128 tures are wiped only when in interactive mode and after confir‐
129 mation by user. In all cases detected signatures are reported
130 by warning messages before a new partition is created. See also
131 wipefs(8) command.
132
133
134 -V, --version
135 Display version information and exit.
136
137
139 The device is usually /dev/sda, /dev/sdb or so. A device name refers
140 to the entire disk. Old systems without libata (a library used inside
141 the Linux kernel to support ATA host controllers and devices) make a
142 difference between IDE and SCSI disks. In such cases the device name
143 will be /dev/hd* (IDE) or /dev/sd* (SCSI).
144
145 The partition is a device name followed by a partition number. For
146 example, /dev/sda1 is the first partition on the first hard disk in the
147 system. See also Linux kernel documentation (the Documenta‐
148 tion/devices.txt file).
149
150
152 The "last sector" dialog accepts partition size specified by number of
153 sectors or by +/-<size>{K,B,M,G,...} notation.
154
155 If the size is prefixed by '+' then it is interpreted as relative to
156 the partition first sector. If the size is prefixed by '-' then it is
157 interpreted as relative to the high limit (last available sector for
158 the partition).
159
160 In the case the size is specified in bytes than the number may be fol‐
161 lowed by the multiplicative suffixes KiB=1024, MiB=1024*1024, and so on
162 for GiB, TiB, PiB, EiB, ZiB and YiB. The "iB" is optional, e.g. "K" has
163 the same meaning as "KiB".
164
165 The relative sizes are always aligned according to device I/O limits.
166 The +/-<size>{K,B,M,G,...} notation is recommended.
167
168 For backward compatibility fdisk also accepts the suffixes KB=1000,
169 MB=1000*1000, and so on for GB, TB, PB, EB, ZB and YB. These 10^N suf‐
170 fixes are deprecated.
171
172
174 fdisk allows to read (by 'I' command) sfdisk compatible script files.
175 The script is applied to in-memory partition table, and then it is pos‐
176 sible to modify the partition table before you write it to the device.
177
178 And vice-versa it is possible to write the current in-memory disk lay‐
179 out to the script file by command 'O'.
180
181 The script files are compatible between cfdisk, sfdisk, fdisk and
182 another libfdisk applications. For more details see sfdisk(8).
183
184
186 GPT (GUID Partition Table)
187 GPT is modern standard for the layout of the partition table.
188 GPT uses 64-bit logical block addresses, checksums, UUIDs and
189 names for partitions and an unlimited number of partitions
190 (although the number of partitions is usually restricted to 128
191 in many partitioning tools).
192
193 Note that the first sector is still reserved for a protective
194 MBR in the GPT specification. It prevents MBR-only partitioning
195 tools from mis-recognizing and overwriting GPT disks.
196
197 GPT is always a better choice than MBR, especially on modern
198 hardware with a UEFI boot loader.
199
200 DOS-type (MBR)
201 A DOS-type partition table can describe an unlimited number of
202 partitions. In sector 0 there is room for the description of 4
203 partitions (called `primary'). One of these may be an extended
204 partition; this is a box holding logical partitions, with
205 descriptors found in a linked list of sectors, each preceding
206 the corresponding logical partitions. The four primary parti‐
207 tions, present or not, get numbers 1-4. Logical partitions are
208 numbered starting from 5.
209
210 In a DOS-type partition table the starting offset and the size
211 of each partition is stored in two ways: as an absolute number
212 of sectors (given in 32 bits), and as a Cylinders/Heads/Sectors
213 triple (given in 10+8+6 bits). The former is OK -- with
214 512-byte sectors this will work up to 2 TB. The latter has two
215 problems. First, these C/H/S fields can be filled only when the
216 number of heads and the number of sectors per track are known.
217 And second, even if we know what these numbers should be, the 24
218 bits that are available do not suffice. DOS uses C/H/S only,
219 Windows uses both, Linux never uses C/H/S. The C/H/S addressing
220 is deprecated and may be unsupported in some later fdisk ver‐
221 sion.
222
223 Please, read the DOS-mode section if you want DOS-compatible
224 partitions. fdisk does not care about cylinder boundaries by
225 default.
226
227 BSD/Sun-type
228 A BSD/Sun disklabel can describe 8 partitions, the third of
229 which should be a `whole disk' partition. Do not start a parti‐
230 tion that actually uses its first sector (like a swap partition)
231 at cylinder 0, since that will destroy the disklabel. Note that
232 a BSD label is usually nested within a DOS partition.
233
234 IRIX/SGI-type
235 An IRIX/SGI disklabel can describe 16 partitions, the eleventh
236 of which should be an entire `volume' partition, while the ninth
237 should be labeled `volume header'. The volume header will also
238 cover the partition table, i.e., it starts at block zero and
239 extends by default over five cylinders. The remaining space in
240 the volume header may be used by header directory entries. No
241 partitions may overlap with the volume header. Also do not
242 change its type or make some filesystem on it, since you will
243 lose the partition table. Use this type of label only when
244 working with Linux on IRIX/SGI machines or IRIX/SGI disks under
245 Linux.
246
247 A sync() and an ioctl(BLKRRPART) (rereading the partition table from
248 disk) are performed before exiting when the partition table has been
249 updated.
250
251
253 Note that all this is deprecated. You don't have to care about things
254 like geometry and cylinders on modern operating systems. If you really
255 want DOS-compatible partitioning then you have to enable DOS mode and
256 cylinder units by using the '-c=dos -u=cylinders' fdisk command-line
257 options.
258
259 The DOS 6.x FORMAT command looks for some information in the first sec‐
260 tor of the data area of the partition, and treats this information as
261 more reliable than the information in the partition table. DOS FORMAT
262 expects DOS FDISK to clear the first 512 bytes of the data area of a
263 partition whenever a size change occurs. DOS FORMAT will look at this
264 extra information even if the /U flag is given -- we consider this a
265 bug in DOS FORMAT and DOS FDISK.
266
267 The bottom line is that if you use fdisk or cfdisk to change the size
268 of a DOS partition table entry, then you must also use dd(1) to zero
269 the first 512 bytes of that partition before using DOS FORMAT to format
270 the partition. For example, if you were using fdisk to make a DOS par‐
271 tition table entry for /dev/sda1, then (after exiting fdisk and reboot‐
272 ing Linux so that the partition table information is valid) you would
273 use the command "dd if=/dev/zero of=/dev/sda1 bs=512 count=1" to zero
274 the first 512 bytes of the partition.
275
276 fdisk usually obtains the disk geometry automatically. This is not
277 necessarily the physical disk geometry (indeed, modern disks do not
278 really have anything like a physical geometry, certainly not something
279 that can be described in the simplistic Cylinders/Heads/Sectors form),
280 but it is the disk geometry that MS-DOS uses for the partition table.
281
282 Usually all goes well by default, and there are no problems if Linux is
283 the only system on the disk. However, if the disk has to be shared
284 with other operating systems, it is often a good idea to let an fdisk
285 from another operating system make at least one partition. When Linux
286 boots it looks at the partition table, and tries to deduce what (fake)
287 geometry is required for good cooperation with other systems.
288
289 Whenever a partition table is printed out in DOS mode, a consistency
290 check is performed on the partition table entries. This check verifies
291 that the physical and logical start and end points are identical, and
292 that each partition starts and ends on a cylinder boundary (except for
293 the first partition).
294
295 Some versions of MS-DOS create a first partition which does not begin
296 on a cylinder boundary, but on sector 2 of the first cylinder. Parti‐
297 tions beginning in cylinder 1 cannot begin on a cylinder boundary, but
298 this is unlikely to cause difficulty unless you have OS/2 on your
299 machine.
300
301 For best results, you should always use an OS-specific partition table
302 program. For example, you should make DOS partitions with the DOS
303 FDISK program and Linux partitions with the Linux fdisk or Linux cfdisk
304 programs.
305
307 Implicit coloring can be disabled by an empty file /etc/terminal-col‐
308 ors.d/fdisk.disable.
309
310 See terminal-colors.d(5) for more details about colorization configura‐
311 tion. The logical color names supported by fdisk are:
312
313 header The header of the output tables.
314
315 help-title
316 The help section titles.
317
318 warn The warning messages.
319
320 welcome
321 The welcome message.
322
323
325 Karel Zak ⟨kzak@redhat.com⟩
326 Davidlohr Bueso ⟨dave@gnu.org⟩
327
328 The original version was written by Andries E. Brouwer, A. V. Le Blanc
329 and others.
330
331
333 FDISK_DEBUG=all
334 enables fdisk debug output.
335
336 LIBFDISK_DEBUG=all
337 enables libfdisk debug output.
338
339 LIBBLKID_DEBUG=all
340 enables libblkid debug output.
341
342 LIBSMARTCOLS_DEBUG=all
343 enables libsmartcols debug output.
344
345 LIBSMARTCOLS_DEBUG_PADDING=on
346 use visible padding characters. Requires enabled LIBSMART‐
347 COLS_DEBUG.
348
349
351 cfdisk(8), mkfs(8), partx(8), sfdisk(8)
352
353
355 The fdisk command is part of the util-linux package and is available
356 from https://www.kernel.org/pub/linux/utils/util-linux/.
357
358
359
360util-linux February 2016 FDISK(8)