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