Can Linux sfdisk Tool Used Instead of Fdisk

| March 20, 2011 | 0 Comments

Linux sfdisk Tool

sfdisk is a partition table manipulator for Linux. sfdisk main uses are list the size of the partition, list the partition on a device,check the portions’ on a device and repartition a device. sfdisk utility will read from the standard input any commands it has 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 excutes the command without prompting /warnings .

Options:
-s gives size of the partition in blocks

Example: 1

[root@localhost ~]# 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
Eg: 35565360 / 1024 = > 34731.79 MB

-l Options will list the partition on device.

Example: 2

[root@localhost ~]#  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

-V This option checks the disk partition table on device. If disk has problem it shows complains.

Example: 3

[root@localhost ~]# sfdisk -V
/dev/sda: OK

-T This options list the supported partition ids

Example: 4

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

Example: 5

-g this option shows geometry of the disk.

[root@localhost ~]# sfdisk -g
/dev/sda: 1305 cylinders, 255 heads, 63 sectors/track

-d This option Dump the partitions of a device in a format useful as input to sfdisk utility

Tags: ,

Category: Linux Administration

Leave a Reply

You must be logged in to post a comment.