Imported upstream version 1.5
[manpages-zh.git] / raw / man8 / fdisk.8
blobe1bf9263dee6fa1a6784b7f2a20eb03d8f06a690
1 .\" Copyright 1992, 1993 Rickard E. Faith (faith@cs.unc.edu)
2 .\" Copyright 1998 Andries E. Brouwer (aeb@cwi.nl)
3 .\" May be distributed under the GNU General Public License
4 .TH FDISK 8 "11 June 1998" "Linux 2.0" "Linux Programmer's Manual"
5 .SH NAME
6 fdisk \- Partition table manipulator for Linux
7 .SH SYNOPSIS
8 .BI "fdisk [\-u] [\-b " sectorsize ]
9 .BI "[\-C " cyls "] [\-H " heads "] [\-S " sects "] " device
10 .sp
11 .BI "fdisk \-l [\-u] [" "device ..." ]
12 .sp
13 .BI "fdisk \-s " "partition ..."
14 .sp
15 .BI "fdisk \-v
16 .SH DESCRIPTION
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.
23 In the BSD world one talks about `disk slices' and a `disklabel'.
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.
39 .B fdisk
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.
45 The
46 .I device
47 is usually one of the following:
48 .br
49 .nf
50 .RS
51 /dev/hda
52 /dev/hdb
53 /dev/sda
54 /dev/sdb
55 .RE
56 .fi
57 (/dev/hd[a-h] for IDE disks, /dev/sd[a-p] for SCSI disks,
58 /dev/ed[a-d] for ESDI disks, /dev/xd[ab] for XT disks).
59 A device name refers to the entire disk.
61 The
62 .I partition
63 is a
64 .I device
65 name followed by a partition number.  For example,
66 .B /dev/hda1
67 is the first partition on the first IDE hard disk in the system.
68 Disks can have up to 15 partitions.
69 See also
70 .IR /usr/src/linux/Documentation/devices.txt .
72 A BSD/SUN type disklabel can describe 8 partitions,
73 the third of which should be a `whole disk' partition.
74 Do not start a partition that actually uses its first sector
75 (like a swap partition) at cylinder 0, since that will
76 destroy the disklabel.
78 An IRIX/SGI type disklabel can describe 16 partitions,
79 the eleventh of which should be an entire `volume' partition,
80 while the ninth should be labeled `volume header'.
81 The volume header will also cover the partition table, i.e.,
82 it starts at block zero and extends by default over five cylinders.
83 The remaining space in the volume header may be used by header
84 directory entries.  No partitions may overlap with the volume header.
85 Also do not change its type and make some file system on it, since
86 you will lose the partition table.  Use this type of label only when
87 working with Linux on IRIX/SGI machines or IRIX/SGI disks under Linux.
89 A DOS type partition table can describe an unlimited number
90 of partitions. In sector 0 there is room for the description
91 of 4 partitions (called `primary'). One of these may be an
92 extended partition; this is a box holding logical partitions,
93 with descriptors found in a linked list of sectors, each
94 preceding the corresponding logical partitions.
95 The four primary partitions, present or not, get numbers 1-4.
96 Logical partitions start numbering from 5.
98 In a DOS type partition table the starting offset and the size
99 of each partition is stored in two ways: as an absolute number
100 of sectors (given in 32 bits) and as a Cylinders/Heads/Sectors
101 triple (given in 10+8+6 bits). The former is OK - with 512-byte
102 sectors this will work up to 2 TB. The latter has two different
103 problems. First of all, these C/H/S fields can be filled only
104 when the number of heads and the number of sectors per track
105 are known. Secondly, even if we know what these numbers should be,
106 the 24 bits that are available do not suffice.
107 DOS uses C/H/S only, Windows uses both, Linux never uses C/H/S.
109 If possible,
110 .B fdisk
111 will obtain the disk geometry automatically.  This is not
112 necessarily the physical disk geometry (indeed, modern disks do not
113 really have anything like a physical geometry, certainly not something
114 that can be described in simplistic Cylinders/Heads/Sectors form),
115 but is the disk geometry that MS-DOS uses for the partition table.
117 Usually all goes well by default, and there are no problems if
118 Linux is the only system on the disk. However, if the disk has
119 to be shared with other operating systems, it is often a good idea
120 to let an fdisk from another operating system make at least one
121 partition. When Linux boots it looks at the partition table, and
122 tries to deduce what (fake) geometry is required for good
123 cooperation with other systems.
125 Whenever a partition table is printed out, a consistency check is performed
126 on the partition table entries.  This check verifies that the physical and
127 logical start and end points are identical, and that the partition starts
128 and ends on a cylinder boundary (except for the first partition).
130 Some versions of MS-DOS create a first partition which does not begin
131 on a cylinder boundary, but on sector 2 of the first cylinder.
132 Partitions beginning in cylinder 1 cannot begin on a cylinder boundary, but
133 this is unlikely to cause difficulty unless you have OS/2 on your machine.
135 A sync() and a BLKRRPART ioctl() (reread partition table from disk)
136 are performed before exiting when the partition table has been updated.
137 Long ago it used to be necessary to reboot after the use of fdisk.
138 I do not think this is the case anymore - indeed, rebooting too quickly
139 might cause loss of not-yet-written data. Note that both the kernel
140 and the disk hardware may buffer data.
142 .SH "DOS 6.x WARNING"
144 The DOS 6.x FORMAT command looks for some information in the first
145 sector of the data area of the partition, and treats this information
146 as more reliable than the information in the partition table.  DOS
147 FORMAT expects DOS FDISK to clear the first 512 bytes of the data area
148 of a partition whenever a size change occurs.  DOS FORMAT will look at
149 this extra information even if the /U flag is given -- we consider
150 this a bug in DOS FORMAT and DOS FDISK.
152 The bottom line is that if you use cfdisk or fdisk to change the size of a
153 DOS partition table entry, then you must also use
154 .B dd
155 to zero the first 512 bytes of that partition before using DOS FORMAT to
156 format the partition.  For example, if you were using cfdisk to make a DOS
157 partition table entry for /dev/hda1, then (after exiting fdisk or cfdisk
158 and rebooting Linux so that the partition table information is valid) you
159 would use the command "dd if=/dev/zero of=/dev/hda1 bs=512 count=1" to zero
160 the first 512 bytes of the partition.
162 .B BE EXTREMELY CAREFUL
163 if you use the
164 .B dd
165 command, since a small typo can make all of the data on your disk useless.
167 For best results, you should always use an OS-specific partition table
168 program.  For example, you should make DOS partitions with the DOS FDISK
169 program and Linux partitions with the Linux fdisk or Linux cfdisk program.
171 .SH OPTIONS
173 .BI "\-b " sectorsize
174 Specify the sector size of the disk. Valid values are 512, 1024, or 2048.
175 (Recent kernels know the sector size. Use this only on old kernels or
176 to override the kernel's ideas.)
178 .BI "\-C " cyls
179 Specify the number of cylinders of the disk.
180 I have no idea why anybody would want to do so.
182 .BI "\-H " heads
183 Specify the number of heads of the disk. (Not the physical number,
184 of course, but the number used for partition tables.)
185 Reasonable values are 255 and 16.
187 .BI "\-S " sects
188 Specify the number of sectors per track of the disk.
189 (Not the physical number, of course, but the number used for
190 partition tables.)
191 A reasonable value is 63.
193 .B \-l
194 List the partition tables for the specified devices and then exit.
195 If no devices are given, those mentioned in
196 .I /proc/partitions
197 (if that exists) are used.
199 .B \-u
200 When listing partition tables, give sizes in sectors instead
201 of cylinders.
203 .BI "\-s " partition
205 .I size
206 of the partition (in blocks) is printed on the standard output.
208 .B \-v
209 Print version number of
210 .B fdisk
211 program and exit.
212 .SH BUGS
213 There are several *fdisk programs around.
214 Each has its problems and strengths.
215 Try them in the order
216 .BR cfdisk ,
217 .BR fdisk ,
218 .BR sfdisk .
219 (Indeed,
220 .B cfdisk
221 is a beautiful program that has strict requirements on
222 the partition tables it accepts, and produces high quality partition
223 tables. Use it if you can. 
224 .B fdisk
225 is a buggy program that does fuzzy things - usually it happens to
226 produce reasonable results. Its single advantage is that it has
227 some support for BSD disk labels and other non-DOS partition tables.
228 Avoid it if you can.
229 .B sfdisk
230 is for hackers only - the user interface is terrible, but it is
231 more correct than fdisk and more powerful than both fdisk and cfdisk.
232 Moreover, it can be used noninteractively.)
234 The IRIX/SGI type disklabel is currently not supported by the kernel.
235 Moreover, IRIX/SGI header directories are not fully supported yet.
237 The option `dump partition table to file' is missing.
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)
242 .\" Andreas Neuper (ANeuper@GUUG.de)
243 .\" and many others.
244 .SH "SEE ALSO"
245 .BR cfdisk (8),
246 .BR mkfs (8),
247 .BR parted (8),
248 .BR sfdisk (8)