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