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