Scenario
A new partition has been added as /dev/sdb1. You are responsible for formatting it, mounting it to
/mnt/data, and ensuring it mounts automatically at boot by correctly updating /etc/fstab.
You also need to validate the entry without rebooting.
Persistent mounts are a common failure point. A single bad /etc/fstab line can drop a system into emergency mode,
so you verify device identity, mount state, and fstab correctness before calling it done.
Objective
- Identify the new block device and confirm it is the correct partition.
- Create an
ext4filesystem on/dev/sdb1. - Create the mountpoint at
/mnt/dataand mount the filesystem. - Verify the mount is active and backed by the expected device.
- Add a correct entry to
/etc/fstab(prefer UUID) for persistence at boot. - Validate
/etc/fstabsafely without rebooting.
Concepts
-
Use stable identifiers in
/etc/fstab. Device names like/dev/sdb1can change; UUIDs typically do not. -
Filesystem creation is destructive. Verify the target device before running
mkfs. - A mount is not “done” until you can prove it: check the mount table and confirm the source device matches expectations.
-
mount -ais your safety net. It lets you catch a badfstabentry while you still have a working shell.
Walkthrough
lsblk
lsblk shows disks, partitions, sizes, filesystem types, and mountpoints.
Confirm /dev/sdb1 exists and has no active mountpoint before you format it.
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 /
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 20G 0 part
/dev/sdb1.
sudo mkfs.ext4 /dev/sdb1
This writes a new filesystem and destroys any existing data on the partition. Do this only after you confirm the correct device.
mke2fs 1.45.5 (07-Jan-2020)
Creating filesystem with 5242880 4k blocks and 1310720 inodes
Filesystem UUID: abc12345-6789-4def-aaaa-bbbbccccdddd
Filesystem created successfully.
sudo mkdir -p /mnt/data
sudo mount /dev/sdb1 /mnt/data
The mountpoint is just an empty directory that becomes the attach point for the filesystem.
After mounting, the filesystem content is accessible under /mnt/data.
/dev/sdb1 mounted to /mnt/data
findmnt /mnt/data
df -hT /mnt/data
findmnt is structured evidence: source device, target, filesystem type, and options.
df -hT confirms size, usage, and filesystem type for the mountpoint.
/mnt/data /dev/sdb1 ext4 rw,relatime
Filesystem Type Size Used Avail Use% Mounted on
/dev/sdb1 ext4 20G 24M 19G 1% /mnt/data
/etc/fstab entry.
sudo blkid /dev/sdb1
Using UUID= in /etc/fstab avoids failures caused by device renaming (/dev/sdb becoming /dev/sdc, etc.).
Copy the UUID exactly.
/dev/sdb1: UUID="abc12345-6789-4def-aaaa-bbbbccccdddd" TYPE="ext4"
# Add this line to /etc/fstab (use your real UUID):
UUID=abc12345-6789-4def-aaaa-bbbbccccdddd /mnt/data ext4 defaults 0 2
/etc/fstab safely without rebooting.
sudo umount /mnt/data
sudo mount -a
findmnt /mnt/data
Unmounting first forces your fstab entry to be used by mount -a.
If anything is wrong, you catch it now instead of at boot.
/mnt/data /dev/sdb1 ext4 rw,relatime
Common breakpoints
Stop immediately and document what happened. This is why you confirm with lsblk -f and double-check the target device
before running mkfs. Treat it as a data loss incident.
Create it first with sudo mkdir -p /mnt/data, then re-run the mount.
Your fstab line is incorrect (bad UUID, wrong field order, invalid options, or missing mountpoint).
Fix the line and re-run mount -a until it succeeds.
Confirm the final fstab line uses UUID=, the mountpoint exists at boot, and the filesystem type matches.
Validate with findmnt and confirm the UUID using blkid.
Cleanup checklist
If this was a test mount, remove the /etc/fstab entry before you forget. Otherwise, leave it in place.
Always confirm the system is in a stable state before moving on.
findmnt /mnt/data
sudo blkid /dev/sdb1
findmnt shows /mnt/data backed by /dev/sdb1 (or the expected UUID), and your last
mount -a run completed without errors.
Reference
-
lsblk: Lists block devices and partitions, including sizes, types, and mountpoints.-f: Show filesystem type, UUID, and label for each device.-p: Show full device paths (example:/dev/sdb1).
-
mkfs.ext4 <device>: Creates an ext4 filesystem on a block device (destructive).-L <label>: Set a filesystem label (example:-L DATA).
-
mkdir -p <dir>: Creates a directory (and parents) for a mountpoint.-p: Do not error if the directory exists; create parent dirs as needed.
-
mount <device> <mountpoint>: Mounts a filesystem at a directory.-t <type>: Specify filesystem type explicitly (example:-t ext4).
-
umount <mountpoint>: Unmounts a mounted filesystem.-l: Lazy unmount (detaches now, cleans up when no longer busy).
-
findmnt <path>: Query the mount that backs a specific path (example:findmnt /mnt/data).-r: Raw output (useful for scripting).
-
df -hT <path>: Shows space usage and filesystem type for a path.-h: Human-readable sizes.-T: Include filesystem type.
-
blkid <device>: Prints UUID and filesystem type for a block device.-s UUID: Print only the UUID field.
-
/etc/fstab: Static filesystem table used to define persistent mounts at boot.- Field order:
<source> <mountpoint> <type> <options> <dump> <fsck_pass> - Prefer
UUID=<uuid>as the source for stability.
- Field order:
-
mount -a: Mounts all filesystems from/etc/fstabthat are not already mounted.- Primary safety check after editing
/etc/fstab. - Entries with
noautoare skipped.
- Primary safety check after editing