You will add a new disk to a Linux server, create a GPT partition, format it, and mount it persistently. By the end you will have extra storage that survives reboots, with a verification check after every destructive step.

Learning Objectives

  • Identify disks safely with lsblk before touching them.
  • Create a GPT partition and format it with a journaling filesystem.
  • Mount it persistently by UUID.
  • Time: ~2 hours · Difficulty: Intermediate · Prereqs: a server with a second, empty disk.

Architecture Overview

Environment Setup

You will need: a Linux server and a second empty block device (a fresh virtual disk works well).

Before you begin: double-check the target device, formatting the wrong disk destroys data.

Step-by-Step Execution

01
Identify the target disk

Confirm the device name and that it is empty before any change, this prevents catastrophic mistakes.

$ lsblk -o NAME,SIZE,TYPE,MOUNTPOINT
sda 20G disk └─sda1 20G part / sdb 10G disk <- empty target
02
Create a GPT partition

GPT is the modern partition table supporting large disks and many partitions.

sudo parted -s /dev/sdb mklabel gpt mkpart primary ext4 0% 100%
[ROOT REQUIRED] Creates one full-disk partition on /dev/sdb.
03
Format with a journaling filesystem

ext4's journal protects metadata consistency across crashes.

sudo mkfs.ext4 -L data /dev/sdb1
04
Mount persistently by UUID

UUID-based fstab entries stay correct even if device order changes.

echo "UUID=$(blkid -s UUID -o value /dev/sdb1) /mnt/data ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab && sudo mkdir -p /mnt/data && sudo mount -a

Progress So Far

Testing & Validation

df -h /mnt/data && touch /mnt/data/test && ls -l /mnt/data

You should see the mounted size and a writable test file. If both pass, your new storage is ready and persistent.

Troubleshooting
  • mount -a errors: a bad fstab line; the nofail option prevents a boot hang while you fix it.
  • Device busy: something is using it; check with lsof /dev/sdb1.
  • Wrong disk formatted: stop immediately; restore from backup. Always verify with lsblk first.

Extension Ideas

Key Results

  • Added and prepared a 10GB disk with a verified mount.
  • Used GPT and a journaling filesystem for resilience.
  • Made the mount persistent and boot-safe via UUID + nofail.
  • Validated every destructive step before proceeding.