🛠️ How to Partition and Format Disk Drives on Linux 🛠️

🔧 Formatting and partitioning disks is a key aspect of Linux administration. It allows you to prepare storage media, address space issues, or wipe a filesystem clean.

📘 This guide will walk you through the steps to partition and format disks for common Linux administration tasks.

🔍 What is Disk Formatting in Linux?

Disk formatting prepares a storage partition for use. Understanding disk formatting can help in managing large data assets effectively.

Here are some of the popular filesystems for Linux:

  • 🗄️ Ext4: Common default filesystem on many Linux distributions. Supports file sizes up to 16TB and volumes up to 1 EB.
  • 🪟 NTFS – Developed by Microsoft, with support added in Linux kernel version 5.15.
  • 💾 FAT32 – Older filesystem, but compatible with most operating systems, supporting a max file size of 4GB and volume of 2TB.

🗂️ What is Partitioning in Linux?

Partitioning creates logical boundaries on storage devices, such as HDDs, SSDs, USB drives, and SD cards. This separation is helpful for tasks like limiting filesystem growth or installing multiple operating systems.

🔨 How to Partition and Format Disk Drives on Linux

Let’s get started with partitioning and formatting disks on a Linux system.

📋 Prerequisites

  • 🔑 Access to a Linux terminal (we’re using Ubuntu 22.04 LTS)
  • 🔒 sudo/root privileges
  • 💽 A disk ready to partition and format (backups recommended)

🔍 How to View Disks in Linux

To list available disks, use:

fdisk -l | grep "Disk /"

For a more detailed view:

lsblk -I 8 -d

list specific disk devices

📊 How to View Existing Partitions in Linux

To list existing partitions, use:

lsblk

list existing disk partitions

🔧 How to Partition a Disk in Linux

To partition disks, we’ll use the fdisk utility:

fdisk /dev/sda

fdisk utility

Type n to create a new partition and follow the prompts.

fdisk create new partition

💾 How to Format a Disk in Linux

To format your partition:

mkfs.ext4 /dev/sda2

format new partition to ext4 file system

For NTFS or FAT32, use:

mkfs.ntfs /dev/sda2
mkfs.fat -F 32 /dev/sda2

🖇️ How to Mount a Disk in Linux

Create a mount point:

mkdir /var/cherry

Related articles

Difference Between fork and clone in GitHub

Difference Between Fork and Clone in GitHub Introduction Understanding the difference between fork and clone in GitHub is crucial for...

What is Data Virtualization

What is Data Virtualization Introduction Data virtualization is a modern approach to distributed data management that simplifies access to data...

Java Synchronization and Thread Safety Tutorial with Examples

Java Synchronization and Thread Safety Tutorial with Examples Introduction Java is a multi-threaded programming language that allows multiple threads to...

Issues in GitHub

Issues in GitHub: A Comprehensive Guide GitHub is more than just a version control system; it is a powerful...