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