Prepare a new partition for use by formatting it, mounting it to a target directory, and confirming it is active.
Persist the mount across reboots by adding a correct entry to /etc/fstab and validating it safely.
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.
ext4 filesystem on /dev/sdb1.
/mnt/data.
/etc/fstab for persistence at boot.
/etc/fstab safely without rebooting.
lsblk.
mkfs.ext4.
mount.
mount and findmnt.
/etc/fstab.
mount -a.
lsblk
lsblk
displays block devices in a tree view so you can see disks, partitions, sizes, and current mountpoints.
This is where you confirm /dev/sdb1 exists and is not already mounted or in use.
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
mkfs.ext4
writes a new ext4 filesystem to the partition. This destroys any existing data on that partition, so you do this only after confirming
you are targeting 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
Superblock backups stored on blocks: 32768, 98304, 163840...
Filesystem created successfully.
/mnt/data.
sudo mount /dev/sdb1 /mnt/data
mount
attaches the filesystem at the mountpoint so it becomes part of the directory tree. If the mountpoint does not exist,
create it first with sudo mkdir -p /mnt/data.
/dev/sdb1 mounted to /mnt/data
findmnt
Verification matters. findmnt gives a structured view of active mounts, which is useful when multiple devices
or bind mounts are present. You can also use mount if you want raw output.
/dev/sdb1 on /mnt/data type ext4 (rw,relatime)
/etc/fstab.
# Add this line to /etc/fstab:
/dev/sdb1 /mnt/data ext4 defaults 0 2
/etc/fstab
controls what mounts at boot. The fields are: device, mountpoint, filesystem type, options, dump, and fsck pass number.
A wrong entry can break boot, so you keep the line minimal and correct.
fstab line added: /dev/sdb1 /mnt/data ext4 defaults 0 2
/etc/fstab without rebooting.
sudo mount -a
mount -a
attempts to mount everything in /etc/fstab that is not already mounted (excluding entries marked
with noauto). If there is an error, this is where you want to catch it.
All valid entries from /etc/fstab mounted successfully.
lsblk
: Lists block devices and partitions, including mountpoints and sizes.
mkfs.ext4 <device>
: Creates an ext4 filesystem on a block device (destructive operation).
mount <device> <mountpoint>
: Mounts a filesystem at a directory.
findmnt
: Displays mounted filesystems in a structured, searchable format.
/etc/fstab
: Static filesystem table used to define persistent mounts at boot.
mount -a
: Mounts all filesystems listed in /etc/fstab (except those marked noauto) to validate entries.