]> git.ipfire.org Git - thirdparty/util-linux.git/blob - disk-utils/fdisk.8
Imported from util-linux-2.8 tarball.
[thirdparty/util-linux.git] / disk-utils / 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 [\-b] [\-u] [" device ]
9 .sp
10 .BI "fdisk \-l [\-b] [\-u] [" "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 A DOS type partition table can describe an unlimited number
78 of partitions. In sector 0 there is room for the description
79 of 4 partitions (called `primary'). One of these may be an
80 extended partition; this is a box holding logical partitions,
81 with descriptors found in a linked list of sectors, each
82 preceding the corresponding logical partitions.
83 The four primary partitions, present or not, get numbers 1-4.
84 Logical partitions start numbering from 5.
85
86 In a DOS type partition table the starting offset and the size
87 of each partition is stored in two ways: as an absolute number
88 of sectors (given in 32 bits) and as a Cylinders/Heads/Sectors
89 triple (given in 10+8+6 bits). The former is OK - with 512-byte
90 sectors this will work up to 2 TB. The latter has two different
91 problems. First of all, these C/H/S fields can be filled only
92 when the number of heads and the number of sectors per track
93 are known. Secondly, even if we know what these numbers should be,
94 the 24 bits that are available do not suffice.
95 DOS uses C/H/S only, Windows uses both, Linux never uses C/H/S.
96
97 If possible,
98 .B fdisk
99 will obtain the disk geometry automatically. This is not
100 necessarily the physical disk geometry (indeed, modern disks do not
101 really have anything like a physical geometry, certainly not something
102 that can be described in simplistic Cylinders/Heads/Sectors form),
103 but is the disk geometry that MS-DOS uses for the partition table.
104
105 Usually all goes well by default, and there are no problems if
106 Linux is the only system on the disk. However, if the disk has
107 to be shared with other operating systems, it is often a good idea
108 to let an fdisk from another operating system make at least one
109 partition. When Linux boots it looks at the partition table, and
110 tries to deduce what (fake) geometry is required for good
111 cooperation with other systems.
112
113 Whenever a partition table is printed out, a consistency check is performed
114 on the partition table entries. This check verifies that the physical and
115 logical start and end points are identical, and that the partition starts
116 and ends on a cylinder boundary (except for the first partition).
117
118 Some versions of MS-DOS create a first partition which does not begin
119 on a cylinder boundary, but on sector 2 of the first cylinder.
120 Partitions beginning in cylinder 1 cannot begin on a cylinder boundary, but
121 this is unlikely to cause difficulty unless you have OS/2 on your machine.
122
123 A sync() and a BLKRRPART ioctl() (reread partition table from disk)
124 are performed before exiting when the partition table has been updated.
125 Long ago it used to be necessary to reboot after the use of fdisk.
126 I do not think this is the case anymore - indeed, rebooting too quickly
127 might cause loss of not-yet-written data. Note that both the kernel
128 and the disk hardware may buffer data.
129
130 .SH "DOS 6.x WARNING"
131
132 The DOS 6.x FORMAT command looks for some information in the first
133 sector of the data area of the partition, and treats this information
134 as more reliable than the information in the partition table. DOS
135 FORMAT expects DOS FDISK to clear the first 512 bytes of the data area
136 of a partition whenever a size change occurs. DOS FORMAT will look at
137 this extra information even if the /U flag is given -- we consider
138 this a bug in DOS FORMAT and DOS FDISK.
139
140 The bottom line is that if you use cfdisk or fdisk to change the size of a
141 DOS partition table entry, then you must also use
142 .B dd
143 to zero the first 512 bytes of that partition before using DOS FORMAT to
144 format the partition. For example, if you were using cfdisk to make a DOS
145 partition table entry for /dev/hda1, then (after exiting fdisk or cfdisk
146 and rebooting Linux so that the partition table information is valid) you
147 would use the command "dd if=/dev/zero of=/dev/hda1 bs=512 count=1" to zero
148 the first 512 bytes of the partition.
149
150 .B BE EXTREMELY CAREFUL
151 if you use the
152 .B dd
153 command, since a small typo can make all of the data on your disk useless.
154
155 For best results, you should always use an OS-specific partition table
156 program. For example, you should make DOS partitions with the DOS FDISK
157 program and Linux partitions with the Linux fdisk or Linux cfdisk program.
158
159 .SH OPTIONS
160 .TP
161 .B \-v
162 Print version number of
163 .B fdisk
164 program and exit.
165 .TP
166 .B \-l
167 List the partition tables for
168 .BR /dev/hd[a-d] ,
169 .BR /dev/sd[a-h] ,
170 .BR /dev/ed[a-d] ,
171 and then exit.
172 .TP
173 .B \-b
174 When listing partition tables, also output a `Begin' column,
175 as earlier versions of fdisk did by default.
176 (Note: the values in this column, when given in cylinder units,
177 cannot be larger than 1023. There is nothing wrong if Begin and Start
178 differ, at least not as far as Linux is concerned.)
179 .TP
180 .B \-u
181 When listing partition tables, give sizes in sectors instead
182 of cylinders.
183 .TP
184 .BI "\-s " partition
185 The
186 .I size
187 of the partition (in blocks) is printed on the standard output.
188 This value is normally used as an argument to the
189 .BR mkfs (8)
190 program to specify the size of the partition which will be formatted.
191 (Older versions of fdisk would do this only if the partition id is
192 greater than 10, in an attempt to refuse DOS partitions;
193 this test has been deleted.)
194 Note that
195 .B "sfdisk -s"
196 gives different (namely, correct) answers.
197 Reasons for the difference are that the kernel and
198 .B fdisk
199 need not have the same idea about partition numbering
200 (e.g., in case you have BSD slices), and have different
201 ideas about the size of an extended partition.
202 .SH BUGS
203 There are several *fdisk programs around.
204 Each has its problems and strengths.
205 Try them in the order
206 .BR cfdisk ,
207 .BR fdisk ,
208 .BR sfdisk .
209 .\" .SH AUTHORS
210 .\" A. V. Le Blanc (LeBlanc@mcc.ac.uk)
211 .\" Bernhard Fastenrath (fasten@informatik.uni-bonn.de)
212 .\" Jakub Jelinek (jj@sunsite.mff.cuni.cz)
213 .\" and many others.