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