Anonymous avatar Anonymous committed 1894e1b

Make fdisk support -s option from Linux fdisk and -t option from GNU cfdisk. Make fdisk support making of a filesystem. Add fdisk man and info page. (fdisk@sv.gnu.org/fdisk--main--0--patch-48)
fdisk@sv.gnu.org/fdisk--main--0--patch-48
Keywords:

Comments (0)

Files changed (11)

 AC_PREREQ(2.50)
-AC_INIT(fdisk, 0.9, [bug-fdisk@gnu.org])
+AC_INIT(fdisk, 0.0.1, [bug-fdisk@gnu.org])
 AC_CONFIG_AUX_DIR(autotools)
 
 AM_INIT_AUTOMAKE
-info_TEXINFOS = cfdisk.texi
-man_MANS      =	cfdisk.8
+info_TEXINFOS = cfdisk.texi fdisk.texi
+man_MANS      =	cfdisk.8 fdisk.8
 .TH CFDISK 8 "16 June, 2006" fdisk "GNU cfdisk Manual"
 .SH NAME
-GNU cfdisk - a curses-based partition manipulation program
+GNU cfdisk - a curses-based partition table manipulation program
 .SH SYNOPSIS
 .B cfdisk
 [options] [device]
 .B -u, --units=\fIUNIT\fP
 sets the default display units to \fIUNIT\fP. A list of possible units is given below.
 .TP
-.B -l, --list-partition-types
+.B -t, --list-partition-types
 displays a list of supported partition types and features.
 .SH UNITS
 You can choose in what unit cfdisk should display quantities like partition sizes. You can choose from sectors, percents, bytes, kilobytes, etc. Note that one kilobyte is equal to 1,000 bytes, as this is consistent with the SI prefixes and is used by hard disk manufacturers. If you prefer to see the sizes in units with binary prefixes, you should instead select one kilo binary byte (kibibyte), which is equal to 1,024 bytes. Whatever display unit you have chosen, you can always enter the quantities in the unit of your choice, for example 1000000B or 1000kB.
 .SH SEE ALSO
 .BR fdisk (8),
 .BR mkfs (8),
-.BR cfdisk (8)
+.BR parted (8)
 The \fIcfdisk\fP program is fully documented in the
 .BR info(1)
 format
 @setfilename cfdisk.info
 @settitle GNU cfdisk User's Manual
 
+@set UPDATED 19 August 2006
+@set UPDATED-MONTH August 2006
+@set EDITION 0.0.1
+@set VERSION 0.0.1
+
 @comment @documentencoding ISO-8859-1
 
 @set lq ``
 @set rq ''
 
+@ifnottex @c texi2pdf don't understand copying and insertcopying ???
 @c modifications must also be done in the titlepage
 @copying
 Copyright @copyright{} 2006
 Texts.  A copy of the license is included in the section entitled ``GNU
 Free Documentation License''.
 @end copying
+@c WTF does the info get the copying output and the plaintext output not ????
+@ifplaintext
 @insertcopying
+@end ifplaintext
+@end ifnottex
+
 
 @titlepage
 @title GNU cfdisk User Manual
-@subtitle GNU cfdisk
+@subtitle GNU cfdisk, version @value{VERSION}, @value{UPDATED}
 @author Milko Krasnomirov Krachounov @email{exabyte@@3mhz.net}
 
 @c @page
 * cfdisk: (cfdisk).                         GNU cfdisk User Manual
 @end direntry
 
+@ifnottex
 @node Top
 @top GNU cfdisk User Manual
+@c WTF doesn't texi2html include the titlepage?
+@ifhtml
+@insertcopying 
+@end ifhtml
+
+This document describes the use of GNU Cfdisk, a curses-based program
+for creating, destroying, resizing, checking and copying hard drive
+partitions, and the file systems on them.
+@end ifnottex
 
 @shortcontents
 
 Sets the default display units to @i{UNIT}. A list of possible units
 is given below.
 
-@item @b{@minus{}l, @minus{}@minus{}list-partition-types}
+@item @b{@minus{}t, @minus{}@minus{}list-partition-types}
 Displays a list of supported partition types and features.
 
 @end table
 Quits the program. If you have made changes and you haven't commited them to the disk, they will be lost.
 
 @item @b{h}
-Displays a short help. You don't need it after you have read this manual.
+Displays a short help. If you have reached this point, it is highly unlikely
+that you need it.
 
 
 @end table
