1FDISK(8)                   Linux Programmer's Manual                  FDISK(8)
2
3
4

NAME

6       fdisk - Partition table manipulator for Linux
7

SYNOPSIS

9       fdisk [-u] [-b sectorsize] [-C cyls] [-H heads] [-S sects] device
10
11       fdisk -l [-u] [device ...]
12
13       fdisk -s partition ...
14
15       fdisk -v
16

DESCRIPTION

18       Hard  disks can be divided into one or more logical disks called parti‐
19       tions.  This division is described in the partition table found in sec‐
20       tor 0 of the disk.
21
22       In the BSD world one talks about `disk slices' and a `disklabel'.
23
24       Linux  needs  at  least one partition, namely for its root file system.
25       It can use swap files and/or swap partitions, but the latter  are  more
26       efficient. So, usually one will want a second Linux partition dedicated
27       as swap partition.  On Intel compatible hardware, the BIOS  that  boots
28       the  system can often only access the first 1024 cylinders of the disk.
29       For this reason people with large disks often create a third partition,
30       just  a  few  MB large, typically mounted on /boot, to store the kernel
31       image and a few auxiliary files needed at boot time, so as to make sure
32       that  this  stuff  is  accessible to the BIOS.  There may be reasons of
33       security, ease of administration and backup, or testing,  to  use  more
34       than the minimum number of partitions.
35
36       fdisk  (in  the  first form of invocation) is a menu driven program for
37       creation and manipulation of partition tables.  It understands DOS type
38       partition tables and BSD or SUN type disklabels.
39
40       fdisk  doesn't  understand  GUID  Partition  Table  (GPT) and it is not
41       designed for large partitions. In particular case use more advanced GNU
42       parted(8).
43
44       The device is usually one of the following:
45              /dev/hda
46              /dev/hdb
47              /dev/sda
48              /dev/sdb
49       (/dev/hd[a-h]  for IDE disks, /dev/sd[a-p] for SCSI disks, /dev/ed[a-d]
50       for ESDI disks, /dev/xd[ab] for XT disks).  A device name refers to the
51       entire disk.
52
53       The  partition  is  a  device name followed by a partition number.  For
54       example, /dev/hda1 is the first partition on the first IDE hard disk in
55       the   system.    Disks   can  have  up  to  15  partitions.   See  also
56       /usr/src/linux/Documentation/devices.txt.
57
58       A BSD/SUN type disklabel can describe 8 partitions, the third of  which
59       should  be  a  `whole  disk'  partition.  Do not start a partition that
60       actually uses its first sector (like a swap partition) at  cylinder  0,
61       since that will destroy the disklabel.
62
63       An  IRIX/SGI type disklabel can describe 16 partitions, the eleventh of
64       which should be an entire `volume' partition, while the ninth should be
65       labeled  `volume header'.  The volume header will also cover the parti‐
66       tion table, i.e., it starts at block zero and extends by  default  over
67       five  cylinders.   The remaining space in the volume header may be used
68       by header directory entries.  No partitions may overlap with the volume
69       header.   Also  do not change its type and make some file system on it,
70       since you will lose the partition table.  Use this type of  label  only
71       when  working  with  Linux on IRIX/SGI machines or IRIX/SGI disks under
72       Linux.
73
74       A DOS type partition table can describe an unlimited number  of  parti‐
75       tions.  In  sector  0 there is room for the description of 4 partitions
76       (called `primary'). One of these may be an extended partition; this  is
77       a  box  holding  logical partitions, with descriptors found in a linked
78       list of sectors, each preceding the corresponding  logical  partitions.
79       The  four primary partitions, present or not, get numbers 1-4.  Logical
80       partitions start numbering from 5.
81
82       In a DOS type partition table the starting offset and the size of  each
83       partition  is  stored  in  two  ways:  as an absolute number of sectors
84       (given in 32 bits) and as a Cylinders/Heads/Sectors  triple  (given  in
85       10+8+6  bits).  The former is OK - with 512-byte sectors this will work
86       up to 2 TB. The latter has two different problems. First of all,  these
87       C/H/S fields can be filled only when the number of heads and the number
88       of sectors per track are known. Secondly, even if we  know  what  these
89       numbers  should be, the 24 bits that are available do not suffice.  DOS
90       uses C/H/S only, Windows uses both, Linux never uses C/H/S.
91
92       If possible, fdisk will obtain the disk geometry  automatically.   This
93       is  not necessarily the physical disk geometry (indeed, modern disks do
94       not really have anything like a physical geometry, certainly not  some‐
95       thing  that  can  be  described  in  simplistic Cylinders/Heads/Sectors
96       form), but is the disk geometry that MS-DOS uses for the partition  ta‐
97       ble.
98
99       Usually all goes well by default, and there are no problems if Linux is
100       the only system on the disk. However, if the disk has to be shared with
101       other  operating  systems, it is often a good idea to let an fdisk from
102       another operating system make at least one partition. When Linux  boots
103       it looks at the partition table, and tries to deduce what (fake) geome‐
104       try is required for good cooperation with other systems.
105
106       Whenever a partition table is printed out, a consistency check is  per‐
107       formed  on  the  partition table entries.  This check verifies that the
108       physical and logical start and end points are identical, and  that  the
109       partition  starts and ends on a cylinder boundary (except for the first
110       partition).
111
112       Some versions of MS-DOS create a first partition which does  not  begin
113       on  a cylinder boundary, but on sector 2 of the first cylinder.  Parti‐
114       tions beginning in cylinder 1 cannot begin on a cylinder boundary,  but
115       this  is  unlikely  to  cause  difficulty  unless you have OS/2 on your
116       machine.
117
118       A sync() and a BLKRRPART ioctl() (reread partition table from disk) are
119       performed  before  exiting  when  the partition table has been updated.
120       Long ago it used to be necessary to reboot after the use of  fdisk.   I
121       do  not  think this is the case anymore - indeed, rebooting too quickly
122       might cause loss of not-yet-written data. Note that both the kernel and
123       the disk hardware may buffer data.
124
125

