1CFDISK(8)                    System Administration                   CFDISK(8)
2
3
4

NAME

6       cfdisk - display or manipulate disk partition table
7

SYNOPSIS

9       cfdisk  [-agvz]  [-c  cylinders]  [-h heads] [-s sectors-per-track] [-P
10       opt] [device]
11

DESCRIPTION

13       cfdisk is a curses-based program for partitioning any hard disk  drive.
14       Typical values of the device argument are:
15
16              /dev/hda [default]
17              /dev/hdb
18              /dev/sda
19              /dev/sdb
20              /dev/sdc
21              /dev/sdd
22
23       Note  that cfdisk does not align partitions to block device I/O limits.
24       This functionality is provided by fdisk(8).
25
26       In order to write the partition table cfdisk needs something called the
27       `geometry'  of  the disk: the number of `heads' and the number of `sec‐
28       tors per track'. Linux does not use any geometry, so if the  disk  will
29       not  be  accessed by other operating systems, you can safely accept the
30       defaults that cfdisk chooses for you. The geometry used  by  cfdisk  is
31       found  as  follows.  First the partition table is examined, to see what
32       geometry was used by the previous program that changed it. If the  par‐
33       tition table is empty, or contains garbage, or does not point at a con‐
34       sistent geometry, the kernel is asked for advice. If nothing works  255
35       heads  and  63 sectors/track is assumed. The geometry can be overridden
36       on the command line or by use of the `g' command. When partitioning  an
37       empty  large  modern  disk,  picking  255 heads and 63 sectors/track is
38       always a good idea.  There is no need to set the number  of  cylinders,
39       since cfdisk knows the disk size.
40
41       Next,  cfdisk  tries  to read the current partition table from the disk
42       drive.  If it is unable to figure out the partition table, an error  is
43       displayed  and  the  program  will  exit.  This might also be caused by
44       incorrect geometry information, and can be overridden  on  the  command
45       line.   Another  way  around  this problem is with the -z option.  This
46       will ignore the partition table on the disk.
47
48       The main display is composed of four sections, from top to bottom:  the
49       header,  the  partitions,  the  command  line  and a warning line.  The
50       header contains the program name and version  number  followed  by  the
51       disk  drive  and  its geometry.  The partitions section always displays
52       the current partition table.  The command line is the place where  com‐
53       mands  and  text  are entered.  The available commands are usually dis‐
54       played in brackets.  The warning line  is  usually  empty  except  when
55       there  is important information to be displayed.  The current partition
56       is highlighted with reverse video (or an arrow  if  the  -a  option  is
57       given).   All  partition  specific commands apply to the current parti‐
58       tion.
59
60       The format of the partition table in the partitions  section  is,  from
61       left  to  right: Name, Flags, Partition Type, Filesystem Type and Size.
62       The name is the partition device name.  The flags can  be  Boot,  which
63       designates a bootable partition or NC, which stands for "Not Compatible
64       with DOS or OS/2".  DOS, OS/2  and  possibly  other  operating  systems
65       require  the  first  sector  of the first partition on the disk and all
66       logical partitions to begin on the second head.  This wastes the second
67       through the last sector of the first track of the first head (the first
68       sector is taken by the partition table itself).  cfdisk allows  you  to
69       recover  these  "lost"  sectors  with  the maximize command (m).  Note:
70       fdisk(8) and some early versions of DOS create all partitions with  the
71       number  of  sectors  already  maximized.  For more information, see the
72       maximize command below.  The partition type can be one  of  Primary  or
73       Logical.   For  unallocated  space on the drive, the partition type can
74       also be Pri/Log, or empty (if the space is unusable).   The  filesystem
75       type section displays the name of the filesystem used on the partition,
76       if known.  If it is unknown, then Unknown and  the  hex  value  of  the
77       filesystem  type  are  displayed.  A special case occurs when there are
78       sections of the disk drive that cannot be used (because all of the pri‐
79       mary  partitions are used).  When this is detected, the filesystem type
80       is displayed as Unusable.  The size field displays the size of the par‐
81       tition in megabytes (by default).  It can also display the size in sec‐
82       tors and cylinders (see the change units command below).  If an  aster‐
83       isk  (*)  appears  after the size, this means that the partition is not
84       aligned on cylinder boundaries.
85

DOS 6.x WARNING

87       The DOS 6.x FORMAT command looks for some information in the first sec‐
88       tor  of  the data area of the partition, and treats this information as
89       more reliable than the information in the partition table.  DOS  FORMAT
90       expects  DOS  FDISK  to clear the first 512 bytes of the data area of a
91       partition whenever a size change occurs.  DOS FORMAT will look at  this
92       extra  information  even  if the /U flag is given -- we consider this a
93       bug in DOS FORMAT and DOS FDISK.
94
95       The bottom line is that if you use cfdisk or fdisk to change  the  size
96       of  a  DOS partition table entry, then you must also use dd to zero the
97       first 512 bytes of that partition before using DOS FORMAT to format the
98       partition.   For example, if you were using cfdisk to make a DOS parti‐
99       tion table entry for /dev/hda1, then (after exiting fdisk or cfdisk and
100       rebooting  Linux  so that the partition table information is valid) you
101       would use the command "dd if=/dev/zero of=/dev/hda1 bs=512 count=1"  to
102       zero the first 512 bytes of the partition. Note:
103
104       BE  EXTREMELY CAREFUL if you use the dd command, since a small typo can
105       make all of the data on your disk useless.
106
107       For best results, you should always use an OS-specific partition  table
108       program.   For  example,  you  should  make DOS partitions with the DOS
109       FDISK program and Linux partitions with the Linux fdisk or Linux cfdisk
110       program.
111
112

COMMANDS

114       cfdisk  commands  can  be entered by pressing the desired key (pressing
115       Enter after the command is not necessary).   Here  is  a  list  of  the
116       available commands:
117
118       b      Toggle  bootable flag of the current partition.  This allows you
119              to select which primary partition is bootable on the drive.
120
121       d      Delete the current partition.  This  will  convert  the  current
122              partition into free space and merge it with any free space imme‐
123              diately surrounding the current partition.  A partition  already
124              marked as free space or marked as unusable cannot be deleted.
125
126       g      Change  the  disk  geometry  (cylinders,  heads, or sectors-per-
127              track).  WARNING: This option should only be used by people  who
128              know  what they are doing.  A command line option is also avail‐
129              able to change the disk geometry.   While  at  the  change  disk
130              geometry  command  line, you can choose to change cylinders (c),
131              heads (h), and sectors per track (s).  The default value will be
132              printed  at  the  prompt which you can accept by simply pressing
133              the Enter key, or you can exit without changes by  pressing  the
134              ESC  key.  If you want to change the default value, simply enter
135              the desired value and press Enter.  The altered  disk  parameter
136              values  do not take effect until you return to the main menu (by
137              pressing Enter or ESC at the change disk geometry command line).
138              If  you  change  the geometry such that the disk appears larger,
139              the extra sectors are added at the  end  of  the  disk  as  free
140              space.   If  the  disk  appears smaller, the partitions that are
141              beyond the new last sector are deleted and the last partition on
142              the drive (or the free space at the end of the drive) is made to
143              end at the new last sector.
144
145       h      Print the help screen.
146
147       m      Maximize disk usage of the current partition.  This command will
148              recover  the  unused  space  between the partition table and the
149              beginning of the partition, but at the cost of making the parti‐
150              tion  incompatible  with  DOS, OS/2 and possibly other operating
151              systems.  This option will toggle between maximal disk usage and
152              DOS,  OS/2, etc. compatible disk usage.  The default when creat‐
153              ing a partition is to create DOS, OS/2, etc.  compatible  parti‐
154              tions.
155
156       n      Create  new partition from free space.  If the partition type is
157              Primary or Logical, a partition of that type  will  be  created,
158              but  if  the partition type is Pri/Log, you will be prompted for
159              the type you want to create.  Be aware that (1) there  are  only
160              four  slots available for primary partitions and (2) since there
161              can be only one extended partition, which contains  all  of  the
162              logical  drives,  all  of  the logical drives must be contiguous
163              (with no intervening primary partition).   cfdisk  next  prompts
164              you  for  the  size  of  the  partition you want to create.  The
165              default size, equal to the entire free space of the current par‐
166              tition,  is  displayed  in  megabytes.  You can either press the
167              Enter key to accept the default size or enter a  different  size
168              at  the  prompt.   cfdisk  accepts size entries in megabytes (M)
169              [default], kilobytes (K),  cylinders  (C)  and  sectors  (S)  by
170              entering  the  number immediately followed by one of (M, K, C or
171              S).  If the partition fills the free space available, the parti‐
172              tion  is  created and you are returned to the main command line.
173              Otherwise, the partition can be created at the beginning or  the
174              end  of  the free space, and cfdisk will ask you to choose where
175              to place the partition.  After the partition is created,  cfdisk
176              automatically  adjusts  the other partitions' partition types if
177              all of the primary partitions are used.
178
179       p      Print the partition table to the screen or to a file. There  are
180              several  different formats for the partition that you can choose
181              from:
182
183
184              r      Raw data format (exactly what would be written to disk)
185
186              s      Partition table in sector order format
187
188              t      Partition table in raw format
189
190              The raw data format will print the sectors that would be written
191              to disk if a write command is selected.  First, the primary par‐
192              tition table is printed, followed by the partition tables  asso‐
193              ciated  with each logical partition.  The data is printed in hex
194              byte by byte with 16 bytes per line.
195
196              The partition table in sector order format will print the parti‐
197              tion  table  ordered by sector number.  The fields, from left to
198              right, are the number of the partition, the partition type,  the
199              first  sector, the last sector, the offset from the first sector
200              of the partition to the start of the data,  the  length  of  the
201              partition,  the filesystem type (with the hex value in parenthe‐
202              sis), and the flags (with the hex  value  in  parenthesis).   In
203              addition  to  the primary and logical partitions, free and unus‐
204              able space is printed and  the  extended  partition  is  printed
205              before the first logical partition.
206
207              If  a  partition does not start or end on a cylinder boundary or
208              if the partition length is not divisible by the  cylinder  size,
209              an  asterisk  (*)  is  printed after the non-aligned sector num‐
210              ber/count.  This usually indicates that a partition was  created
211              by  an operating system that either does not align partitions to
212              cylinder boundaries or that used different disk geometry  infor‐
213              mation.   If  you  know the disk geometry of the other operating
214              system, you could enter the geometry information with the change
215              geometry command (g).
216
217              For  the  first partition on the disk and for all logical parti‐
218              tions, if the offset from the beginning of the partition is  not
219              equal  to  the  number of sectors per track (i.e., the data does
220              not start on the first head), a number sign (#) is printed after
221              the  offset.  For the remaining partitions, if the offset is not
222              zero, a number sign will be printed after the offset.  This cor‐
223              responds  to  the  NC flag in the partitions section of the main
224              display.
225
226              The partition table in raw format will print the partition table
227              ordered  by  partition  number.   It will leave out all free and
228              unusable space.  The fields, from left to right, are the  number
229              of  the partition, the flags (in hex), the starting head, sector
230              and cylinder, the filesystem ID (in hex), the ending head,  sec‐
231              tor  and  cylinder, the starting sector in the partition and the
232              number of sectors in the partition.  The information in this ta‐
233              ble can be directly translated to the raw data format.
234
235              The  partition table entries only have 10 bits available to rep‐
236              resent the starting and ending cylinders.  Thus, when the  abso‐
237              lute  starting  (ending)  sector number is on a cylinder greater
238              than 1023, the maximal values for starting (ending) head, sector
239              and  cylinder are printed.  This is the method used by OS/2, and
240              thus fixes the problems associated with OS/2's  fdisk  rewriting
241              the  partition table when it is not in this format.  Since Linux
242              and OS/2 use absolute sector counts, the values in the  starting
243              and ending head, sector and cylinder are not used.
244
245       q      Quit  program.   This  will exit the program without writing any
246              data to disk.
247
248       t      Change the filesystem type.  By default, new partitions are cre‐
249              ated as Linux partitions, but since cfdisk can create partitions
250              for other operating systems, change partition type allows you to
251              enter the hex value of the filesystem you desire.  A list of the
252              know filesystem  types  is  displayed.   You  can  type  in  the
253              filesystem  type  at the prompt or accept the default filesystem
254              type [Linux].
255
256       u      Change units of the partition  size  display.   It  will  rotate
257              through megabytes, sectors and cylinders.
258
259       W      Write  partition  table  to  disk  (must enter an upper case W).
260              Since this might destroy data on the disk, you must either  con‐
261              firm  or deny the write by entering `yes' or `no'.  If you enter
262              `yes', cfdisk will write the partition table  to  disk  and  the
263              tell  the  kernel  to re-read the partition table from the disk.
264              The re-reading of the partition table  does  not  work  in  some
265              cases,  for  example  for  device-mapper devices.  In particular
266              case you need to inform kernel about  new  partitions  by  part‐
267              probe(8), kpartx(8) or reboot the system.
268
269       Up Arrow
270
271       Down Arrow
272              Move  cursor  to  the  previous or next partition.  If there are
273              more partitions than can be displayed on a screen, you can  dis‐
274              play  the  next (previous) set of partitions by moving down (up)
275              at the last (first) partition displayed on the screen.
276
277       CTRL-L Redraws the screen.  In case something goes wrong and you cannot
278              read  anything, you can refresh the screen from the main command
279              line.
280
281       ?      Print the help screen.
282
283       All of the commands can be entered with either upper or lower case let‐
284       ters (except for Writes).  When in a sub-menu or at a prompt to enter a
285       filename, you can hit the ESC key to return to the main command line.
286

OPTIONS

288       -a     Use an arrow cursor instead of reverse  video  for  highlighting
289              the current partition.
290
291       -g     Do  not  use  the  geometry given by the disk driver, but try to
292              guess a geometry from the partition table.
293
294       -v     Print the version number and copyright.
295
296       -z     Start with zeroed partition table.  This option is  useful  when
297              you  want  to  repartition  your entire disk.  Note: this option
298              does not zero the partition table on the disk; rather, it simply
299              starts the program without reading the existing partition table.
300
301       -c cylinders
302
303       -h heads
304
305       -s sectors-per-track
306              Override  the  number  of cylinders, heads and sectors per track
307              read from the BIOS.  If your BIOS or  adapter  does  not  supply
308              this  information  or  if it supplies incorrect information, use
309              these options to set the disk geometry values.
310
311       -P opt Prints the partition table in specified formats.  opt can be one
312              or  more  of "r", "s" or "t".  See the print command (above) for
313              more information on the print formats.
314

EXIT STATUS

316       0: No errors; 1: Invocation error; 2: I/O error; 3: cannot  get  geome‐
317       try; 4: bad partition table on disk.
318

SEE ALSO

320       fdisk(8), sfdisk(8), mkfs(8), parted(8), partprobe(8), kpartx(8)
321

BUGS

323       The current version does not support multiple disks.
324

AUTHOR

326       Kevin E. Martin (martin@cs.unc.edu)
327
328

AVAILABILITY

330       The  cfdisk  command is part of the util-linux package and is available
331       from ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
332
333
334
335util-linux                         July 2009                         CFDISK(8)
Impressum