+.TH CFDISK 8 "18 August, 2006" fdisk "GNU fdisk Manual"
+.SH NAME
+GNU fdisk, lfdisk, gfdisk - manipulate partition tables on a hard drive
+.SH SYNOPSIS
+.B fdisk
+[options] [device]
+.SH DESCRIPTION
+.B fdisk
+is a disk partition manipulation program, which allows you to create, destroy, resize, move and copy partitions on a hard drive using a menu-driven interface. It is useful for organising the disk space on a new drive, reorganising an old drive, creating space for new operating systems, and copying data to new hard disks. For a list of the supported partition types, see the
+.B --list-partition-types
+option below.
+.PP
+It comes in two variants, gfdisk and lfdisk. Lfdisk aims to resemble Linux fdisk 2.12, while gfdisk supports more advanced disk operations, like resizing the filesystem, moving and copying partitions. When starting fdisk, the default is to run gfdisk.
+.SH OPTIONS
+.TP
+.B -h, --help
+displays a help message.
+.TP
+.B -v, --version
+displays the program's version.
+.TP
+.B -L, --linux-fdisk
+turns on Linux fdisk compatibility mode. This is the same as running lfdisk.
+.TP
+.B -G, --gnu-fdisk
+turns off Linux fdisk compatibility mode.
+.TP
+.B -i, --interactive
+where necessary, prompts for user intervention.
+.TP
+.B -p, --script
+never prompts for user intervention.
+.TP
+.B -l, --list
+lists the partition table on the specified device and exits. If there is no device specified, lists the partition tables on all detected devices.
+.TP
+.B -u, --sector-units
+use sectors, instead of cylinders for a default unit.
+.TP
+.B -s, --size=\fIDEVICE\fP
+prints the size of the partition on \fIDEVICE\fP is printed on the standard output.
+.TP
+.B -t, --list-partition-types
+displays a list of supported partition types and features.
+.PP
+The options -b, -C, -H and -S, taking one argument, are ignored for Linux fdisk compatibility. 
+.SH BUGS
+Before editing a BSD disklabel, the partition with the disklabel should already exist on the disk and be detected by the OS. If you have created a BSD-type partition, you need to write the changes to the disk. If fdisk fails to notify the OS about the changes in partition table, you need to restart your computer. As fdisk tries to guess the device holding the BSD disklabel, it might fail to edit it at all, even if the OS has detected it. In this case you are adviced to simply open the device with fdisk directly. It is possible that it doesn't work on some operating systems.
+.PP
+Getting the size of a partition with -s might fail, if fdisk fails to guess the disk device, for the same reasons as with the previous bug.
+.SH SEE ALSO
+.BR mkfs (8),
+.BR cfdisk (8),
+.BR parted (8)
+The \fIfdisk\fP program is fully documented in the
+.BR info(1)
+format
+.IR "GNU fdisk User Manual"
+manual.
 @setfilename fdisk.info
 @settitle GNU fdisk User's Manual
 
+@set UPDATED 19 August 2006
+@set UPDATED-MONTH August 2006
+@set EDITION 0.0.1
+@set VERSION 0.0.1
+
+
 @comment @documentencoding ISO-8859-1
 
 @set lq ``
 @set rq ''
 
+@ifnottex @c texi2pdf don't understand copying and insertcopying ???
 @c modifications must also be done in the titlepage
 @copying
-Copyright @copyright{} 2005, 2006
+Copyright @copyright{} 2006
 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 Texts.  A copy of the license is included in the section entitled ``GNU
 Free Documentation License''.
 @end copying
+@c WTF does the info get the copying output and the plaintext output not ????
+@ifplaintext
 @insertcopying
+@end ifplaintext
+@end ifnottex
+
 
 @titlepage
 @title GNU fdisk User Manual
-@subtitle GNU fdisk
+@subtitle GNU fdisk, version @value{VERSION}, @value{UPDATED}
 @author Leslie Patrick Polzer @email{polzer@@gnu.org}
+@author Milko Krasnomirov Krachounov @email{exabyte@@3mhz.net}
 
 @c @page
 @c @vskip 0pt plus 1filll
 
 @c modifications must also be done in the copying block
-Copyright @copyright{} 2005, 2006
+Copyright @copyright{} 2006
 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 Free Documentation License''.
 @end titlepage
 
+
+@dircategory GNU partitioning software
+@direntry
+* fdisk: (fdisk).                          GNU fdisk User Manual
+@end direntry
+
+@ifnottex
 @node Top
 @top GNU fdisk User Manual
+@c WTF doesn't texi2html include the titlepage?
+@ifhtml
+@insertcopying 
+@end ifhtml
+
+This document describes the use of GNU Cfdisk, a curses based program
+for creating, destroying, resizing, checking and copying hard drive
+partitions, and the file systems on them.
+@end ifnottex
+
+@shortcontents
 
 @menu
-* Name::
-* Invoking fdisk::
-* Description::
-* Options::
+* About::
+* Using fdisk::
 * Bugs::
 * See also::
 * Copying this manual::
 @end menu
 
 
+@node About
+@chapter About
+@menu
+* Name::
+@end menu
+
 @node Name
 @section Name
 
-GNU fdisk @minus{} partition table manipulator (clone of Linux fdisk)
+GNU fdisk @minus{} menu driven partition table manipulator, similar to Linux
+fdisk. It has two variants, lfdisk and gfdisk, lfdisk aims to be close to 
+Linux fdisk, while gfdisk supports the more advanced disk operations like
+partition resizing. When fdisk is called, the default is to run gfdisk. 
+
+@node Using fdisk
+@chapter Using fdisk
+
+@menu
+* Invoking fdisk::
+* Overview::
+* Options::
+* Commands and usage::
+@end menu
 
 @node Invoking fdisk
 @section Invoking fdisk
 
