Can Linux sfdisk Tool Used Instead Of Fdisk

March 20, 2011 | By
| Reply More

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.

[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.
Example: 35565360 / 1024 = > 34731.79 MB

Example: 2

-l will list the partition on device.

[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.

Example: 3

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

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

Example: 4

-T lists the supported partition ids.

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

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

Filed Under : LINUX COMMANDS, LINUX HOWTO

Tagged With : ,

Free Linux Ebook to Download

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.