]>
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> |
6dbe3af9 | 4 | .\" May be distributed under the GNU General Public License |
6efb4b12 | 5 | .TH FDISK 8 "June 2012" "util-linux" "System Administration" |
6dbe3af9 | 6 | .SH NAME |
232dc924 | 7 | fdisk \- manipulate disk partition table |
6dbe3af9 | 8 | .SH SYNOPSIS |
57bc4707 | 9 | .B fdisk |
78498b7b | 10 | .RB [ \-uc ] |
57bc4707 PB |
11 | .RB [ \-b |
12 | .IR sectorsize ] | |
13 | .RB [ \-C | |
14 | .IR cyls ] | |
15 | .RB [ \-H | |
16 | .IR heads ] | |
17 | .RB [ \-S | |
18 | .IR sects ] | |
19 | .I device | |
2b6fc908 | 20 | .sp |
57bc4707 PB |
21 | .B fdisk \-l |
22 | .RB [ \-u ] | |
23 | .RI [ device ...] | |
2b6fc908 | 24 | .sp |
57bc4707 PB |
25 | .B fdisk \-s |
26 | .IR partition ... | |
2b6fc908 | 27 | .sp |
57bc4707 | 28 | .B fdisk \-v |
3b19e88d KZ |
29 | .sp |
30 | .B fdisk \-h | |
6dbe3af9 | 31 | .SH DESCRIPTION |
278f63c0 KZ |
32 | .B fdisk |
33 | (in the first form of invocation) | |
a1939d70 | 34 | is a menu-driven program for creation and manipulation of |
278f63c0 | 35 | partition tables. |
a1939d70 | 36 | It understands DOS-type partition tables and BSD- or SUN-type disklabels. |
278f63c0 KZ |
37 | |
38 | .B fdisk | |
a1939d70 BS |
39 | does not understand GUID partition tables (GPTs) and it is not designed |
40 | for large partitions. In these cases, use the more advanced GNU | |
278f63c0 KZ |
41 | .BR parted (8). |
42 | ||
a1939d70 BS |
43 | .B fdisk |
44 | does not use DOS-compatible mode and cylinders as display units by default. | |
45 | The old deprecated DOS behavior can be enabled with | |
46 | the '-c=dos -u=cylinders' command-line options. | |
278f63c0 | 47 | |
2b6fc908 KZ |
48 | Hard disks can be divided into one or more logical disks called |
49 | .IR partitions . | |
a1939d70 BS |
50 | This division is recorded in the |
51 | .IR "partition table" , | |
2b6fc908 | 52 | found in sector 0 of the disk. |
a1939d70 | 53 | (In the BSD world one talks about `disk slices' and a `disklabel'.) |
2b6fc908 KZ |
54 | |
55 | Linux needs at least one partition, namely for its root file system. | |
56 | It can use swap files and/or swap partitions, but the latter are more | |
a1939d70 | 57 | efficient. So, usually one will want a second Linux partition |
2b6fc908 | 58 | dedicated as swap partition. |
a1939d70 | 59 | On Intel-compatible hardware, the BIOS that boots the system |
2b6fc908 KZ |
60 | can often only access the first 1024 cylinders of the disk. |
61 | For this reason people with large disks often create a third partition, | |
62 | just a few MB large, typically mounted on | |
63 | .IR /boot , | |
64 | to store the kernel image and a few auxiliary files needed at boot time, | |
65 | so as to make sure that this stuff is accessible to the BIOS. | |
66 | There may be reasons of security, ease of administration and backup, | |
67 | or testing, to use more than the minimum number of partitions. | |
68 | ||
278f63c0 | 69 | .SH DEVICES |
6dbe3af9 KZ |
70 | The |
71 | .I device | |
a1939d70 BS |
72 | is usually /dev/sda, /dev/sdb or so. A device name refers to the entire disk. |
73 | Old systems without libata (a library used inside the Linux kernel to | |
d92026e4 | 74 | support ATA host controllers and devices) make a difference between IDE and |
a1939d70 | 75 | SCSI disks. In such cases the device name will be /dev/hd* (IDE) or /dev/sd* |
d92026e4 | 76 | (SCSI). |
2b6fc908 | 77 | |
6dbe3af9 KZ |
78 | The |
79 | .I partition | |
a1939d70 | 80 | is a device name followed by a partition number. For example, /dev/sda1 |
d92026e4 KZ |
81 | is the first partition on the first hard disk in the system. |
82 | See also Linux kernel documentation (the Documentation/devices.txt file). | |
2b6fc908 | 83 | |
278f63c0 | 84 | .SH DISK LABELS |
a1939d70 | 85 | A BSD/SUN-type disklabel can describe 8 partitions, |
2b6fc908 KZ |
86 | the third of which should be a `whole disk' partition. |
87 | Do not start a partition that actually uses its first sector | |
88 | (like a swap partition) at cylinder 0, since that will | |
89 | destroy the disklabel. | |
90 | ||
a1939d70 | 91 | An IRIX/SGI-type disklabel can describe 16 partitions, |
5c36a0eb KZ |
92 | the eleventh of which should be an entire `volume' partition, |
93 | while the ninth should be labeled `volume header'. | |
94 | The volume header will also cover the partition table, i.e., | |
95 | it starts at block zero and extends by default over five cylinders. | |
96 | The remaining space in the volume header may be used by header | |
97 | directory entries. No partitions may overlap with the volume header. | |
a1939d70 | 98 | Also do not change its type or make some filesystem on it, since |
5c36a0eb KZ |
99 | you will lose the partition table. Use this type of label only when |
100 | working with Linux on IRIX/SGI machines or IRIX/SGI disks under Linux. | |
101 | ||
a1939d70 BS |
102 | A DOS-type partition table can describe an unlimited number |
103 | of partitions. In sector 0 there is room for the description | |
104 | of 4 partitions (called `primary'). One of these may be an | |
2b6fc908 KZ |
105 | extended partition; this is a box holding logical partitions, |
106 | with descriptors found in a linked list of sectors, each | |
107 | preceding the corresponding logical partitions. | |
108 | The four primary partitions, present or not, get numbers 1-4. | |
109 | Logical partitions start numbering from 5. | |
110 | ||
a1939d70 | 111 | In a DOS-type partition table the starting offset and the size |
2b6fc908 | 112 | of each partition is stored in two ways: as an absolute number |
a1939d70 BS |
113 | of sectors (given in 32 bits), and as a Cylinders/Heads/Sectors |
114 | triple (given in 10+8+6 bits). The former is OK -- with 512-byte | |
115 | sectors this will work up to 2 TB. The latter has two | |
116 | problems. First, these C/H/S fields can be filled only | |
2b6fc908 | 117 | when the number of heads and the number of sectors per track |
a1939d70 | 118 | are known. And second, even if we know what these numbers should be, |
2b6fc908 KZ |
119 | the 24 bits that are available do not suffice. |
120 | DOS uses C/H/S only, Windows uses both, Linux never uses C/H/S. | |
6dbe3af9 KZ |
121 | |
122 | If possible, | |
123 | .B fdisk | |
2b6fc908 KZ |
124 | will obtain the disk geometry automatically. This is not |
125 | necessarily the physical disk geometry (indeed, modern disks do not | |
126 | really have anything like a physical geometry, certainly not something | |
127 | that can be described in simplistic Cylinders/Heads/Sectors form), | |
a1939d70 | 128 | but it is the disk geometry that MS-DOS uses for the partition table. |
2b6fc908 KZ |
129 | |
130 | Usually all goes well by default, and there are no problems if | |
a1939d70 | 131 | Linux is the only system on the disk. However, if the disk has |
2b6fc908 KZ |
132 | to be shared with other operating systems, it is often a good idea |
133 | to let an fdisk from another operating system make at least one | |
a1939d70 | 134 | partition. When Linux boots it looks at the partition table, and |
2b6fc908 KZ |
135 | tries to deduce what (fake) geometry is required for good |
136 | cooperation with other systems. | |
6dbe3af9 KZ |
137 | |
138 | Whenever a partition table is printed out, a consistency check is performed | |
139 | on the partition table entries. This check verifies that the physical and | |
a1939d70 | 140 | logical start and end points are identical, and that each partition starts |
6dbe3af9 KZ |
141 | and ends on a cylinder boundary (except for the first partition). |
142 | ||
6dbe3af9 KZ |
143 | Some versions of MS-DOS create a first partition which does not begin |
144 | on a cylinder boundary, but on sector 2 of the first cylinder. | |
145 | Partitions beginning in cylinder 1 cannot begin on a cylinder boundary, but | |
146 | this is unlikely to cause difficulty unless you have OS/2 on your machine. | |
147 | ||
a1939d70 | 148 | A sync() and an ioctl(BLKRRPART) (reread partition table from disk) |
2b6fc908 KZ |
149 | are performed before exiting when the partition table has been updated. |
150 | Long ago it used to be necessary to reboot after the use of fdisk. | |
a1939d70 BS |
151 | I do not think this is the case anymore -- indeed, rebooting too quickly |
152 | might cause loss of not-yet-written data. Note that both the kernel | |
2b6fc908 | 153 | and the disk hardware may buffer data. |
6dbe3af9 KZ |
154 | |
155 | .SH "DOS 6.x WARNING" | |
156 | ||
157 | The DOS 6.x FORMAT command looks for some information in the first | |
158 | sector of the data area of the partition, and treats this information | |
159 | as more reliable than the information in the partition table. DOS | |
160 | FORMAT expects DOS FDISK to clear the first 512 bytes of the data area | |
161 | of a partition whenever a size change occurs. DOS FORMAT will look at | |
162 | this extra information even if the /U flag is given -- we consider | |
163 | this a bug in DOS FORMAT and DOS FDISK. | |
164 | ||
165 | The bottom line is that if you use cfdisk or fdisk to change the size of a | |
166 | DOS partition table entry, then you must also use | |
167 | .B dd | |
168 | to zero the first 512 bytes of that partition before using DOS FORMAT to | |
169 | format the partition. For example, if you were using cfdisk to make a DOS | |
d92026e4 | 170 | partition table entry for /dev/sda1, then (after exiting fdisk or cfdisk |
6dbe3af9 | 171 | and rebooting Linux so that the partition table information is valid) you |
d92026e4 | 172 | would use the command "dd if=/dev/zero of=/dev/sda1 bs=512 count=1" to zero |
6dbe3af9 | 173 | the first 512 bytes of the partition. |
6dbe3af9 KZ |
174 | |
175 | .B BE EXTREMELY CAREFUL | |
176 | if you use the | |
177 | .B dd | |
178 | command, since a small typo can make all of the data on your disk useless. | |
179 | ||
fd6b7a7f | 180 | For best results, you should always use an OS-specific partition table |
6dbe3af9 KZ |
181 | program. For example, you should make DOS partitions with the DOS FDISK |
182 | program and Linux partitions with the Linux fdisk or Linux cfdisk program. | |
183 | ||
184 | .SH OPTIONS | |
185 | .TP | |
22853e4a | 186 | .BI "\-b " sectorsize |
a1939d70 BS |
187 | Specify the sector size of the disk. Valid values are 512, 1024, 2048 or 4096. |
188 | (Recent kernels know the sector size. Use this only on old kernels or | |
601d12fb | 189 | to override the kernel's ideas.) Since util-linux-2.17, fdisk differentiates |
a1939d70 | 190 | between logical and physical sector size. This option changes both sector sizes to |
7f152745 | 191 | .IB sectorsize . |
6dbe3af9 | 192 | .TP |
278f63c0 | 193 | .BI "\-c"[=mode] |
455fe9a0 | 194 | Specify the compatibility mode, 'dos' or 'nondos'. The default is non-DOS |
a1939d70 BS |
195 | mode. For backward compatibility, it is possible to use the option without |
196 | the <mode> argument -- then the default is used. Note that the optional | |
197 | <mode> argument cannot be separated from the -c option by a space, the correct | |
6efb4b12 | 198 | form is for example '-c=dos'. This option is DEPRECATED. |
78498b7b | 199 | .TP |
0e6f4a20 KZ |
200 | .BI "\-C " cyls |
201 | Specify the number of cylinders of the disk. | |
6efb4b12 | 202 | I have no idea why anybody would want to do so. This option is DEPRECATED. |
0e6f4a20 KZ |
203 | .TP |
204 | .BI "\-H " heads | |
a1939d70 | 205 | Specify the number of heads of the disk. (Not the physical number, |
0e6f4a20 | 206 | of course, but the number used for partition tables.) |
6efb4b12 | 207 | Reasonable values are 255 and 16. This option is DEPRECATED. |
0e6f4a20 KZ |
208 | .TP |
209 | .BI "\-S " sects | |
210 | Specify the number of sectors per track of the disk. | |
211 | (Not the physical number, of course, but the number used for | |
212 | partition tables.) | |
6efb4b12 | 213 | A reasonable value is 63. This option is DEPRECATED. |
0e6f4a20 | 214 | .TP |
a1939d70 BS |
215 | .BI \-h |
216 | Print help and then exit. | |
217 | .TP | |
6dbe3af9 | 218 | .B \-l |
eb63b9b8 KZ |
219 | List the partition tables for the specified devices and then exit. |
220 | If no devices are given, those mentioned in | |
221 | .I /proc/partitions | |
222 | (if that exists) are used. | |
6dbe3af9 | 223 | .TP |
a1939d70 BS |
224 | .BI "\-s " partition... |
225 | Print the size (in blocks) of each given partition. | |
2b6fc908 | 226 | .TP |
a1939d70 BS |
227 | .BI "\-u"[=unit] |
228 | When listing partition tables, show sizes in 'sectors' or in 'cylinders'. The | |
229 | default is to show sizes in sectors. For backward compatibility, it is possible | |
230 | to use the option without the <units> argument -- then the default is used. | |
231 | Note that the optional <unit> argument cannot be separated from the -u option | |
232 | by a space, the correct form is for example '-u=cylinders'. | |
22853e4a KZ |
233 | .TP |
234 | .B \-v | |
235 | Print version number of | |
236 | .B fdisk | |
237 | program and exit. | |
2b6fc908 KZ |
238 | .SH BUGS |
239 | There are several *fdisk programs around. | |
240 | Each has its problems and strengths. | |
241 | Try them in the order | |
242 | .BR cfdisk , | |
243 | .BR fdisk , | |
244 | .BR sfdisk . | |
7eda085c KZ |
245 | (Indeed, |
246 | .B cfdisk | |
247 | is a beautiful program that has strict requirements on | |
248 | the partition tables it accepts, and produces high quality partition | |
a1939d70 | 249 | tables. Use it if you can. |
7eda085c KZ |
250 | .B fdisk |
251 | is a buggy program that does fuzzy things - usually it happens to | |
a1939d70 | 252 | produce reasonable results. Its single advantage is that it has |
7eda085c KZ |
253 | some support for BSD disk labels and other non-DOS partition tables. |
254 | Avoid it if you can. | |
255 | .B sfdisk | |
a1939d70 | 256 | is for hackers only -- the user interface is terrible, but it is |
7eda085c KZ |
257 | more correct than fdisk and more powerful than both fdisk and cfdisk. |
258 | Moreover, it can be used noninteractively.) | |
5c36a0eb | 259 | .PP |
09b2d37a PU |
260 | There also is |
261 | .BR parted | |
262 | which supports many types of different partition table formats. | |
d03dd608 | 263 | .PP |
a1939d70 | 264 | The IRIX/SGI-type disklabel is currently not supported by the kernel. |
5c36a0eb KZ |
265 | Moreover, IRIX/SGI header directories are not fully supported yet. |
266 | .PP | |
267 | The option `dump partition table to file' is missing. | |
2b6fc908 KZ |
268 | .\" .SH AUTHORS |
269 | .\" A. V. Le Blanc (LeBlanc@mcc.ac.uk) | |
270 | .\" Bernhard Fastenrath (fasten@informatik.uni-bonn.de) | |
271 | .\" Jakub Jelinek (jj@sunsite.mff.cuni.cz) | |
5c36a0eb | 272 | .\" Andreas Neuper (ANeuper@GUUG.de) |
2b6fc908 | 273 | .\" and many others. |
612721db KZ |
274 | .SH "SEE ALSO" |
275 | .BR cfdisk (8), | |
c64061c9 | 276 | .BR sfdisk (8), |
63cccae4 | 277 | .BR mkfs (8), |
612721db | 278 | .BR parted (8), |
c64061c9 VD |
279 | .BR partprobe (8), |
280 | .BR kpartx (8) | |
86d62711 | 281 | .SH AVAILABILITY |
601d12fb KZ |
282 | The fdisk command is part of the util-linux package and is available from |
283 | ftp://ftp.kernel.org/pub/linux/utils/util-linux/. |