DOS 6.x WARNING

127       The DOS 6.x FORMAT command looks for some information in the first sec‐
128       tor of the data area of the partition, and treats this  information  as
129       more  reliable than the information in the partition table.  DOS FORMAT
130       expects DOS FDISK to clear the first 512 bytes of the data  area  of  a
131       partition  whenever a size change occurs.  DOS FORMAT will look at this
132       extra information even if the /U flag is given -- we  consider  this  a
133       bug in DOS FORMAT and DOS FDISK.
134
135       The  bottom  line  is that if you use fdisk to change the size of a DOS
136       partition table entry, then you must also use dd to zero the first  512
137       bytes  of  that  partition before using DOS FORMAT to format the parti‐
138       tion.  For example, if you were using disk to make a DOS partition  ta‐
139       ble  entry for /dev/hda1, then (after exiting fdisk and rebooting Linux
140       so that the partition table information is valid)  you  would  use  the
141       command "dd if=/dev/zero of=/dev/hda1 bs=512 count=1" to zero the first
142       512 bytes of the partition.
143
144       BE EXTREMELY CAREFUL if you use the dd command, since a small typo  can
145       make all of the data on your disk useless.
146
147       For  best results, you should always use an OS-specific partition table
148       program.  For example, you should make  DOS  partitions  with  the  DOS
149       FDISK program and Linux partitions with the Linux fdisk program.
150
151

OPTIONS

153       -b sectorsize
154              Specify the sector size of the disk. Valid values are 512, 1024,
155              or 2048.  (Recent kernels know the sector size. Use this only on
156              old kernels or to override the kernel's ideas.)
157
158       -C cyls
159              Specify the number of cylinders of the disk.  I have no idea why
160              anybody would want to do so.
161
162       -H heads
163              Specify the number of heads of the disk. (Not the physical  num‐
164              ber, of course, but the number used for partition tables.)  Rea‐
165              sonable values are 255 and 16.
166
167       -S sects
168              Specify the number of sectors per track of the disk.   (Not  the
169              physical  number,  of  course, but the number used for partition
170              tables.)  A reasonable value is 63.
171
172       -l     List the partition tables for the  specified  devices  and  then
173              exit.   If no devices are given, those mentioned in /proc/parti‐
174              tions (if that exists) are used.
175
176       -u     When listing partition tables, give sizes in sectors instead  of
177              cylinders.
178
179       -s partition
180              The size of the partition (in blocks) is printed on the standard
181              output.
182
183       -v     Print version number of fdisk program and exit.
184

BUGS

186       There are several *fdisk programs around.  Each has  its  problems  and
187       strengths.  Try them in the order parted, fdisk, sfdisk.
188
189       The  IRIX/SGI  type disklabel is currently not supported by the kernel.
190       Moreover, IRIX/SGI header directories are not fully supported yet.
191
192       The option `dump partition table to file' is missing.
193

SEE ALSO

195       mkfs(8), parted(8), sfdisk(8)
196
197
198
199Linux 2.0                        11 June 1998                         FDISK(8)
Impressum