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