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