Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-17-2004, 02:49 AM   #1
LQ Newbie
Registered: Jan 2004
Distribution: Suse & Mandrake
Posts: 10

Rep: Reputation: 0

Linux has at least 3 disk tools FDISK;CFDISK;SFDISK. Which one(s) are accurate. I had seen a post that cfdisk was not accurate in reading the partition tables correctly. It this true? If so, what can be done to REMOVE or FIX a problem in a program?
Old 07-17-2004, 04:21 AM   #2
Registered: Jun 2004
Location: India
Distribution: CLFS
Posts: 515

Rep: Reputation: 36
cfdisk is a curses-based disk partition table manipulator.cfdisk tries to read the current partition table from the disk drive. It is functionally identical to fdisk, but with a graphical user interface (GUI).Unless you are a system adminstrator,better stick with cfdisk.And I haven't heard of cfdisk producing erreneous partition tables.
sfdisk has four (main) uses: list the size of a partition, list the partitions on a device, check the partitions on a device, and repartition a device.

sfdisk -s partition gives the size of partition in blocks. This may be useful in connection with programs like mkswap or so. Here partition is usually something like /dev/hda1 or /dev/sdb12, but may also be an entire disk, like /dev/xda.

% sfdisk -s /dev/hda9
If the partition argument is omitted, sfdisk will list the sizes of all disks, and the total:

% sfdisk -s
/dev/hda: 208896
/dev/hdb: 1025136
/dev/hdc: 1031063
/dev/sda: 8877895
/dev/sdb: 1758927
total: 12901917 blocks

The second type of invocation: sfdisk -l [options] device will list the partitions on this device. If the device argument is omitted, the partitions on all hard disks are listed.

% sfdisk -l /dev/hdc

Disk /dev/hdc: 16 heads, 63 sectors, 2045 cylinders
Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/hdc1 0+ 406 407- 205096+ 83 Linux native
/dev/hdc2 407 813 407 205128 83 Linux native
/dev/hdc3 814 2044 1231 620424 83 Linux native
/dev/hdc4 0 - 0 0 0 Empty
The trailing - and + signs indicate that rounding has taken place, and that the actual value is slightly less (more). To see the exact values, ask for a listing with sectors as unit.

The third type of invocation: sfdisk -V device will apply various consistency checks to the partition tables on device. It prints `OK' or complains. The -V option can be used together with -l. In a shell script one might use sfdisk -V -q device which only returns a status.

The fourth type of invocation: sfdisk device will cause sfdisk to read the specification for the desired partitioning of device from its standard input, and then to change the partition tables on that disk. Thus, it is possible to use sfdisk from a shell script. When sfdisk determines that its standard input is a terminal, it will be conversational; otherwise it will abort on any error.

As a precaution, one can save the sectors changed by sfdisk:

% sfdisk /dev/hdd -O

Then, if you discover that you did something stupid before anything else has been written to disk, it may be possible to recover the old situation with

% sfdisk /dev/hdd -I

(This is not the same as saving the old partition table: a readable version of the old partition table can be saved using the -d option. However, if you create logical partitions, the sectors describing them are located somewhere on disk, possibly on sectors that were not part of the partition table before. Thus, the information the -O option saves is not a binary version of the output of -d.)

There are many options.

-v or --version
Print version number of sfdisk and exit immediately.
-? or --help
Print a usage message and exit immediately.
-T or --list-types
Print the recognized types (system Id's).
-s or --show-size
List the size of a partition.
-g or --show-geometry
List the kernel's idea of the geometry of the indicated disk(s).
-l or --list
List the partitions of a device.
Dump the partitions of a device in a format useful as input to sfdisk. For example,

% sfdisk -d /dev/hda > hda.out
% sfdisk /dev/hda < hda.out
will correct the bad last extended partition that the OS/2 fdisk creates.
-V or --verify
Test whether partitions seem correct. (See above.)
-i or --increment
Number cylinders etc. starting from 1 instead of 0.
-N number
Change only the single partition indicated. For example:

% sfdisk /dev/hdb -N5
will make the fifth partition on /dev/hdb bootable (`active') and change nothing else. (Probably this fifth partition is called /dev/hdb5, but you are free to call it something else, like `/my_equipment/disks/2/5' or so).
Make the indicated partition(s) active, and all others inactive.
-c or --id number [Id]
If no Id argument given: print the partition Id of the indicated partition. If an Id argument is present: change the type (Id) of the indicated partition to the given value. This option has the two very long forms --print-id and --change-id. For example:

