Loading...

Lab 18: Partitioning a Disk Using fdisk

Identify a newly attached disk, create a primary partition using fdisk, and write the partition table safely. Verify the new device node exists and prepare it for use by formatting the partition with ext4.

storage core troubleshooting

Scenario

A new 10GB disk has been attached at /dev/sdc. You are tasked with confirming the disk is present, creating a new primary partition using fdisk, writing the changes, and preparing the partition for use by formatting it.

Operator context

Partitioning is irreversible when done wrong. The job is not “run commands,” it is proving you targeted the correct disk, wrote the expected table, and verified the partition exists before you touch filesystems or mounts.

Objective

  • Confirm /dev/sdc is present and unpartitioned.
  • Launch fdisk and create a new primary partition.
  • Write the partition table and exit cleanly.
  • Verify the new partition device node exists (for example /dev/sdc1).
  • Format the partition as ext4 to prepare it for use.

What You’ll Practice

  • Disk and partition discovery with lsblk.
  • Interactive partition creation with fdisk.
  • Understanding critical fdisk actions: create (n) vs write (w).
  • Post-change verification using lsblk or fdisk -l.
  • Filesystem creation using mkfs.ext4.

Walkthrough

Step 1 : Confirm the new disk is present.
Command
lsblk

lsblk is your first proof that the kernel can see the disk. You use it to confirm size and naming so you do not accidentally partition the wrong device.

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   40G  0 disk
├─sda1   8:1    0  512M  0 part /boot
└─sda2   8:2    0 39.5G  0 part /
sdc      8:32   0   10G  0 disk
Step 2 : Launch fdisk on the whole disk.
Command
sudo fdisk /dev/sdc

You run fdisk on the disk device (not a partition). From here, you create a new partition interactively. Nothing is committed until you write changes.

Welcome to fdisk. Type 'm' for help, 'n' to create a new partition.
Step 3 : Create a new partition inside fdisk.
Command
n

n creates a new partition definition in the in-memory partition table. You typically accept defaults for a single primary partition that consumes the disk, unless you have specific sizing requirements.

Partition type: primary (default p)
Partition number: 1
First sector: (default)
Last sector: (default)
Created a new partition 1 of type 'Linux' and size ~10 GiB.
Step 4 : Write the partition table and exit.
Command
w

w commits changes to disk and exits fdisk. This is the point of no return. After writing, the kernel may immediately pick up the new partition table, and the new partition node should appear.

Partition table written. Syncing disks.
Step 5 : Verify the new partition exists.
Command
lsblk
# OR
sudo fdisk -l

After writing the table, you confirm the kernel sees the partition. If the partition does not appear, you might need to rescan the device or re-run lsblk. In real environments you might use partprobe or replug the device.

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdc      8:32   0   10G  0 disk
└─sdc1   8:33   0   10G  0 part
Step 6 : Format the new partition for use.
Command
sudo mkfs.ext4 /dev/sdc1

Formatting creates the filesystem that higher-level tools and mounts can use. Once this completes, the partition is ready to be mounted to a directory and used for storage.

Filesystem created on /dev/sdc1

Reference

  • lsblk : Lists block devices and partitions to confirm device presence and structure.
  • fdisk <disk> : Interactive partition editor for MBR/DOS-style partition tables (commonly used in basic lab scenarios).
    • n : Creates a new partition definition.
    • w : Writes the partition table to disk and exits.
  • fdisk -l : Lists partition tables for disks (useful for verification).
  • mkfs.ext4 <partition> : Creates an ext4 filesystem on a partition.