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