11

While reading the man page for fdisk I came across this interesting text:

There are several *fdisk programs around. Each has its problems and strengths. Try them in the order cfdisk, fdisk, sfdisk. (Indeed, cfdisk is a beautiful program that has strict requirements on the parti‐ tion tables it accepts, and produces high quality partition tables. Use it if you can. 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. 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.)

I notice that the option formats are not the same for the two applications:

 - melancholy():/$ sudo fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00036f1b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    39063551    19530752   83  Linux
/dev/sda2        39063552   976771071   468853760   83  Linux

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00085251

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048    15624191     7811072   82  Linux swap / Solaris
/dev/sdc2   *    15624192    64452607    24414208   83  Linux
/dev/sdc3        64454654  1953523711   944534529    5  Extended
Partition 3 does not start on physical sector boundary.
/dev/sdc5        64454656  1953523711   944534528   83  Linux
 - melancholy():/$ sudo cfdisk -l
cfdisk: invalid option -- 'l'

Usage:
Print version:
        cfdisk -v
Print partition table:
        cfdisk -P {r|s|t} [options] device
Interactive use:
        cfdisk [options] device

Options:
-a: Use arrow instead of highlighting;
-z: Start with a zero partition table, instead of reading the pt from disk;
-c C -h H -s S: Override the kernel's idea of the number of cylinders,
                the number of heads and the number of sectors/track.

Copyright (C) 1994-2002 Kevin E. Martin & aeb

Is there real merit in switching to using cfdisk instead of fdisk, or is the man page note a historical observation that is no longer valid? Since fdisk works fine for listing the disks info (-l flag) should I use cfdisk only for altering the partitions and partition tables? What are the real strengths and weaknesses of each application?

dotancohen
  • 15,494
  • 26
  • 80
  • 116
  • For modern hard disks, >2TB, `fdisk` is useless: it doesn't support GPT partition tables. – John1024 Apr 06 '15 at 21:06
  • @John1024: I'm glad I asked, I just installed a 2TiB disk but have not formatted it yet (sdb in the OP). Do you mean `>=2 TiB` or just `>2 TiB`? In other words, should I expect fdisk to work with sdb (2 TiB) that I just installed? Thanks! – dotancohen Apr 06 '15 at 21:43
  • I believe that the failure is only for `>2 TiB`. For such large disks, `fdisk` will partition only the first 2 TiB and leave the rest unused. From `fdisk`, run the `v` command to "verify" and it will inform you if you have unused space. – John1024 Apr 06 '15 at 21:52
  • @John1024 - latest versions (partially) [do](http://git.kernel.org/cgit/utils/util-linux/util-linux.git/commit/?id=766d5156c43b784700d28d1c1141008b2bf35ed7) support gpt... – don_crissti Apr 06 '15 at 21:53
  • @don_crissti Good link. Thanks. I appreciated the honesty in the author's test report but it did leave me less than confident:: "For the image, all operations were tested successfully, and for /dev/sda all except write, which was not tested - hey, I'm not suicidal!" – John1024 Apr 06 '15 at 21:58
  • 1
    neither - use `gdisk` - it is the best of them. – mikeserv Apr 06 '15 at 22:55
  • +1 for `gdisk`. Both `fdisk` and `cfdisk` support GPT now, though. – teppic Apr 07 '15 at 01:46

1 Answers1

10

cfdisk is a graphical application designed to be more friendly to the novice. If you are comfortable with fdisk, then by all means, use it. If you prefer a bit more hand holding and fewer ( advanced ) options, use cfdisk. Another good alternative is GNU parted.

psusi
  • 17,007
  • 3
  • 40
  • 51