337 words
2 minutes

How to Format and Partition Disks Using fdisk or GParted

Managing disk partitions is an essential skill for anyone working with Linux systems. Whether you’re setting up a new hard drive, resizing existing partitions, or troubleshooting storage issues, tools like fdisk and GParted are invaluable. This guide will walk you through formatting and partitioning disks using these two powerful tools.

Why Partitioning Matters#

Partitioning a disk organizes storage into separate sections, making it easier to manage and optimize performance. It also helps when you need to install multiple operating systems or separate data from the system files.


Using fdisk for Disk Management#

fdisk is a command-line utility for creating and managing disk partitions. Follow these steps to use fdisk:

  1. Identify Your Disk
    Use the command lsblk or fdisk -l to list all available disks and partitions. Identify the target disk (e.g., /dev/sda).

  2. Launch fdisk
    Run the following command, replacing /dev/sda with your target disk:

    sudo fdisk /dev/sda
  3. Create a New Partition

    • Press n to create a new partition.
    • Choose the partition type (primary or extended).
    • Set the partition size.
  4. Write Changes to Disk
    After making changes, press w to write them to the disk.

  5. Format the Partition
    Format the new partition using a file system like ext4:

    sudo mkfs.ext4 /dev/sda1

Using GParted for a GUI-Based Approach#

For those who prefer graphical interfaces, GParted simplifies disk management:

  1. Install GParted
    Use the following command to install GParted on Ubuntu or Debian-based systems:

    sudo apt update && sudo apt install gparted
  2. Launch GParted
    Open GParted with administrative privileges:

    sudo gparted
  3. Select Your Disk
    From the dropdown menu in the top-right corner, select the disk you want to manage.

  4. Create or Resize Partitions

    • Right-click on unallocated space and choose “New” to create a partition.
    • Adjust the size, file system, and label as needed.
  5. Apply Changes
    Click the green checkmark to apply the changes.


FAQs#

  1. What’s the difference between fdisk and GParted?
    fdisk is a command-line tool ideal for scripting and advanced users, while GParted provides a user-friendly graphical interface.

  2. Is it safe to partition a disk with data?
    Partitioning a disk may overwrite data. Always back up important files before modifying partitions.

  3. Can I use these tools on external drives?
    Yes, both fdisk and GParted work with internal and external drives. Ensure the correct disk is selected to avoid data loss.

How to Format and Partition Disks Using fdisk or GParted
https://netalynx.web.id/posts/how-to-format-and-partition-disks-using-fdisk-or-gparted/
Author
Neta Lynx
Published at
2025-01-21