-@b{fdisk [@minus{}u] [@minus{}b }@i{sectorsize}@b{]}
-@b{[@minus{}C }@i{cyls}@b{] [@minus{}H }@i{heads}@b{]
-[@minus{}S }@i{sects}@b{] }@i{device}
-@b{fdisk @minus{}l [@minus{}u] [}@i{device ...}@b{]}
-@b{fdisk @minus{}s }@i{partition ...}
-@b{"fdisk}@i{@minus{}v}
+@b{fdisk [options] [device]}
 
-@node Description
+@node Overview
 
-@section Description
+@section Overview
 
-Hard disks can be divided into one or more logical disks called
-@i{partitions}@r{.} This division is described in the
-@i{partition table} found in sector 0 of the disk.
+Hard disks can be divided into logical disks called @i{partitions}
+(or @i{disk slices} in the BSD world), which are described in a @i{partition table}, 
+which is also called a @i{disklabel}.
 
-In the BSD world one talks about `disk slices' and a `disklabel'.
+For ordinary use, like file storage or operation system installation, you
+will most likely need at least one partition, although with most modern operating system,
+you might also want to create several partitions, including one for swap space. For example,
+you usually create a seperate partition for home directories. For more information on what
+partitions you need for your operating system, look at its installation manual.
 
-Linux needs at least one partition, namely for its root file system.
-It can use swap files and/or swap partitions, but the latter are more
-efficient. So, usually one will want a second Linux partition
-dedicated as swap partition.
-On Intel compatible hardware, the BIOS that boots the system
-can often only access the first 1024 cylinders of the disk.
-For this reason people with large disks often create a third partition,
-just a few MB large, typically mounted on
-@i{/boot}@r{,} to store the kernel image and a few auxiliary files
-needed at boot time, so as to make sure that this stuff is accessible to
-the BIOS. There may be reasons of security, ease of administration and
-backup, or testing, to use more than the minimum number of partitions.
+@b{GNU fdisk} is a menu driven program for creating and editing partition tables.
+It has support for DOS and MAC type partition tables, BSD and SUN type disklabels
+and others.
 
-@b{fdisk} (in the first form of invocation)
-is a menu driven program for creation and manipulation of
-partition tables.
-It understands DOS type partition tables and BSD or SUN type disklabels.
-
-The @i{device} is usually one of the following:
+On most GNU/Linux distributions @i{device} is usually one of the following:
 
 @c ---------------------------------------------------------------------
 @display
-
 @c ---------------------------------------------------------------------
 @quotation
 /dev/hda
 /dev/sdb
 
 @end quotation
-
 @end display
 
-(/dev/hd[a-h] for IDE disks, /dev/sd[a-p] for SCSI disks,
-/dev/ed[a-d] for ESDI disks, /dev/xd[ab] for XT disks).
-A device name refers to the entire disk.
+IDE disks are usually using /dev/hd[a-h] for device names, SCSI disks - /dev/sd[a-p].
+The partitions will take the device name followed by the partition number, e.g.
+/dev/hda1. If you are using a GNU/Linux operating system, you can see
+@i{/usr/src/linux/Documentation/devices.txt} for more infomation on
+device naming.
 
-The @i{partition} is a @i{device} name followed by a partition number.
-For example, @b{/dev/hda1} is the first partition on the first IDE hard
-disk in the system. IDE disks can have up to 63 partitions, SCSI disks
-up to 15. See also @i{/usr/src/linux/Documentation/devices.txt}@r{.}
+A DOS type partition table can have up to four `primary' partitions, which get
+numbers 1-4. One of the primary partitions may be used as an `extended' partition,
+which is used as a container for more partitions, which are called `logical' and
+take numbers starting from 5.
 
-A BSD/SUN type disklabel can describe 8 partitions,
-the third of which should be a `whole disk' partition.
-Do not start a partition that actually uses its first sector
-(like a swap partition) at cylinder 0, since that will
-destroy the disklabel.
-
-An IRIX/SGI type disklabel can describe 16 partitions,
-the eleventh of which should be an entire `volume' partition,
-while the ninth should be labeled `volume header'.
-The volume header will also cover the partition table, i.e.,
-it starts at block zero and extends by default over five cylinders.
-The remaining space in the volume header may be used by header
-directory entries.  No partitions may overlap with the volume header.
-Also do not change its type and make some file system on it, since
-you will lose the partition table.  Use this type of label only when
-working with Linux on IRIX/SGI machines or IRIX/SGI disks under Linux.
-
-A DOS type partition table can describe an unlimited number
-of partitions. In sector 0 there is room for the description
-of 4 partitions (called `primary'). One of these may be an
-extended partition; this is a box holding logical partitions,
-with descriptors found in a linked list of sectors, each
-preceding the corresponding logical partitions.
-The four primary partitions, present or not, get numbers 1-4.
-Logical partitions start numbering from 5.
-
-In a DOS type partition table the starting offset and the size
-of each partition is stored in two ways: as an absolute number
-of sectors (given in 32 bits) and as a Cylinders/Heads/Sectors
-triple (given in 10+8+6 bits). The former is OK - with 512-byte
-sectors this will work up to 2 TB. The latter has two different
-problems. First of all, these C/H/S fields can be filled only
-when the number of heads and the number of sectors per track
-are known. Secondly, even if we know what these numbers should be,
-the 24 bits that are available do not suffice.
-DOS uses C/H/S only, Windows uses both, Linux never uses C/H/S.
-
-If possible, @b{fdisk} will obtain the disk geometry automatically.
-This is not necessarily the physical disk geometry (indeed, modern disks
-do not really have anything like a physical geometry, certainly not
-something that can be described in simplistic Cylinders/Heads/Sectors
-form), but is the disk geometry that MS-DOS uses for the partition
-table.
-
-Usually all goes well by default, and there are no problems if
-Linux is the only system on the disk. However, if the disk has
-to be shared with other operating systems, it is often a good idea
-to let an fdisk from another operating system make at least one
-partition. When Linux boots it looks at the partition table, and
-tries to deduce what (fake) geometry is required for good
-cooperation with other systems.
-
-Whenever a partition table is printed out, a consistency check is performed
-on the partition table entries.  This check verifies that the physical and
-logical start and end points are identical, and that the partition starts
-and ends on a cylinder boundary (except for the first partition).
-
-Some versions of MS-DOS create a first partition which does not begin
-on a cylinder boundary, but on sector 2 of the first cylinder.
-Partitions beginning in cylinder 1 cannot begin on a cylinder boundary, but
-this is unlikely to cause difficulty unless you have OS/2 on your machine.
-
-A sync() and a BLKRRPART ioctl() (reread partition table from disk)
-are performed before exiting when the partition table has been updated.
-Long ago it used to be necessary to reboot after the use of fdisk.
-I do not think this is the case anymore - indeed, rebooting too quickly
-might cause loss of not-yet-written data. Note that both the kernel
-and the disk hardware may buffer data.
+A BSD/SUN type disklabel can hold up to 8 partitions, and an IRIX/SGI type disk label,
+called `dvh' in fdisk, can hold up to 16.
 
 @node Options
 
 @section Options
 
 @table @code
-@item @b{@minus{}b }@i{sectorsize}
-This option is currently ignored.
-@c Specify the sector size of the disk. Valid values are 512, 1024, or 2048.
-@c (Recent kernels know the sector size. Use this only on old kernels or
-@c to override the kernel's ideas.)
+@item @b{@minus{}h, @minus{}@minus{}help}
+Displays a help message.
 
-@item @b{@minus{}C }@i{cyls}
-@c Specify the number of cylinders of the disk.
-This option is currently ignored.
+@item @b{@minus{}v, @minus{}@minus{}version}
+Displays the program's version.
 
-@item @b{@minus{}H }@i{heads}
-This option is currently ignored.
-@c Specify the number of heads of the disk. (Not the physical number,
-@c of course, but the number used for partition tables.)
-@c Reasonable values are 255 and 16.
+@item @b{@minus{}L, @minus{}@minus{}linux-fdisk}
+Turns  on  Linux  fdisk  compatibility mode. This is the same as running lfdisk.
+In this mode, only disk operations supported by Linux fdisk will be available.
 
-@item @b{@minus{}S }@i{sects}
-@c This option is currently ignored.
-@c Specify the number of sectors per track of the disk.
-@c (Not the physical number, of course, but the number used for
-@c partition tables.)
-@c A reasonable value is 63.
+@item @b{@minus{}G, @minus{}@minus{}gnu-fdisk}
+Turns off Linux fdisk compatibility mode. You will be able to perform more
+operations on the disk - create on a partition, resize, move or copy a partition,
+with the filesystem on it, or automatically detect deleted partitions.
 
-@item @b{@minus{}l}
-List the partition tables for the specified devices and then exit.
-If no devices are given, those mentioned in @i{/proc/partitions}
-(if that exists) are used.
+@item @b{@minus{}i, @minus{}@minus{}interactive}
+Where necessary, prompts for user intervention. This is the default, when the
+program is started at a terminal.
 
-@item @b{@minus{}u}
-When listing partition tables, give sizes in sectors instead
-of cylinders.
+@item @b{@minus{}p, @minus{}@minus{}script}
+Never prompts for user intervention. This is the default, when the program is
+not started at a terminal, when it is called from another program. You can use
+this mode for scripting, fdisk tries to perform the select the most suitable
+choice in every case.
 
-@item @b{@minus{}s }@i{partition}
-The @i{size} of the partition (in blocks) is printed on the standard output.
+@item @b{@minus{}l, @minus{}@minus{}list}
+Lists the partition table on the specified  device  and  exits.  If
+there  is  no  device  specified, lists the partition tables on all
+detected devices.
 
-@item @b{@minus{}v}
-Print version number of @b{fdisk} program and exit.
+@item @b{@minus{}u, @minus{}@minus{}unit-sector}
+Use sectors, instead of cylinders for a default unit.
 
+@item @b{@minus{}s, @minus{}@minus{}size=}@i{DEVICE}
+Displays the size of the partition on @i{DEVICE} is printed on the standard output.
+
+@item @b{@minus{}t, @minus{}@minus{}list-partition-types}
+Displays a list of supported partition types and features.
+
+For compatibility with Linux fdisk, GNU fdisk also silently ignores options 
+@b{-b}, @b{-C}, @b{-H} and @b{-S}, all taking one parameter.
+
+@end table
+
+@node Commands and usage
+
+@section Commands and usage
+
+When @b{GNU fdisk} is started, a simple command line interface is displayed. 
+A list with the available commands and a short description can displayed by entering
+@b{m}. More detailed information about every command is given below. Most operations
+are not performed immediately, but only after the user decides to write the partition
+table to the disk. Those that need to write to the disk immediately, warn the user
+about it and are only available when not running in Linux fdisk compatibility mode.
+The default unit used is cylinder and can be changed to sector. Partition sizes
+can be specified in any other available unit, though.
+
+@table @code
+@item @b{m}
+A command obsoleted by reading this manual.
+
+@item @b{p}
+Displays the partition table on the disk. It shows information like
+the start and end of the partitions, and their partition number. This
+is needed for using most of the commands below, so it is a good idea
+to list the partition table before using them. The start and end of
+the partition are displayed in the unit that you have selected for
+fdisk, while the size is displayed in blocks.
+
+@item @b{a}
+Toggles the bootable flag on a partition. On a DOS partition table type
+the partition with the bootable flag is the one that the system will boot
+from if there is no a boot manager in the master record. Make sure you 
+have a bootable partition, and it is indeed bootable. You will be
+asked for a partition number.
+
+@item @b{d}
+Delete the selected partition so you can use it to create another partition on the free space left by it.
+
+
+
+@item @b{n}
+Creates a new partition on some free space in the partition table. You will be 
+asked for the type of partition you want to create, and you can enter @b{p} for
+primary, @b{e} for extended or @b{l} for logical. Make sure that you select a type, 
+that can be created in the position that you want to create it. You can create
+logical partition only inside the extended. You will be asked about the start
+and end of the partition. If you put a @i{+} before the end, it will be regarded
+as size. You can also specify the start and end or size in a different unit,
+please check the next section for more information. If you are using gfdisk, 
+you will also be asked about the filesystem type and whether you want to create
+a filesystem on the partition. If you don't want to select a filesystem type,
+just select the default and you can later change the system type with the
+@b{t} command.
+
+@item @b{o}
+Creates a new empty DOS partition table. Use this command if you want to
+start the partition table on the disk from scratch, deleting all the partitions
+that are currently residing on it.
+
+@item @b{s}
+Creates a new empty SUN disklabel. If you are using a disk with a SUN disklabel, 
+use this command if you want to start the partition table on the disk from scratch,
+deleting all the partitions that are currently residing on it.
+
+@item @b{l}
+Lists the known filesystem types for the partition table or disklabel on the disk.
+This is not about the supported filesystem types, but about the way the disklabel
+marks the filesystem that is supposed to be residing on the partition. It can
+differ from the real filesystem, although it is not recommended.
+
+@item @b{t}
+Changes the filesystem type of a partition. This does not touch the actual filesystem
+on the partition, it just changes the field in the partition table that marks
+the filesystem that is supposed to be residing on the partition. If you are 
+running gfdisk, when you select a filesystem during the creation of a new
+partition, the most appropriate value for this field is selected.
+
+@item @b{w}
+Writes the partition table to the disk, notifies the operating system about the
+changes and quits the program. If fdisk wasn't able to notify the OS, you
+will have to restart the computer in order to use the new partition table.
+
+@item @b{q}
+Quits the program without saving the changes.
+
+@item @b{x}
+Displays a menu with extra operations, which are described below.
+@end table
+
+There is a menu with extra functionality in GNU fdisk. In gfdisk, it
+will include the specific to gfdisk commands. Everything is described below.
+
+The extra commands in lfdisk include
+
+@table @code
+@item @b{f}
+Fixes the order of the partitions in the partition table. This is
+useful, when for example on an DOS partition table, the partitions have
+a wrong order and you want to order them in order they are placed on
+the disk.
+@end table
+
+
+The extra commands in gfdisk include
+@table @code
+@item @b{h}
+Checks the consistency of the filesystem.  It is useful to see whether
+it is safe to perform operations like resize on the partitions. It
+performs a very basic check on the filesystem, so if you want to make
+a more thorough test or fix the errors on the filesystem, you should an
+external utility like e2fsck for ext2 or reiserfsck for reiserfs. Please
+note that the check is limited on some filesystem types (ext2, ext3 and
+reiserfs at the time of writing of the manual), but if the partition
+contains errors resize will gracefully fail without destroying the filesystem.
+
+@item @b{v}
+Moves the partition to another location on the disk. It asks for the number 
+of the partition you want to move. This command works in the same
+way as the new partition command and asks same questions, see above.
+The new location can't overlap with the current location. If this is what
+you need, you should try using the resize function, instead. Moving the
+partition requires that all changes you made so far are written to the disk. 
+
+@item @b{c}
+Rescues a partition with a supported filesystem, that has been deleted. 
+You specify the start and end of the region where you want to look for
+the start of the partition.
+
+@item @b{z}
+Resizes the partition and its filesystem, if supported. You will be asked
+for the number of the partition, and the new size and end. Some
+supported filesystem types require that the start of the partition
+stays fixed. This command requires that all changes you made so far
+are written to the disk.
+
+@item @b{o}
+Copies another partition over an already created partition on the disk.
+You can copy a partition from a different disk. You will be
+asked for the device of the disk that you want to copy from and the
+number of the partitions on both disks. This requires that all
+changes you made so far are written to the disk.
+
+@item @b{k}
+Creates a new file system on the selected partition. You will be asked
+to choose the filesystem type. The filesystem field in the partition table
+or disklabel is updated automatically. Please note that this requires that all
+changes you made so far are commited to the disk. If there is already
+a filesystem on the partition, it will be destroyed.
 @end table
 
 @node Bugs
 
-@section Bugs
+@chapter Bugs
+disk and be detected by the OS. If you have created a BSD-type partition, you need to write the changes to the disk. If fdisk fails to notify the OS about the changes in partition table, you need to restart your computer. As fdisk tries to guess the device holding the BSD disklabel, it might fail to edit it at all, even if the OS has detected it. In this case you are adviced to simply open the device with fdisk directly. It is possible that it doesn't work on some operating systems.
 
-There are several *fdisk programs around.
-Each has its problems and strengths.
-Try them in the order @b{cfdisk}@r{,} @b{fdisk}@r{,} @b{sfdisk}@r{.}
-(Indeed, @b{cfdisk} is a beautiful program that has strict requirements on
-the partition tables it accepts, and produces high quality partition
-tables. Use it if you can.
-@b{fdisk}
-is a buggy program that does fuzzy things - usually it happens to
-produce reasonable results. Its single advantage is that it has
-some support for BSD disk labels and other non-DOS partition tables.
-Avoid it if you can.
-@b{sfdisk}
-is for hackers only - the user interface is terrible, but it is
-more correct than fdisk and more powerful than both fdisk and cfdisk.
-Moreover, it can be used noninteractively.)
 
-These days there also is @b{parted}@r{.}
-The cfdisk interface is nicer, but parted does much more: it not only
-resizes partitions, but also the filesystems that live in them.
-
-@c FIXME: still true?
-The IRIX/SGI type disklabel is currently not supported by the kernel.
-Moreover, IRIX/SGI header directories are not fully supported yet.
-
-The option `dump partition table to file' is missing.
+Getting the size of a partition with -s might fail, if fdisk fails to guess the disk device, for the same reasons as with the previous bug.
 
 @node See also
 
-@section See also
+@chapter See also
 
 @b{cfdisk}@r{(8),}
 @b{mkfs}@r{(8),}
-@b{parted}@r{(8),}
-@b{sfdisk}@r{(8)}
+@b{parted}@r{(8)}
 
 @node Copying this manual
 @appendix Copying this manual
 	{"arrow-cursor", 'a', NULL, 	N_("use an arrow cursor instead of reverse video")},
 	{"new-table",	'z', NULL,	N_("create a new partition table on the disk")},
 	{"units",	'u', N_("UNIT"),N_("sets the default display units to UNIT")},
-	{"list-partition-types", 'l', NULL, N_("displays a list of supported partition types")},
+	{"list-partition-types", 't', NULL, N_("displays a list of supported partition types")},
         {NULL, 0, NULL, NULL}
 };
 
 	exit(0);
 }
 
-static void
-_print_flag (int *i, const char *name) {
-	printf(*i == 0 ? "%s" : ",%s", name);
-	(*i)++;
-}
-
-static void
-print_partition_types() {
-	PedFileSystemType *walk;
-	char buf[SMALLBUF];
-	for (walk = ped_file_system_type_get_next(NULL); walk; walk = ped_file_system_type_get_next(walk)) {
-		int i = 0;
-		printf ("%-15s",walk->name);
-		if (walk->ops->open) _print_flag(&i,_("open"));
-		if (walk->ops->create) _print_flag(&i,_("create"));
-		if (walk->ops->check) _print_flag(&i,_("check"));
-		if (walk->ops->copy) _print_flag(&i,_("copy"));
-		if (walk->ops->resize) _print_flag(&i,_("resize"));
-		printf("\n");
-	}
-	exit(0);
-}
-
 int
 main (int argc, char **argv) {
 	PedUnit unit = -1;
 		{ "arrow-cursor", no_argument, NULL, 'a' },
 		{ "units", required_argument, NULL, 'u' },
 		{ "help", no_argument, NULL, 'h' },
-		{ "list-partition-types", no_argument, NULL, 'l' },
+		{ "list-partition-types", no_argument, NULL, 't' },
 		{ NULL, 0, NULL, 0 }
 	};
 
 	int opt,option_index;
-	while ((opt = getopt_long(argc,argv, "hazvlu:", long_options, &option_index)) != -1) {
+	while ((opt = getopt_long(argc,argv, "hazvtu:", long_options, &option_index)) != -1) {
 #else
 	int opt;
-	while ((opt = getopt(argc,argv,"hazvlu:")) != -1) {
+	while ((opt = getopt(argc,argv,"hazvtu:")) != -1) {
 #endif		
 		switch (opt) {
 			case 'v':
 				print_version();
 			case 'h':
 				print_usage();
-			case 'l':
+			case 't':
 				print_partition_types();
 			case 'a':
 				arrow_cursor = 1;
 	} while (part && (part->type & skip));
 	return part;
 }
+
+
+static void
+_print_flag (int *i, const char *name) {
+	printf(*i == 0 ? "%s" : ",%s", name);
+	(*i)++;
+}
+
+
+void
+print_partition_types() {
+	PedFileSystemType *walk;
+	char buf[SMALLBUF];
+	for (walk = ped_file_system_type_get_next(NULL); walk; walk = ped_file_system_type_get_next(walk)) {
+		int i = 0;
+		printf ("%-15s",walk->name);
+		if (walk->ops->open) _print_flag(&i,_("open"));
+		if (walk->ops->create) _print_flag(&i,_("create"));
+		if (walk->ops->check) _print_flag(&i,_("check"));
+		if (walk->ops->copy) _print_flag(&i,_("copy"));
+		if (walk->ops->resize) _print_flag(&i,_("resize"));
+		printf("\n");
+	}
+	exit(0);
+}
 extern PedPartition* part_list_prev (PedPartition*, PedPartitionType skip);
 extern PedPartition* part_list_next (PedPartition*, PedPartitionType skip);
 
+
+/* Other cfdisk/fdisk common functions */
+extern void print_partition_types();
+
 #endif
 	time_t	predicted_time_left;
 } TimerContext;
 
+
+/* NOTE: options and options_help MUST be in the same order and count */
 static struct option	options[] = {
 	/* name, has-arg, string-return-val, char-return-val */
 	{"help",	0, NULL, 'h'},
 	{"list",        0, NULL, 'l'},
+	{"size",	1, NULL, 's'},
 	{"linux-fdisk", 0, NULL, 'L'},
 	{"gnu-fdisk",   0, NULL, 'G'},
 	{"interactive",	0, NULL, 'i'},
-	{"script",	0, NULL, 's'},
+	{"script",	0, NULL, 'p'},
+	{"sector-units",0, NULL, 'u'},
+	{"list-partition-types", 0, NULL, 't'},
 	{"version",	0, NULL, 'v'},
 	{NULL,		0, NULL, 0}
 };
 #endif
 
+
+/* NOTE: options and options_help MUST be in the same order and count */
 static char*	options_help [][2] = {
 	{"help",	N_("displays this help message")},
-	{"list",        N_("List partition table(s)")},
-	{"linux-fdisk", N_("Enable Linux fdisk compatibility mode")},
-	{"gnu-fdisk",   N_("Disable Linux fdisk compatibility mode")},
+	{"list",        N_("list partition table(s)")},
+	{"size",	N_("show partition size")},
+	{"linux-fdisk", N_("enable Linux fdisk compatibility mode")},
+	{"gnu-fdisk",   N_("disable Linux fdisk compatibility mode")},
 	{"interactive",	N_("where necessary, prompts for user intervention")},
 	{"script",	N_("never prompts for user intervention")},
+	{"sector-units",N_("use sectors instead of cylinder as a default unit.")},
+	{"list-partition-types", N_("displays a list of supported partition types")},
 	{"version",	N_("displays the version")},
 	{NULL,		NULL}
 };
 
 int fdisk_compatibility_mode = 0;
 int fdisk_opt_script_mode;
-int fdisk_list_table;
+int fdisk_list_table = 0;
+const char *fdisk_part_size = NULL;
 
 static char* number_msg = N_(
 "NUMBER is the partition number used by Linux.  On MS-DOS disk labels, the "
 	return perform_cp(*disk,NULL,UI_WARN_COMMIT);
 }
 
+/* FIXME: Doesn't work correctly without getopt.h */
 void 
 fdisk_print_options_help ()
 { 
         int		i; 
-
- 	for (i=0; options_help [i][0]; i++) { 
- 		printf ("  -%c, --%-23.23s %s\n", 
- 			options_help [i][0][0], 
+#ifdef HAVE_GETOPT_H
+ 	for (i=0; options_help [i][0] && options[i].val; i++) {
+#else 
+#warning Printing help without getopt.h is broken. Fix it.
+	for (i=0; options_help [i][0]; i++) {
+#endif
+ 		printf ("  -%c, --%-23.23s %s\n",
+#ifdef HAVE_GETOPT_H 
+ 			options [i].val,
+#else
+			options[i][0][0],
+#endif 
  			options_help [i][0], 
  			_(options_help [i][1])); 
  	} 
 	return 0;
 }
 
+static void
+print_partitio_size(PedDisk *disk)
+{
+	int t = atoi(fdisk_part_size);
+	PedPartition *part = ped_disk_get_partition(disk,t);
+	if (!part) {
+		printf(_("There is no partition %d on %s\n"), t, disk->dev->path);
+		exit(1);
+	}
+	else {
+		PedCHSGeometry* 	chs;
+		PedSector               sectors;
+		PedSector		cyl_size;
+		PedSector		cyl_start;
+		PedSector		cyl_end;
+		PedSector		sect_size;
+		PedSector		heads;
+		PedSector		total_cyl;
+	
+		chs          = &(disk->dev)->hw_geom;
+		sectors      = chs->sectors;
+		heads        = chs->heads;
+		total_cyl    = heads * sectors;
+		sect_size    = disk->dev->sector_size;
+		cyl_start     = (part->geom.start / (total_cyl)) + 1; 
+		cyl_end       = (part->geom.end   / (total_cyl)) + 1;
+		//ped_unit_set_default(PED_UNIT_CYLINDER);
+
+		printf("%lld\n",
+			((cyl_end * total_cyl) - ((part->num == 1) ? 
+			(cyl_start * sectors) : (cyl_start * total_cyl))) / 
+			(1024 / sect_size)
+		);
+		exit(0);
+	}
+	
+}
+
 static void 
 do_list_devices (PedDisk* disk) {
         if (disk == NULL) {
 _(" o   copy the partition over another partition"),
 NULL), NULL, 1));
 
+	fdisk_command_register (fdisk_ex_menu_commands, fdisk_command_create (
+		str_list_create_unique ("k", _("k"), NULL),
+		do_mkfs,
+		str_list_create (
+_(" k   creates a filesystem on a partition"),
+NULL), NULL, 1));
+
 
   }
 
 static void
 _version ()
 {
-	printf ("%s for %s", interface_name, fdisk_prog_name);
+	printf ("%s\n", interface_name);
 	exit (0);
 }
 
 
 	while (1)
 	{
+	/* NOTE: b, C, H, S are ignored, for Linux fdisk compatibility */
 #ifdef HAVE_GETOPT_H
-		opt = getopt_long (*argc_ptr, *argv_ptr, "hlisvLG",
+		opt = getopt_long (*argc_ptr, *argv_ptr, "hlipvLGs:utb:C:H:S:",
 				   options, NULL);
 #else
-		opt = getopt (*argc_ptr, *argv_ptr, "hlisvLG");
+		opt = getopt (*argc_ptr, *argv_ptr, "hlipvLGs:utb:C:H:S:");
 #endif
 		if (opt == -1)
 			break;
 			case 'h': fdisk_help_msg (); break;
 			case 'l': fdisk_list_table = 1; break;
 			case 'i': fdisk_opt_script_mode = 0; break;
-			case 's': fdisk_opt_script_mode = 1; break;
+			case 'p': fdisk_opt_script_mode = 1; break;
 			case 'G': fdisk_compatibility_mode = 0; break;
 			case 'L': fdisk_compatibility_mode = 1; break;
+			case 's': fdisk_part_size = optarg; break;
+			case 't': print_partition_types(); break;
+			case 'u': ped_unit_set_default(PED_UNIT_SECTOR);
+			          cylinder_unit = 0;
+			          break;
 			case 'v': _version (); break;
+			/* For Linux fdisk compatibility */
+			/*
+			case 'b': break;
+			case 'C': break;
+			case 'H': break;
+			case 'S': break;
+			*/
 		}
 	}
 
 _choose_device (int* argc_ptr, char*** argv_ptr)
 {
 	PedDevice*	dev;
+	const char*	path = NULL;
 
+	/* if we want partition size */
+	if (fdisk_part_size) {
+		/* TODO: Make this more portable */
+		int t,s;
+		char* temp;
+		t = strlen(fdisk_part_size);
+		/* We count the digits at the end */
+		for (s = 0; s < t && isdigit(fdisk_part_size[t-s-1]); s++); 
+
+		if (s == 0) {
+			printf(_("You must specify a partition\n"));
+			exit(0);
+			
+		}
+		/* For names like ad0s0, cut two chars */
+		if (t > 2 && (fdisk_part_size[t-s-1] == 's' || 
+		              fdisk_part_size[t-s-1] == 'p')
+		          && isdigit(fdisk_part_size[t-s-2]))
+		{
+			temp = calloc(sizeof(char), t-s);
+			snprintf(temp, t-s, "%s", fdisk_part_size);
+		}
+		/* Otherwise, cut one char */
+		else //if (t > 1 && !isdigit(fdisk_part_size[t-2]))
+		{
+			temp = calloc(sizeof(char), t-s+1);
+			snprintf(temp, t-s+1, "%s", fdisk_part_size);
+		}
+		
+		path = temp;
+		/* We set the pointer to point to the digits */
+		fdisk_part_size += t - s;
+	}
+	else if (*argc_ptr) {
+		path = (*argv_ptr) [0];
+	}
 	/* specified on comand line? */
-	if (*argc_ptr) {
-		dev = ped_device_get ((*argv_ptr) [0]);
-		if (!dev)
+	if (path) {
+		dev = ped_device_get (path);
+		if (!dev) {
+			printf(_("Unable to open %s\n"), path);
 			return NULL;
-		(*argc_ptr)--;
-		(*argv_ptr)++;
+		}
+		if (*argc_ptr) {
+			(*argc_ptr)--;
+			(*argv_ptr)++;
+		}
 
-		if (!ped_device_open (dev))
-		  return NULL;
-		
+		if (!ped_device_open (dev)) {
+			printf(_("Unable to open %s\n"), path); 
+			return NULL;
+		}
 		return dev;
 	}
 	return NULL;	
 	_init_bsd_menu_commands ();
 	_init_main_menu_commands ();
 
-	if (!dev)
+	if (!dev) {
 		goto error_done_commands;
-
+	}
 	_init_uicalls();
 
 	if (!uiquery.timer)
 
 	if (!disk) 
 	        return 1;
-
+	/* Show the size of the partition */
+	if (fdisk_part_size) {
+		print_partitio_size(disk);
+	}
 	/* List the specified disk. */
 	if (fdisk_list_table)
 	         do_list_devices(disk);
 #endif
 
 #endif /* HAVE_LIBREADLINE */
-char* interface_name = "GNU Fdisk 0.0.1";
-char* fdisk_prog_name = "GNU Parted " VERSION "\n";
+char* interface_name = "GNU Fdisk " VERSION;
 
 static char* banner_msg = N_(
 "Copyright (C) 1998 - 2006 Free Software Foundation, Inc.\n"
 
 	printf ("\n%s\n", _("OPTIONs:"));
 	fdisk_print_options_help ();
-
+/*
 	printf ("\n%s\n", _("COMMANDs:"));
 	fdisk_print_commands_help ((FdiskCommand**)NULL);
+*/
 	exit (0);
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.