Upload Tizen:Base source
[framework/base/util-linux-ng.git] / fdisk / cfdisk.8
1 .\" cfdisk.8 -- man page for cfdisk
2 .\" Copyright 1994 Kevin E. Martin (martin@cs.unc.edu)
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" " for hilit mode
14 .TH CFDISK 8 "3 June 1995" "The BOGUS Linux Release" "Linux Programmer's Manual"
15 .SH NAME
16 cfdisk \- Curses based disk partition table manipulator for Linux
17 .SH SYNOPSIS
18 .B cfdisk
19 .RB [ \-agvz ]
20 .RB [ \-c
21 .IR cylinders ]
22 .RB [ \-h
23 .IR heads ]
24 .RB [ \-s
25 .IR sectors-per-track ]
26 .RB [ \-P
27 .IR opt ]
28 .RI [ device ]
29 .SH DESCRIPTION
30 .B cfdisk
31 is a curses based program for partitioning any hard disk drive.
32 Typical values of the
33 .I device
34 argument are:
35 .sp
36 .nf
37 .RS
38 /dev/hda [default]
39 /dev/hdb
40 /dev/sda
41 /dev/sdb
42 /dev/sdc
43 /dev/sdd
44 .RE
45 .fi
46
47 In order to write the partition table
48 .B cfdisk
49 needs something called the `geometry' of the disk: the number
50 of `heads' and the number of `sectors per track'. Linux does not
51 use any geometry, so if the disk will not be accessed by other
52 operating systems, you can safely accept the defaults that
53 .B cfdisk
54 chooses for you. The geometry used by
55 .B cfdisk
56 is found as follows. First the partition table is examined,
57 to see what geometry was used by the previous program that
58 changed it. If the partition table is empty, or contains garbage,
59 or does not point at a consistent geometry, the kernel is
60 asked for advice. If nothing works 255 heads and 63 sectors/track
61 is assumed. The geometry can be overridden on the command line
62 or by use of the `g' command. When partitioning an empty large modern
63 disk, picking 255 heads and 63 sectors/track is always a good idea.
64 There is no need to set the number of cylinders, since
65 .B cfdisk
66 knows the disk size.
67
68 Next,
69 .B cfdisk
70 tries to read the current partition table from the disk drive.  If it
71 is unable to figure out the partition table, an error is displayed and
72 the program will exit.  This might also be caused by incorrect
73 geometry information, and can be overridden on the command line.
74 Another way around this problem is with the
75 .B \-z
76 option.  This will ignore the partition table on the disk.
77
78 The main display is composed of four sections, from top to bottom: the
79 header, the partitions, the command line and a warning line.  The
80 header contains the program name and version number followed by the
81 disk drive and its geometry.  The partitions section always displays
82 the current partition table.  The command line is the place where
83 commands and text are entered.  The available commands are usually
84 displayed in brackets.  The warning line is usually empty except when
85 there is important information to be displayed.  The current partition
86 is highlighted with reverse video (or an arrow if the
87 .B \-a
88 option is given).  All partition specific commands apply to the
89 current partition.
90
91 The format of the partition table in the partitions section is, from
92 left to right: Name, Flags, Partition Type, Filesystem Type and Size.
93 The name is the partition device name.  The flags can be
94 .IR Boot ,
95 which designates a bootable partition or
96 .IR NC ,
97 which stands for "Not Compatible with DOS or OS/2".  DOS, OS/2 and
98 possibly other operating systems require the first sector of the first
99 partition on the disk and all logical partitions to begin on the
100 second head.  This wastes the second through the last sector of the
101 first track of the first head (the first sector is taken by the
102 partition table itself).
103 .B cfdisk
104 allows you to recover these "lost" sectors with the maximize command
105 .RB ( m ).
106 .I Note:
107 .BR fdisk (8)
108 and some early versions of DOS create all partitions with the number
109 of sectors already maximized.  For more information, see the maximize
110 command below.  The partition type can be one of
111 .IR Primary " or " Logical .
112 For unallocated space on the drive, the partition type can also be
113 .IR Pri/Log ,
114 or empty (if the space is unusable).  The filesystem type section
115 displays the name of the filesystem used on the partition, if known.
116 If it is unknown, then
117 .I Unknown
118 and the hex value of the filesystem type are displayed.  A special
119 case occurs when there are sections of the disk drive that cannot be
120 used (because all of the primary partitions are used).  When this is
121 detected, the filesystem type is displayed as
122 .IR Unusable .
123 The size field displays the size of the partition in megabytes (by
124 default).  It can also display the size in sectors and cylinders (see
125 the change units command below).  If an asterisk
126 .RB ( * )
127 appears after the size, this means that the partition is not aligned
128 on cylinder boundaries.
129 .SH "DOS 6.x WARNING"
130
131 The DOS 6.x FORMAT command looks for some information in the first
132 sector of the data area of the partition, and treats this information
133 as more reliable than the information in the partition table.  DOS
134 FORMAT expects DOS FDISK to clear the first 512 bytes of the data area
135 of a partition whenever a size change occurs.  DOS FORMAT will look at
136 this extra information even if the /U flag is given -- we consider
137 this a bug in DOS FORMAT and DOS FDISK.
138
139 The bottom line is that if you use cfdisk or fdisk to change the size of a
140 DOS partition table entry, then you must also use
141 .B dd
142 to zero the first 512 bytes of that partition before using DOS FORMAT to
143 format the partition.  For example, if you were using cfdisk to make a DOS
144 partition table entry for /dev/hda1, then (after exiting fdisk or cfdisk
145 and rebooting Linux so that the partition table information is valid) you
146 would use the command "dd if=/dev/zero of=/dev/hda1 bs=512 count=1" to zero
147 the first 512 bytes of the partition. Note:
148
149 .B BE EXTREMELY CAREFUL
150 if you use the
151 .B dd
152 command, since a small typo can make all of the data on your disk useless.
153
154 For best results, you should always use an OS-specific partition table
155 program.  For example, you should make DOS partitions with the DOS FDISK
156 program and Linux partitions with the Linux fdisk or Linux cfdisk program.
157
158 .SH COMMANDS
159 .B cfdisk
160 commands can be entered by pressing the desired key (pressing
161 .I Enter
162 after the command is not necessary).  Here is a list of the available
163 commands:
164 .TP
165 .B b
166 Toggle bootable flag of the current partition.  This allows you to
167 select which primary partition is bootable on the drive.
168 .TP
169 .B d
170 Delete the current partition.  This will convert the current partition
171 into free space and merge it with any free space immediately
172 surrounding the current partition.  A partition already marked as free
173 space or marked as unusable cannot be deleted.
174 .TP
175 .B g
176 Change the disk geometry (cylinders, heads, or sectors-per-track).
177 .B WARNING:
178 This option should only be used by people who know what they are
179 doing.  A command line option is also available to change the disk
180 geometry.  While at the change disk geometry command line, you can
181 choose to change cylinders
182 .RB ( c ),
183 heads
184 .RB ( h ),
185 and sectors per track
186 .RB ( s ).
187 The default value will be printed at the prompt which you can accept
188 by simply pressing the
189 .I Enter
190 key, or you can exit without changes by pressing the
191 .I ESC
192 key.  If you want to change the default value, simply enter the
193 desired value and press
194 .IR Enter .
195 The altered disk parameter values do not take effect until you return
196 to the main menu (by pressing
197 .IR Enter " or " ESC
198 at the change disk geometry command line).  If you change the geometry
199 such that the disk appears larger, the extra sectors are added at the
200 end of the disk as free space.  If the disk appears smaller, the
201 partitions that are beyond the new last sector are deleted and the
202 last partition on the drive (or the free space at the end of the
203 drive) is made to end at the new last sector.
204 .TP
205 .B h
206 Print the help screen.
207 .TP
208 .B m
209 Maximize disk usage of the current partition.  This command will
210 recover the unused space between the partition table and the
211 beginning of the partition, but at the cost of making the partition
212 incompatible with DOS, OS/2 and possibly other operating systems.
213 This option will toggle between maximal disk usage and DOS, OS/2,
214 etc. compatible disk usage.  The default when creating a partition is
215 to create DOS, OS/2, etc. compatible partitions.
216 .TP
217 .B n
218 Create new partition from free space.  If the partition type is
219 .IR Primary " or " Logical ,
220 a partition of that type will be created, but if the partition type is
221 .IR Pri/Log ,
222 you will be prompted for the type you want to create.  Be aware that
223 (1) there are only four slots available for primary partitions and (2)
224 since there can be only one extended partition, which contains all of
225 the logical drives, all of the logical drives must be contiguous (with
226 no intervening primary partition).
227 .B cfdisk
228 next prompts you for the size of the partition you want to create.
229 The default size, equal to the entire free space of the current
230 partition, is displayed in megabytes.  You can either press the
231 .I Enter
232 key to accept the default size or enter a different size at the
233 prompt.
234 .B cfdisk
235 accepts size entries in megabytes
236 .RB ( M )
237 [default], kilobytes
238 .RB ( K ),
239 cylinders
240 .RB ( C )
241 and sectors
242 .RB ( S )
243 by entering the number immediately followed by one of
244 .RB ( M ", " K ", " C " or " S ).
245 If the partition fills the free space available, the partition is
246 created and you are returned to the main command line.  Otherwise, the
247 partition can be created at the beginning or the end of the free
248 space, and
249 .B cfdisk
250 will ask you to choose where to place the partition.  After the
251 partition is created,
252 .B cfdisk
253 automatically adjusts the other partitions' partition types if all of
254 the primary partitions are used.
255 .TP
256 .B p
257 Print the partition table to the screen or to a file. There are
258 several different formats for the partition that you can choose from:
259 .sp
260 .RS
261 .TP
262 .B r
263 Raw data format (exactly what would be written to disk)
264 .TP
265 .B s
266 Partition table in sector order format
267 .TP
268 .B t
269 Partition table in raw format
270 .RE
271
272 .RS
273 The
274 .I raw data format
275 will print the sectors that would be written to disk if a
276 .BR w rite
277 command is selected.  First, the primary partition table is printed,
278 followed by the partition tables associated with each logical
279 partition.  The data is printed in hex byte by byte with 16 bytes per
280 line.
281
282 The
283 .I partition table in sector order format
284 will print the partition table ordered by sector number.  The fields,
285 from left to right, are the number of the partition, the partition
286 type, the first sector, the last sector, the offset from the first
287 sector of the partition to the start of the data, the length of the
288 partition, the filesystem type (with the hex value in parenthesis),
289 and the flags (with the hex value in parenthesis).  In addition to the
290 primary and logical partitions, free and unusable space is printed and
291 the extended partition is printed before the first logical partition.
292
293 If a partition does not start or end on a cylinder boundary or if the
294 partition length is not divisible by the cylinder size, an asterisk
295 .RB ( * )
296 is printed after the non-aligned sector number/count.  This usually
297 indicates that a partition was created by an operating system that
298 either does not align partitions to cylinder boundaries or that used
299 different disk geometry information.  If you know the disk geometry of
300 the other operating system, you could enter the geometry information
301 with the change geometry command
302 .RB ( g ).
303
304 For the first partition on the disk and for all logical partitions, if
305 the offset from the beginning of the partition is not equal to the
306 number of sectors per track (i.e., the data does not start on the
307 first head), a number sign
308 .RB ( # )
309 is printed after the offset.  For the remaining partitions, if the
310 offset is not zero, a number sign will be printed after the offset.
311 This corresponds to the
312 .I NC
313 flag in the partitions section of the main display.
314
315 The
316 .I partition table in raw format
317 will print the partition table ordered by partition number.  It will
318 leave out all free and unusable space.  The fields, from left to
319 right, are the number of the partition, the flags (in hex), the
320 starting head, sector and cylinder, the filesystem ID (in hex), the
321 ending head, sector and cylinder, the starting sector in the partition
322 and the number of sectors in the partition.  The information in this
323 table can be directly translated to the
324 .IR "raw data format" .
325
326 The partition table entries only have 10 bits available to represent
327 the starting and ending cylinders.  Thus, when the absolute starting
328 (ending) sector number is on a cylinder greater than 1023, the maximal
329 values for starting (ending) head, sector and cylinder are printed.
330 This is the method used by OS/2, and thus fixes the problems
331 associated with OS/2's fdisk rewriting the partition table when it is
332 not in this format.  Since Linux and OS/2 use absolute sector counts,
333 the values in the starting and ending head, sector and cylinder are
334 not used.
335 .RE
336 .TP
337 .B q
338 Quit program.  This will exit the program without writing any data to
339 disk.
340 .TP
341 .B t
342 Change the filesystem type.  By default, new partitions are created as
343 .I Linux
344 partitions, but since
345 .B cfdisk
346 can create partitions for other operating systems, change partition
347 type allows you to enter the hex value of the filesystem you desire.
348 A list of the know filesystem types is displayed.  You can type in the
349 filesystem type at the prompt or accept the default filesystem type
350 .RI [ Linux ].
351 .TP
352 .B u
353 Change units of the partition size display.  It will rotate through
354 megabytes, sectors and cylinders.
355 .TP
356 .B W
357 Write partition table to disk (must enter an upper case W).  Since
358 this might destroy data on the disk, you must either confirm or deny
359 the write by entering `yes' or `no'.  If you enter `yes',
360 .B cfdisk
361 will write the partition table to disk and the tell the kernel to re-read the
362 partition table from the disk.  The re-reading of the partition table does not
363 work in some cases, for example for device-mapper devices.  In
364 particular case you need to inform kernel about new
365 partitions by
366 .B partprobe(8),
367 .B kpartx(8)
368 or reboot the system.
369 .TP
370 .I Up Arrow
371 .TP
372 .I Down Arrow
373 Move cursor to the previous or next partition.  If there are more
374 partitions than can be displayed on a screen, you can display the next
375 (previous) set of partitions by moving down (up) at the last (first)
376 partition displayed on the screen.
377 .TP
378 .I CTRL-L
379 Redraws the screen.  In case something goes wrong and you cannot read
380 anything, you can refresh the screen from the main command line.
381 .TP
382 .B ?
383 Print the help screen.
384
385 .RE
386 All of the commands can be entered with either upper or lower case
387 letters (except for
388 .BR W rites).
389 When in a sub-menu or at a prompt to enter a filename, you can hit the
390 .I ESC
391 key to return to the main command line.
392 .SH OPTIONS
393 .TP
394 .B \-a
395 Use an arrow cursor instead of reverse video for highlighting the
396 current partition.
397 .TP
398 .B \-g
399 Do not use the geometry given by the disk driver, but try to
400 guess a geometry from the partition table.
401 .TP
402 .B \-v
403 Print the version number and copyright.
404 .TP
405 .B \-z
406 Start with zeroed partition table.  This option is useful when you
407 want to repartition your entire disk.
408 .I Note:
409 this option does not zero the partition table on the disk; rather, it
410 simply starts the program without reading the existing partition
411 table.
412 .TP
413 .BI \-c " cylinders"
414 .TP
415 .BI \-h " heads"
416 .TP
417 .BI \-s " sectors-per-track"
418 Override the number of cylinders, heads and sectors per track read
419 from the BIOS.  If your BIOS or adapter does not supply this
420 information or if it supplies incorrect information, use these options
421 to set the disk geometry values.
422 .TP
423 .BI \-P " opt"
424 Prints the partition table in specified formats.
425 .I opt
426 can be one or more of "r", "s" or "t".  See the
427 .BR p rint
428 command (above) for more information on the print formats.
429 .SH "EXIT STATUS"
430 0: No errors; 1: Invocation error; 2: I/O error;
431 3: cannot get geometry; 4: bad partition table on disk.
432 .SH "SEE ALSO"
433 .BR fdisk (8),
434 .BR sfdisk (8),
435 .BR mkfs (8),
436 .BR parted (8),
437 .BR partprobe (8),
438 .BR kpartx(8)
439 .SH BUGS
440 The current version does not support multiple disks.
441 .SH AUTHOR
442 Kevin E. Martin (martin@cs.unc.edu)
443
444 .SH AVAILABILITY
445 The cfdisk command is part of the util-linux-ng package and is available from
446 ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.