]>
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 |
811d2ecc | 6 | .TH FDISK 8 "September 2013" "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 |
811d2ecc | 13 | .RB [ 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 | |
811d2ecc | 35 | as the default values (e.g. first and last partition sectors) and partition |
870a6df5 | 36 | sizes specified by the +<size>{M,G,...} notation are always aligned according |
811d2ecc | 37 | to the device properties. |
6dbe3af9 | 38 | |
811d2ecc | 39 | Note that |
870a6df5 BS |
40 | .BR partx (8) |
41 | provides a rich interface for scripts to print disk layouts, | |
42 | .B fdisk | |
43 | is mostly designed for humans. Backward compatibility in the output of | |
811d2ecc | 44 | .B fdisk |
870a6df5 | 45 | is not guaranteed. The input (the commands) should always be backward compatible. |
6dbe3af9 KZ |
46 | |
47 | .SH OPTIONS | |
48 | .TP | |
22853e4a | 49 | .BI "\-b " sectorsize |
870a6df5 BS |
50 | Specify the sector size of the disk. Valid values are 512, 1024, 2048, and 4096. |
51 | (Recent kernels know the sector size. Use this option only on old kernels or | |
eb2be4fd | 52 | to override the kernel's ideas.) Since util-linux-2.17, \fBfdisk\fR differentiates |
a1939d70 | 53 | between logical and physical sector size. This option changes both sector sizes to |
7f152745 | 54 | .IB sectorsize . |
6dbe3af9 | 55 | .TP |
870a6df5 | 56 | .BR "\-c"[=\fImode\fR] |
455fe9a0 | 57 | Specify the compatibility mode, 'dos' or 'nondos'. The default is non-DOS |
a1939d70 | 58 | mode. For backward compatibility, it is possible to use the option without |
eb2be4fd BS |
59 | the \fImode\fR argument -- then the default is used. Note that the optional |
60 | \fImode\fR argument cannot be separated from the \fB-c\fR option by a space, | |
61 | the correct form is for example '-c=dos'. This option is DEPRECATED. | |
78498b7b | 62 | .TP |
eb2be4fd | 63 | .BI "\-C " cylinders |
0e6f4a20 | 64 | Specify the number of cylinders of the disk. |
eb2be4fd | 65 | I have no idea why anybody would want to do so. This option is DEPRECATED. |
0e6f4a20 KZ |
66 | .TP |
67 | .BI "\-H " heads | |
a1939d70 | 68 | Specify the number of heads of the disk. (Not the physical number, |
0e6f4a20 | 69 | of course, but the number used for partition tables.) |
eb2be4fd | 70 | Reasonable values are 255 and 16. This option is DEPRECATED. |
0e6f4a20 | 71 | .TP |
eb2be4fd | 72 | .BI "\-S " sectors |
0e6f4a20 KZ |
73 | Specify the number of sectors per track of the disk. |
74 | (Not the physical number, of course, but the number used for | |
75 | partition tables.) | |
eb2be4fd | 76 | A reasonable value is 63. This option is DEPRECATED. |
0e6f4a20 | 77 | .TP |
a1939d70 | 78 | .BI \-h |
eb2be4fd | 79 | Display a help text and exit. |
a1939d70 | 80 | .TP |
870a6df5 BS |
81 | .BR "\-L"[=\fIwhen\fR] |
82 | Colorize the output in interactive mode. The optional argument \fIwhen\fP can | |
83 | be \fBauto\fR, \fBnever\fR or \fBalways\fR. The default is \fBauto\fR. | |
80a1712f | 84 | .TP |
6dbe3af9 | 85 | .B \-l |
eb63b9b8 KZ |
86 | List the partition tables for the specified devices and then exit. |
87 | If no devices are given, those mentioned in | |
88 | .I /proc/partitions | |
870a6df5 | 89 | (if that file exists) are used. |
6dbe3af9 | 90 | .TP |
a1939d70 | 91 | .BI "\-s " partition... |
870a6df5 | 92 | Print the size (in blocks) of each given partition. This option is DEPRECATED |
9564e46c | 93 | in favour of |
870a6df5 | 94 | .BR blockdev (1). |
2b6fc908 | 95 | .TP |
565b7da6 | 96 | .BI "\-t " type |
870a6df5 BS |
97 | Enable support only for disklabels of the specified \fItype\fP, and disable |
98 | support for all other types. | |
99 | This is necessary for example to access a protective or hybrid MBR on devices | |
565b7da6 KZ |
100 | with GPT. |
101 | .TP | |
870a6df5 | 102 | .BR "\-u"[=\fIunit\fR] |
a1939d70 BS |
103 | When listing partition tables, show sizes in 'sectors' or in 'cylinders'. The |
104 | default is to show sizes in sectors. For backward compatibility, it is possible | |
eb2be4fd BS |
105 | to use the option without the \fIunit\fR argument -- then the default is used. |
106 | Note that the optional \fIunit\fR argument cannot be separated from the \fB-u\fR | |
107 | option by a space, the correct form is for example '-u=cylinders'. | |
22853e4a KZ |
108 | .TP |
109 | .B \-v | |
eb2be4fd | 110 | Display version information and exit. |
24505fb2 | 111 | |
811d2ecc KZ |
112 | .SH DEVICES |
113 | The | |
114 | .I device | |
115 | is usually /dev/sda, /dev/sdb or so. A device name refers to the entire disk. | |
116 | Old systems without libata (a library used inside the Linux kernel to support | |
117 | ATA host controllers and devices) make a difference between IDE and SCSI disks. | |
118 | In such cases the device name will be /dev/hd* (IDE) or /dev/sd* (SCSI). | |
119 | ||
120 | The | |
121 | .I partition | |
122 | is a device name followed by a partition number. For example, /dev/sda1 is the | |
123 | first partition on the first hard disk in the system. See also Linux kernel | |
124 | documentation (the Documentation/devices.txt file). | |
125 | ||
126 | .SH DISK LABELS | |
127 | .B GPT (GUID Partition Table) | |
128 | .RS | |
870a6df5 BS |
129 | GPT is modern standard for the layout of the partition table. GPT uses 64-bit |
130 | logical block addresses, checksums, UUIDs and names for partitions and an | |
131 | unlimited number of partitions (although the number of partitions is | |
811d2ecc KZ |
132 | usually restricted to 128 in many partitioning tools). |
133 | ||
134 | Note that the first sector is still reserved for a | |
135 | .B protective MBR | |
870a6df5 BS |
136 | in the GPT specification. It prevents MBR-only partitioning tools |
137 | from mis-recognizing and overwriting GPT disks. | |
811d2ecc | 138 | |
870a6df5 | 139 | GPT is always a better choice than MBR, especially on modern hardware with a UEFI |
811d2ecc KZ |
140 | boot loader. |
141 | .RE | |
142 | ||
143 | .B DOS-type (MBR) | |
144 | .RS | |
870a6df5 | 145 | A DOS-type partition table can describe an unlimited number of partitions. In sector 0 |
811d2ecc KZ |
146 | there is room for the description of 4 partitions (called `primary'). One of |
147 | these may be an extended partition; this is a box holding logical partitions, | |
148 | with descriptors found in a linked list of sectors, each preceding the | |
149 | corresponding logical partitions. The four primary partitions, present or not, | |
870a6df5 | 150 | get numbers 1-4. Logical partitions are numbered starting from 5. |
811d2ecc KZ |
151 | |
152 | In a DOS-type partition table the starting offset and the size of each | |
153 | partition is stored in two ways: as an absolute number of sectors (given in 32 | |
154 | bits), and as a | |
155 | .B Cylinders/Heads/Sectors | |
156 | triple (given in 10+8+6 bits). The former is OK -- with 512-byte sectors this | |
157 | will work up to 2 TB. The latter has two problems. First, these C/H/S fields | |
158 | can be filled only when the number of heads and the number of sectors per track | |
159 | are known. And second, even if we know what these numbers should be, the 24 | |
160 | bits that are available do not suffice. DOS uses C/H/S only, Windows uses | |
870a6df5 | 161 | both, Linux never uses C/H/S. The |
811d2ecc | 162 | .B C/H/S addressing is deprecated |
0d0d12ad | 163 | and may be unsupported in some later fdisk version. |
811d2ecc | 164 | |
870a6df5 | 165 | .B Please, read the DOS-mode section if you want DOS-compatible partitions. |
811d2ecc | 166 | .B fdisk |
870a6df5 | 167 | does not care about cylinder boundaries by default. |
811d2ecc KZ |
168 | .RE |
169 | ||
870a6df5 | 170 | .B BSD/Sun-type |
811d2ecc | 171 | .RS |
870a6df5 | 172 | A BSD/Sun disklabel can describe 8 partitions, the third of which should be a `whole |
811d2ecc KZ |
173 | disk' partition. Do not start a partition that actually uses its first sector |
174 | (like a swap partition) at cylinder 0, since that will destroy the disklabel. | |
870a6df5 | 175 | Note that a |
811d2ecc | 176 | .B BSD label |
870a6df5 | 177 | is usually nested within a DOS partition. |
811d2ecc KZ |
178 | .RE |
179 | ||
180 | .B IRIX/SGI-type | |
181 | .RS | |
870a6df5 | 182 | An IRIX/SGI disklabel can describe 16 partitions, the eleventh of which should be an entire |
811d2ecc KZ |
183 | `volume' partition, while the ninth should be labeled `volume header'. The |
184 | volume header will also cover the partition table, i.e., it starts at block | |
185 | zero and extends by default over five cylinders. The remaining space in the | |
186 | volume header may be used by header directory entries. No partitions may | |
187 | overlap with the volume header. Also do not change its type or make some | |
188 | filesystem on it, since you will lose the partition table. Use this type of | |
189 | label only when working with Linux on IRIX/SGI machines or IRIX/SGI disks under | |
190 | Linux. | |
191 | .RE | |
192 | ||
870a6df5 | 193 | A sync() and an ioctl(BLKRRPART) (rereading the partition table from disk) |
811d2ecc KZ |
194 | are performed before exiting when the partition table has been updated. |
195 | ||
196 | .SH "DOS mode and DOS 6.x WARNING" | |
870a6df5 BS |
197 | .B Note that all this is deprecated. You don't have to care about things like |
198 | .B geometry and cylinders on modern operating systems. If you really want | |
199 | .B DOS-compatible partitioning then you have to enable DOS mode and cylinder | |
200 | .B units by using the '-c=dos -u=cylinders' fdisk command-line options. | |
811d2ecc KZ |
201 | |
202 | The DOS 6.x FORMAT command looks for some information in the first sector of | |
203 | the data area of the partition, and treats this information as more reliable | |
204 | than the information in the partition table. DOS FORMAT expects DOS FDISK to | |
205 | clear the first 512 bytes of the data area of a partition whenever a size | |
206 | change occurs. DOS FORMAT will look at this extra information even if the /U | |
207 | flag is given -- we consider this a bug in DOS FORMAT and DOS FDISK. | |
208 | ||
870a6df5 BS |
209 | The bottom line is that if you use \fBfdisk\fR or \fBcfdisk\R to change the |
210 | size of a DOS partition table entry, then you must also use | |
211 | .BR dd "(1) to " "zero the first 512 bytes" | |
811d2ecc | 212 | of that partition before using DOS FORMAT to format the partition. For |
870a6df5 BS |
213 | example, if you were using \fBfdisk\fR to make a DOS partition table entry for |
214 | /dev/sda1, then (after exiting \fBfdisk\fR and rebooting Linux so that the | |
811d2ecc KZ |
215 | partition table information is valid) you would use the command "dd |
216 | if=/dev/zero of=/dev/sda1 bs=512 count=1" to zero the first 512 bytes of the | |
217 | partition. | |
218 | ||
219 | .B fdisk | |
870a6df5 | 220 | usually obtains the disk geometry automatically. This is not necessarily the |
811d2ecc | 221 | physical disk geometry (indeed, modern disks do not really have anything like a |
870a6df5 | 222 | physical geometry, certainly not something that can be described in the simplistic |
811d2ecc KZ |
223 | Cylinders/Heads/Sectors form), but it is the disk geometry that MS-DOS uses for |
224 | the partition table. | |
225 | ||
226 | Usually all goes well by default, and there are no problems if Linux is the | |
227 | only system on the disk. However, if the disk has to be shared with other | |
228 | operating systems, it is often a good idea to let an fdisk from another | |
229 | operating system make at least one partition. When Linux boots it looks at the | |
230 | partition table, and tries to deduce what (fake) geometry is required for good | |
231 | cooperation with other systems. | |
232 | ||
233 | Whenever a partition table is printed out in DOS mode, a consistency check is | |
234 | performed on the partition table entries. This check verifies that the | |
235 | physical and logical start and end points are identical, and that each | |
236 | partition starts and ends on a cylinder boundary (except for the first | |
237 | partition). | |
238 | ||
239 | Some versions of MS-DOS create a first partition which does not begin | |
240 | on a cylinder boundary, but on sector 2 of the first cylinder. | |
241 | Partitions beginning in cylinder 1 cannot begin on a cylinder boundary, but | |
242 | this is unlikely to cause difficulty unless you have OS/2 on your machine. | |
243 | ||
244 | For best results, you should always use an OS-specific partition table | |
245 | program. For example, you should make DOS partitions with the DOS FDISK | |
870a6df5 | 246 | program and Linux partitions with the Linux fdisk or Linux cfdisk programs. |
811d2ecc KZ |
247 | |
248 | .SH AUTHORS | |
249 | .MT kzak@redhat.com | |
250 | Karel Zak | |
251 | .ME | |
252 | .br | |
253 | .MT dave@gnu.org | |
254 | Davidlohr Bueso | |
255 | .ME | |
256 | .br | |
257 | .PP | |
258 | The original version was written by | |
259 | Andries E. Brouwer, A. V. Le Blanc and others. | |
260 | ||
24505fb2 | 261 | .SH ENVIRONMENT |
811d2ecc | 262 | .IP "Setting LIBFDISK_DEBUG=0xffff enables debug output." |
24505fb2 | 263 | |
612721db KZ |
264 | .SH "SEE ALSO" |
265 | .BR cfdisk (8), | |
c64061c9 | 266 | .BR sfdisk (8), |
63cccae4 | 267 | .BR mkfs (8), |
811d2ecc | 268 | .BR partx (8) |
eb2be4fd | 269 | |
86d62711 | 270 | .SH AVAILABILITY |
601d12fb KZ |
271 | The fdisk command is part of the util-linux package and is available from |
272 | ftp://ftp.kernel.org/pub/linux/utils/util-linux/. |