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"
6 fdisk \- Partition table manipulator for Linux
8 .BI "fdisk [\-u] " device
10 .BI "fdisk \-l [\-u] " "device ..."
12 .BI "fdisk \-s " "partition ..."
16 Hard disks can be divided into one or more logical disks called
18 This division is described in the
20 found in sector 0 of the disk.
22 In the BSD world one talks about `disk slices' and a `disklabel'.
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
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.
39 (in the first form of invocation)
40 is a menu driven program for creation and manipulation of
42 It understands DOS type partition tables and BSD or SUN type disklabels.
46 is usually one of the following:
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.
64 name followed by a partition number. For example,
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.
69 .IR /usr/src/linux/Documentation/devices.txt .
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.
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.
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.
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.
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.
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.
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).
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.
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.
141 .SH "DOS 6.x WARNING"
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.
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
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.
161 .B BE EXTREMELY CAREFUL
164 command, since a small typo can make all of the data on your disk useless.
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.
173 Print version number of
178 List the partition tables for
185 When listing partition tables, give sizes in sectors instead
191 of the partition (in blocks) is printed on the standard output.
193 There are several *fdisk programs around.
194 Each has its problems and strengths.
195 Try them in the order
201 is a beautiful program that has strict requirements on
202 the partition tables it accepts, and produces high quality partition
203 tables. Use it if you can.
205 is a buggy program that does fuzzy things - usually it happens to
206 produce reasonable results. Its single advantage is that it has
207 some support for BSD disk labels and other non-DOS partition tables.
210 is for hackers only - the user interface is terrible, but it is
211 more correct than fdisk and more powerful than both fdisk and cfdisk.
212 Moreover, it can be used noninteractively.)
214 The IRIX/SGI type disklabel is currently not supported by the kernel.
215 Moreover, IRIX/SGI header directories are not fully supported yet.
217 The option `dump partition table to file' is missing.
219 .\" A. V. Le Blanc (LeBlanc@mcc.ac.uk)
220 .\" Bernhard Fastenrath (fasten@informatik.uni-bonn.de)
221 .\" Jakub Jelinek (jj@sunsite.mff.cuni.cz)
222 .\" Andreas Neuper (ANeuper@GUUG.de)