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:
- View Existing Disk Partitions
- Change Display Units (Display Size in MB)
- Create New Disk Partitions (Interactive Method)
- Verify Partition Table Consistency
- Display Total Partition Size
- Dump Disk Partition Details to Text File
- Create New Partitions from Text File (Non-interactive Method)
- Display Extended Partition Details
- Display Disk Geometry for Debugging
- Display All Disk Partition types
- Manipulate Only a Single Disk Partition
- Dry-run Mode for Verification
- Mark a Specific Partition as Bootable
- Change Partition Type
- 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”]