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