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