If you are a sysadmin, managing your Linux server’s hard disk partition is a critical task.

In this tutorial, we’ll focus on how to use sfdisk command-line utility to manage your hard disk partitions.

While sfdisk is similar to fdisk, there are few partition manipulation activities that are very easy to perform in sfdisk. For example, you can create new partitions in an non-interactive method using sfdisk.

The following sfdisk activities are covered in this tutorial:

  1. View Existing Disk Partitions
  2. Change Display Units (Display Size in MB)
  3. Create New Disk Partitions (Interactive Method)
  4. Verify Partition Table Consistency
  5. Display Total Partition Size
  6. Dump Disk Partition Details to Text File
  7. Create New Partitions from Text File (Non-interactive Method)
  8. Display Extended Partition Details
  9. Display Disk Geometry for Debugging
  10. Display All Disk Partition types
  11. Manipulate Only a Single Disk Partition
  12. Dry-run Mode for Verification
  13. Mark a Specific Partition as Bootable
  14. Change Partition Type
  15. Create New Partitions from Shell Script (Non-interactive Method)

View Existing Disk Partitions

Using -l option you can view all your disk partitions. -l stands for list.

By default this will display partitions of all the disks on your systems.

# sfdisk -l

Disk /dev/sda: 1044 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+   1044-   1045-   8387584   83  Linux
/dev/sda2          0       -       0          0    0  Empty
/dev/sda3          0       -       0          0    0  Empty
/dev/sda4          0       -       0          0    0  Empty

Disk /dev/sdf: 1044 cylinders, 255 heads, 63 sectors/track
[ad type=”banner”]

Categorized in: