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