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