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