% sfdisk --print-id /dev/hdb 5
% sfdisk --change-id /dev/hdb 5 83
first reports that /dev/hdb5 has Id 6, and then changes that into 83.

-uS or -uB or -uC or -uM
Accept or report in units of sectors (blocks, cylinders, megabytes, respectively). The default is cylinders, at least when the geometry is known.

-x or --show-extended
Also list non-primary extended partitions on output, and expect descriptors for them on input.

-C cylinders
Specify the number of cylinders, possibly overriding what the kernel thinks.

-H heads
Specify the number of heads, possibly overriding what the kernel thinks.

-S sectors
Specify the number of sectors, possibly overriding what the kernel thinks.

-f or --force
Do what I say, even if it is stupid.

-q or --quiet
Suppress warning messages.

-L or --Linux
Do not complain about things irrelevant for Linux.

-D or --DOS
For DOS-compatibility: waste a little space. (More precisely: if a partition cannot contain sector 0, e.g. because that is the MBR of the device, or contains the partition table of an extended partition, then sfdisk would make it start the next sector. However, when this option is given it skips to the start of the next track, wasting for example 33 sectors (in case of 34 sectors/track), just like certain versions of DOS do.) Certain Disk Managers and boot loaders (such as OSBS, but not LILO or the OS/2 Boot Manager) also live in this empty space, so maybe you want this option if you use one.

-E or --DOS-extended
Take the starting sector numbers of "inner" extended partitions to be relative to the starting cylinder boundary of the outer one, (like some versions of DOS do) rather than to the starting sector (like Linux does). (The fact that there is a difference here means that one should always let extended partitions start at cylinder boundaries if DOS and Linux should interpret the partition table in the same way. Of course one can only know where cylinder boundaries are when one knows what geometry DOS will use for this disk.)

--IBM or --leave-last
Certain IBM diagnostic programs assume that they can use the last cylinder on a disk for disk-testing purposes. If you think you might ever run such programs, use this option to tell sfdisk that it should not allocate the last cylinder. Sometimes the last cylinder contains a bad sector table.

Go through all the motions, but do not actually write to disk.

Only execute the BLKRRPART ioctl (to make the kernel re-read the partition table). This can be useful for checking in advance that the final BLKRRPART will be successful, and also when you changed the partition table `by hand' (e.g., using dd from a backup). If the kernel complains (`device busy for revalidation (usage = 2)') then something still uses the device, and you still have to unmount some file system, or say swapoff to some swap partition.

When starting a repartitioning of a disk, sfdisk checks that this disk is not mounted, or in use as a swap device, and refuses to continue if it is. This option suppresses the test. (On the other hand, the -f option would force sfdisk to continue even when this test fails.)

-O file
Just before writing the new partition, output the sectors that are going to be overwritten to file (where hopefully file resides on another disk, or on a floppy).

-I file
After destroying your filesystems with an unfortunate sfdisk command, you would have been able to restore the old situation if only you had preserved it using the -O flag.

Again,if you're not very experienced in partitioning hard disks,stick with cfdisk.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
fdisk, sfdisk, cfdisk: driving me crazy rosslaird Linux - Software 3 02-14-2005 02:21 PM
CFdisk does not see new HD but Fdisk does? BajaNick Linux - Software 6 08-28-2004 11:31 AM
Cant get fdisk or cfdisk to partition my 20gig Bytes disk Heath Linux - Newbie 3 05-19-2004 06:08 AM
fdisk and sfdisk devinWhalen Linux - Distributions 5 04-08-2003 12:20 PM
fdisk,cfdisk,sfdisk not in my distro of RH 8.0 personal thehamguy1 Linux - Newbie 5 02-28-2003 01:10 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:55 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration