Linux Disk Management: Partition, Format, and Mount
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
Confirm the device name and that it is empty before any change, this prevents catastrophic mistakes.
GPT is the modern partition table supporting large disks and many partitions.
sudo parted -s /dev/sdb mklabel gpt mkpart primary ext4 0% 100%ext4's journal protects metadata consistency across crashes.
sudo mkfs.ext4 -L data /dev/sdb1UUID-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 -aProgress So Far
Testing & Validation
df -h /mnt/data && touch /mnt/data/test && ls -l /mnt/dataYou 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
nofailoption 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
- Make the storage flexible with Logical Volume Management.
- Explore mount options further in Mounting & Filesystem Management.
- Try XFS instead of ext4 and compare resize behaviour.
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.