Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

Read This First

  • Formatting erases everything: all files on the device are gone, and there is no undo.
  • Identify the device before anything else: run lsblk -f and match the size and name to the disk you added.
  • Never format a device that shows a mount point: a mount point means it is in use, possibly as the system disk.
  • Back up first: if the disk might hold anything of value, copy it off or take a snapshot.

Step 1: Identify the Disk

lsblk -f

The output looks similar to this:

NAME    FSTYPE FSVER LABEL UUID     FSAVAIL FSUSE% MOUNTPOINTS
vda
└─vda1  ext4   1.0         4f2c...    21.4G    22% /
vdb

Here vda is the system disk, with its partition mounted on /. vdb has no file system and no mount point, so it is the new disk. On virtual servers disks are often named vda, vdb, or sda, sdb; NVMe disks are named nvme0n1, nvme1n1, with partitions such as nvme1n1p1. Confirm the size with sudo fdisk -l /dev/vdb.

Step 2: Check for Old Signatures

Without options, wipefs only lists what it finds:

sudo wipefs /dev/vdb

If it shows an old partition table or file system on a disk you have confirmed is unused, sudo wipefs -a /dev/vdb removes those signatures. This step is destructive.

Step 3: Create a Partition

sudo parted /dev/vdb --script mklabel gpt mkpart data ext4 0% 100%
lsblk /dev/vdb

This writes a GPT partition table and one partition across the whole disk, named vdb1. A file system can also go straight onto the whole disk, but a partition makes the layout clear to every tool.

Step 4: Create the File System

File systemCommand
ext4sudo mkfs.ext4 -L data /dev/vdb1
XFSsudo mkfs.xfs -L data /dev/vdb1
  • ext4: the default on Debian and Ubuntu; can be grown and shrunk.
  • XFS: the default on AlmaLinux and Rocky Linux; handles large files well and can be grown but not shrunk. On Debian and Ubuntu, install xfsprogs first.

-L sets a label (up to 16 bytes for ext4, 12 characters for XFS). mkfs.ext4 refuses a device that is mounted or in use unless forced, and mkfs.xfs will not write over a device that already holds a file system unless you add -f. If either tool stops with such a warning, do not force it: check lsblk -f again.

Step 5: Mount It and Add It to fstab

sudo mkdir -p /mnt/data
sudo mount /dev/vdb1 /mnt/data
sudo blkid /dev/vdb1

Copy the UUID that blkid prints and add a line to /etc/fstab. Use the UUID, not /dev/vdb1, because device names can change between boots. nofail lets the server boot even if this data disk is missing:

UUID=your-uuid  /mnt/data  ext4  defaults,nofail  0  2

For XFS, write xfs and end the line with 0 0. Test the file before you reboot:

sudo findmnt --verify
sudo systemctl daemon-reload
sudo mount -a

No errors means the line is valid. Mount options and ownership are covered in how to mount a drive in Linux. Check the new space with df -h, as in how to check disk space in Linux.

Check a File System

Run a check only on an unmounted file system; checking a mounted one can damage it. For ext4:

sudo umount /mnt/data
sudo fsck -f /dev/vdb1

For XFS, the tool is sudo xfs_repair -n /dev/vdb1, where -n only reports.

Several Disks Together

To combine disks for redundancy before formatting, build a RAID array first and format the array device; see RAID levels explained. Formatting is not a backup strategy either: keep copies elsewhere, as described in snapshot vs backup.

Was this answer helpful?
Loading...