~ubuntu-branches/ubuntu/precise/util-linux/precise-proposed

« back to all changes in this revision

Viewing changes to fdisk/fdisk.8

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-06-20 22:31:50 UTC
  • mfrom: (1.6.3 upstream) (4.5.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110620223150-lz8wrv0946ihcz3z
Tags: 2.19.1-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - Build for multiarch.
  - Add pre-depends on multiarch-support.
  - configure.ac: don't try to be clever about extracting a path name from
    $libdir to append to /usr in a way that's not overridable; instead,
    reuse the built-in configurable libexecdir.
  - Fix up the .pc.in files to know about libexecdir, so our substitutions
    don't leave us with unusable pkg-config files.
  - Install custom blkid.conf to use /dev/.blkid.tab since we don't
    expect device names to survive a reboot
  - Mention mountall(8) in fstab(5) manpages, along with its special
    options.
  - Since upstart is required in Ubuntu, the hwclock.sh init script is not
    called on startup and the hwclockfirst.sh init script is removed.
  - Drop depends on initscripts for the above.
  - Replace hwclock udev rule with an Upstart job.
  - For the case where mount is called with a directory to mount, look
    that directory up in mountall's /lib/init/fstab if we couldn't find
    it mentioned anywhere else.  This means "mount /proc", "mount /sys",
    etc. work.
  - mount.8 points to the cifs-utils package, not the obsolete smbfs one. 
* Dropped changes:
  - mount.preinst: lsb_release has been fixed in lucid and above to be
    usable without configuration, so we don't have to diverge from Debian
    here anymore.
* Changes merged upstream:
  - sfdisk support for '+' with '-N'
  - mount/umount.c: fix a segfault on umount with empty mtab entry
  - Fix arbitrary unmount with fuse security issue

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
.\" May be distributed under the GNU General Public License
4
4
.TH FDISK 8 "11 June 1998" "Linux 2.0" "Linux Programmer's Manual"
5
5
.SH NAME
6
 
fdisk \- Partition table manipulator for Linux
 
6
fdisk \- partition table manipulator for Linux
7
7
.SH SYNOPSIS
8
8
.B fdisk
9
9
.RB [ \-uc ]
28
28
.sp
29
29
.B fdisk \-h
30
30
.SH DESCRIPTION
 
31
.B fdisk
 
32
(in the first form of invocation)
 
33
is a menu-driven program for creation and manipulation of
 
34
partition tables.
 
35
It understands DOS-type partition tables and BSD- or SUN-type disklabels.
 
36
 
 
37
.B fdisk
 
38
does not understand GUID partition tables (GPTs) and it is not designed
 
39
for large partitions.  In these cases, use the more advanced GNU
 
40
.BR parted (8).
 
41
 
 
42
.B fdisk
 
43
does not use DOS-compatible mode and cylinders as display units by default.
 
44
The old deprecated DOS behavior can be enabled with
 
45
the '-c=dos -u=cylinders' command-line options.
 
46
 
31
47
Hard disks can be divided into one or more logical disks called
32
48
.IR partitions .
33
 
This division is described in the
34
 
.I "partition table"
 
49
This division is recorded in the
 
50
.IR "partition table" ,
35
51
found in sector 0 of the disk.
36
 
 
37
 
In the BSD world one talks about `disk slices' and a `disklabel'.
 
52
(In the BSD world one talks about `disk slices' and a `disklabel'.)
38
53
 
39
54
Linux needs at least one partition, namely for its root file system.
40
55
It can use swap files and/or swap partitions, but the latter are more
41
 
efficient. So, usually one will want a second Linux partition
 
56
efficient.  So, usually one will want a second Linux partition
42
57
dedicated as swap partition.
43
 
On Intel compatible hardware, the BIOS that boots the system
 
58
On Intel-compatible hardware, the BIOS that boots the system
44
59
can often only access the first 1024 cylinders of the disk.
45
60
For this reason people with large disks often create a third partition,
46
61
just a few MB large, typically mounted on
50
65
There may be reasons of security, ease of administration and backup,
51
66
or testing, to use more than the minimum number of partitions.
52
67
 
53
 
.B fdisk
54
 
(in the first form of invocation)
55
 
is a menu driven program for creation and manipulation of
56
 
partition tables.
57
 
It understands DOS type partition tables and BSD or SUN type disklabels.
58
 
 
59
 
.B fdisk
60
 
doesn't understand GUID Partition Table (GPT) and
61
 
it is not designed for large partitions. In particular case use more advanced GNU
62
 
.BR parted (8).
63
 
 
 
68
.SH DEVICES
64
69
The
65
70
.I device
66
 
is usually /dev/sda, /dev/sdb or so. A device name refers to the entire disk.
67
 
The old systems without libata (a library used inside the Linux kernel to
 
71
is usually /dev/sda, /dev/sdb or so.  A device name refers to the entire disk.
 
72
Old systems without libata (a library used inside the Linux kernel to
68
73
support ATA host controllers and devices) make a difference between IDE and
69
 
SCSI disks. In such a case the device name will be /dev/hd* (IDE) or /dev/sd*
 
74
SCSI disks.  In such cases the device name will be /dev/hd* (IDE) or /dev/sd*
70
75
(SCSI).
71
76
 
72
77
The
73
78
.I partition
74
 
is a
75
 
.I device
76
 
name followed by a partition number.  For example,
77
 
.B /dev/sda1
 
79
is a device name followed by a partition number.  For example, /dev/sda1
78
80
is the first partition on the first hard disk in the system.
79
81
See also Linux kernel documentation (the Documentation/devices.txt file).
80
82
 
81
 
A BSD/SUN type disklabel can describe 8 partitions,
 
83
.SH DISK LABELS
 
84
A BSD/SUN-type disklabel can describe 8 partitions,
82
85
the third of which should be a `whole disk' partition.
83
86
Do not start a partition that actually uses its first sector
84
87
(like a swap partition) at cylinder 0, since that will
85
88
destroy the disklabel.
86
89
 
87
 
An IRIX/SGI type disklabel can describe 16 partitions,
 
90
An IRIX/SGI-type disklabel can describe 16 partitions,
88
91
the eleventh of which should be an entire `volume' partition,
89
92
while the ninth should be labeled `volume header'.
90
93
The volume header will also cover the partition table, i.e.,
91
94
it starts at block zero and extends by default over five cylinders.
92
95
The remaining space in the volume header may be used by header
93
96
directory entries.  No partitions may overlap with the volume header.
94
 
Also do not change its type and make some file system on it, since
 
97
Also do not change its type or make some filesystem on it, since
95
98
you will lose the partition table.  Use this type of label only when
96
99
working with Linux on IRIX/SGI machines or IRIX/SGI disks under Linux.
97
100
 
98
 
A DOS type partition table can describe an unlimited number
99
 
of partitions. In sector 0 there is room for the description
100
 
of 4 partitions (called `primary'). One of these may be an
 
101
A DOS-type partition table can describe an unlimited number
 
102
of partitions.  In sector 0 there is room for the description
 
103
of 4 partitions (called `primary').  One of these may be an
101
104
extended partition; this is a box holding logical partitions,
102
105
with descriptors found in a linked list of sectors, each
103
106
preceding the corresponding logical partitions.
104
107
The four primary partitions, present or not, get numbers 1-4.
105
108
Logical partitions start numbering from 5.
106
109
 
107
 
In a DOS type partition table the starting offset and the size
 
110
In a DOS-type partition table the starting offset and the size
108
111
of each partition is stored in two ways: as an absolute number
109
 
of sectors (given in 32 bits) and as a Cylinders/Heads/Sectors
110
 
triple (given in 10+8+6 bits). The former is OK - with 512-byte
111
 
sectors this will work up to 2 TB. The latter has two different
112
 
problems. First of all, these C/H/S fields can be filled only
 
112
of sectors (given in 32 bits), and as a Cylinders/Heads/Sectors
 
113
triple (given in 10+8+6 bits).  The former is OK -- with 512-byte
 
114
sectors this will work up to 2 TB.  The latter has two
 
115
problems.  First, these C/H/S fields can be filled only
113
116
when the number of heads and the number of sectors per track
114
 
are known. Secondly, even if we know what these numbers should be,
 
117
are known.  And second, even if we know what these numbers should be,
115
118
the 24 bits that are available do not suffice.
116
119
DOS uses C/H/S only, Windows uses both, Linux never uses C/H/S.
117
120
 
121
124
necessarily the physical disk geometry (indeed, modern disks do not
122
125
really have anything like a physical geometry, certainly not something
123
126
that can be described in simplistic Cylinders/Heads/Sectors form),
124
 
but is the disk geometry that MS-DOS uses for the partition table.
 
127
but it is the disk geometry that MS-DOS uses for the partition table.
125
128
 
126
129
Usually all goes well by default, and there are no problems if
127
 
Linux is the only system on the disk. However, if the disk has
 
130
Linux is the only system on the disk.  However, if the disk has
128
131
to be shared with other operating systems, it is often a good idea
129
132
to let an fdisk from another operating system make at least one
130
 
partition. When Linux boots it looks at the partition table, and
 
133
partition.  When Linux boots it looks at the partition table, and
131
134
tries to deduce what (fake) geometry is required for good
132
135
cooperation with other systems.
133
136
 
134
137
Whenever a partition table is printed out, a consistency check is performed
135
138
on the partition table entries.  This check verifies that the physical and
136
 
logical start and end points are identical, and that the partition starts
 
139
logical start and end points are identical, and that each partition starts
137
140
and ends on a cylinder boundary (except for the first partition).
138
141
 
139
142
Some versions of MS-DOS create a first partition which does not begin
141
144
Partitions beginning in cylinder 1 cannot begin on a cylinder boundary, but
142
145
this is unlikely to cause difficulty unless you have OS/2 on your machine.
143
146
 
144
 
A sync() and a BLKRRPART ioctl() (reread partition table from disk)
 
147
A sync() and an ioctl(BLKRRPART) (reread partition table from disk)
145
148
are performed before exiting when the partition table has been updated.
146
149
Long ago it used to be necessary to reboot after the use of fdisk.
147
 
I do not think this is the case anymore - indeed, rebooting too quickly
148
 
might cause loss of not-yet-written data. Note that both the kernel
 
150
I do not think this is the case anymore -- indeed, rebooting too quickly
 
151
might cause loss of not-yet-written data.  Note that both the kernel
149
152
and the disk hardware may buffer data.
150
153
 
151
154
.SH "DOS 6.x WARNING"
180
183
.SH OPTIONS
181
184
.TP
182
185
.BI "\-b " sectorsize
183
 
Specify the sector size of the disk. Valid values are 512, 1024, 2048 or 4096.
184
 
(Recent kernels know the sector size. Use this only on old kernels or
185
 
to override the kernel's ideas.) Since util-linux-ng 2.17 fdisk differentiates
186
 
between logical and physical sector size. This option changes both sector sizes to
 
186
Specify the sector size of the disk.  Valid values are 512, 1024, 2048 or 4096.
 
187
(Recent kernels know the sector size.  Use this only on old kernels or
 
188
to override the kernel's ideas.)  Since util-linux-2.17, fdisk differentiates
 
189
between logical and physical sector size.  This option changes both sector sizes to
187
190
.IB sectorsize .
188
191
.TP
189
 
.BI \-h
190
 
Print help and then exit.
191
 
.TP
192
 
.BI \-c
193
 
Switch off DOS-compatible mode. (Recommended)
 
192
.BI "\-c"[=mode]
 
193
Specify the compatiblity mode, 'dos' or 'nondos'.  The default is non-DOS
 
194
mode.  For backward compatibility, it is possible to use the option without
 
195
the <mode> argument -- then the default is used.  Note that the optional
 
196
<mode> argument cannot be separated from the -c option by a space, the correct
 
197
form is for example '-c=dos'.
194
198
.TP
195
199
.BI "\-C " cyls
196
200
Specify the number of cylinders of the disk.
197
201
I have no idea why anybody would want to do so.
198
202
.TP
199
203
.BI "\-H " heads
200
 
Specify the number of heads of the disk. (Not the physical number,
 
204
Specify the number of heads of the disk.  (Not the physical number,
201
205
of course, but the number used for partition tables.)
202
206
Reasonable values are 255 and 16.
203
207
.TP
207
211
partition tables.)
208
212
A reasonable value is 63.
209
213
.TP
 
214
.BI \-h
 
215
Print help and then exit.
 
216
.TP
210
217
.B \-l
211
218
List the partition tables for the specified devices and then exit.
212
219
If no devices are given, those mentioned in
213
220
.I /proc/partitions
214
221
(if that exists) are used.
215
222
.TP
216
 
.B \-u
217
 
When listing partition tables, give sizes in sectors instead
218
 
of cylinders.
 
223
.BI "\-s " partition...
 
224
Print the size (in blocks) of each given partition.
219
225
.TP
220
 
.BI "\-s " partition
221
 
The
222
 
.I size
223
 
of the partition (in blocks) is printed on the standard output.
 
226
.BI "\-u"[=unit]
 
227
When listing partition tables, show sizes in 'sectors' or in 'cylinders'.  The
 
228
default is to show sizes in sectors.  For backward compatibility, it is possible
 
229
to use the option without the <units> argument -- then the default is used.
 
230
Note that the optional <unit> argument cannot be separated from the -u option
 
231
by a space, the correct form is for example '-u=cylinders'.
224
232
.TP
225
233
.B \-v
226
234
Print version number of
237
245
.B cfdisk
238
246
is a beautiful program that has strict requirements on
239
247
the partition tables it accepts, and produces high quality partition
240
 
tables. Use it if you can.
 
248
tables.  Use it if you can.
241
249
.B fdisk
242
250
is a buggy program that does fuzzy things - usually it happens to
243
 
produce reasonable results. Its single advantage is that it has
 
251
produce reasonable results.  Its single advantage is that it has
244
252
some support for BSD disk labels and other non-DOS partition tables.
245
253
Avoid it if you can.
246
254
.B sfdisk
247
 
is for hackers only - the user interface is terrible, but it is
 
255
is for hackers only -- the user interface is terrible, but it is
248
256
more correct than fdisk and more powerful than both fdisk and cfdisk.
249
257
Moreover, it can be used noninteractively.)
250
258
.PP
253
261
The cfdisk interface is nicer, but parted does much more: it not only
254
262
resizes partitions, but also the filesystems that live in them.
255
263
.PP
256
 
The IRIX/SGI type disklabel is currently not supported by the kernel.
 
264
The IRIX/SGI-type disklabel is currently not supported by the kernel.
257
265
Moreover, IRIX/SGI header directories are not fully supported yet.
258
266
.PP
259
267
The option `dump partition table to file' is missing.
271
279
.BR partprobe (8),
272
280
.BR kpartx (8)
273
281
.SH AVAILABILITY
274
 
The fdisk command is part of the util-linux-ng package and is available from
275
 
ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
 
282
The fdisk command is part of the util-linux package and is available from
 
283
ftp://ftp.kernel.org/pub/linux/utils/util-linux/.