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