fdisk

fdisk

It seems like you're interested in learning about fdisk, a command-line utility used for disk partitioning in Unix-like operating systems. fdisk is a powerful tool that allows users to create, delete, modify, and manage disk partitions on hard drives. Here's an overview of fdisk and its common usage:

Overview of fdisk

Purpose: fdisk is used to perform various disk partitioning tasks, such as creating, deleting, and resizing partitions on hard drives.

Availability: fdisk is typically included with most Unix-like operating systems, including Linux distributions.

Common fdisk Commands and Usage

  1. Display Partition Table:

    • To view the current partition table of a disk:

      fdisk -l /dev/sda

      Replace /dev/sda with the disk device you want to inspect.

  2. Creating a New Partition:

    • To create a new partition:

      fdisk /dev/sda
      • Type n to create a new partition.

      • Specify the partition type, start sector, and end sector.

      • Write changes to disk using w.

  3. Deleting a Partition:

    • To delete an existing partition:

      fdisk /dev/sda
      • Type d to delete a partition.

      • Select the partition number to delete.

      • Write changes to disk using w.

  4. Changing Partition Type:

    • To change the type of an existing partition:

      fdisk /dev/sda
      • Type t to change a partition's system ID (type).

      • Select the partition number and enter the new hexadecimal code for the partition type.

      • Write changes to disk using w.

  5. Printing Help and Options:

    • To print a summary of fdisk commands and options:

      fdisk --help

Considerations

  • Data Loss: Be cautious when using fdisk as it directly manipulates partition tables, and incorrect operations can result in data loss.

  • Backup: Always back up important data before making any changes to disk partitions.

Alternatives

  • GNU Parted (parted): Provides a more user-friendly interface with additional features like resizing partitions while they are in use.

  • GParted: A graphical front-end for parted that offers a visual representation of disk partitions and makes it easier to manage partitioning tasks.

Conclusion

fdisk is a fundamental tool for disk partitioning on Unix-like systems, offering powerful capabilities to manage disk partitions directly from the command line. It's essential to understand its commands and use them carefully to avoid unintended data loss or system issues.

help

man

Last updated