Can Linux sfdisk Tool Used Instead Of Fdisk

Linux sfdisk Tool

sfdisk is a partition table manipulator for Linux. The uses of sfdisk main are list the size of the partition, list the partition on a device and check the portions on a device and repartition a device. sfdisk utility will read from the standard input if any commands have to perform. You can copy a partition map from one disk to another with sfdisk. Linux sfdisk is able to save a backup of the primary and extended partition table. It creates a file that can be used by sfdisk to restore the primary or extended partition table. The sfdisk is useful for setting up mirroring.

Note: sfdisk executes the command without prompting/warning.

Example: 1

Options:
-s gives size of the partition in blocks.

[[email protected] ~]# sfdisk -s
/dev/cciss/c0d0: 35565360
/dev/cciss/c0d1: 35565360
/dev/cciss/c0d2: 35565360
/dev/cciss/c0d3: 35565360
/dev/cciss/c0d4: 35565360
/dev/cciss/c0d5: 17780640
total: 195607440 blocks

To calculate how much MB for each disk.
Example: 35565360 / 1024 = > 34731.79 MB

Example: 2

-l will list the partition on device.

[[email protected] ~]# sfdisk -l
Disk /dev/sda: 1305 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sda1 * 0+ 764 765- 6144831 83 Linux
/dev/sda2 765 891 127 1020127+ 82 Linux swap / Solaris
/dev/sda3 0 - 0 0 0 Empty
/dev/sda4 0 - 0 0 0 Empty

In above output, + sign indicates rounding has been taken. Actual value is plus or minus.

Example: 3

-V checks the disk partition table on device. If the disk has problem, it shows complaints.

[[email protected] ~]# sfdisk -V
/dev/sda: OK

Example: 4

-T lists the supported partition ids.

[[email protected] ~]# sfdisk –T | head
Id Name
0 Empty
1 FAT12
2 XENIX root
3 XENIX usr
4 FAT16 <32M

Example: 5

-g shows geometry of the disk.

[[email protected] ~]# sfdisk -g
/dev/sda: 1305 cylinders, 255 heads, 63 sectors/track

-d dumps the partitions of a device in a format, it is used as input to sfdisk utility.

About Bobbin Zachariah

Founder of LinOxide, passionate lover of Linux and technology writer. Started his career in Linux / Opensource from 2000. Love traveling, blogging and listening music. Reach Bobbin Zachariah about me page and google plus page.

Author Archive Page

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.