Last updated on October 26, 2026
Updated October 2026. The 2019 version of this post was written for CentOS 7, which reached end of life in 2024. The steps below work on Rocky Linux, AlmaLinux and RHEL 9/10 (XFS) and on Ubuntu 22.04/24.04 (ext4), and still apply to an old CentOS 7 box. Tested on Rocky Linux 9.8 and Ubuntu 24.04.
The short version: find the disk with lsblk, give it a GPT partition, create a filesystem, and mount it from /etc/fstab by UUID with nofail. The last part is where most guides, including the old version of this one, cut corners.
1. Find the new disk
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTSThe new disk is the one with the right size, no partitions and no filesystem. Its name depends on the controller:
/dev/sdb,/dev/sdc: SATA, SAS, VMware and Hyper-V SCSI disks./dev/vdb: KVM and Proxmox VirtIO disks./dev/nvme1n1: NVMe. Partitions get ap:/dev/nvme1n1p1.
The examples below use /dev/sdb. Check the name twice: the next steps destroy whatever is on the disk you point them at.
If you hot-added a disk to a running VM and it does not show up, rescan the SCSI hosts instead of rebooting:
for host in /sys/class/scsi_host/host*/scan; do echo "- - -" > "$host"; done
lsblk2. Make sure the tools are installed
Minimal images often ship without parted:
# Rocky, Alma, RHEL
dnf install -y parted xfsprogs
# Ubuntu, Debian
apt install -y parted3. Create a GPT partition
parted -s /dev/sdb mklabel gpt mkpart data 1MiB 100%
partprobe /dev/sdb
lsblk /dev/sdbExpected result: a single partition sdb1 that spans the disk. GPT instead of the old MBR (fdisk with n, p, 1) means no 2 TB limit, and starting at 1 MiB keeps the partition aligned. partprobe makes the kernel read the new table without a reboot.
4. Create a filesystem
XFS is the default on Rocky, Alma and RHEL, ext4 on Ubuntu. Pick one:
# XFS
mkfs.xfs -L data /dev/sdb1
# or ext4
mkfs.ext4 -L data /dev/sdb1The label (-L data) shows up in lsblk -f and makes the disk easy to recognise later. Keep in mind that XFS can grow but cannot shrink.
5. Mount it permanently
Create the mount point and look up the UUID of the new filesystem:
mkdir -p /data
blkid -s UUID -o value /dev/sdb1Add one line to /etc/fstab with that UUID. For XFS:
UUID=678e7c65-e5c6-441a-a6f7-abc087f215a9 /data xfs defaults,nofail 0 0For ext4 use ext4 and 0 2 at the end, so the filesystem is checked at boot:
UUID=678e7c65-e5c6-441a-a6f7-abc087f215a9 /data ext4 defaults,nofail 0 2Before mounting anything, let findmnt check the file, then reload systemd and mount:
findmnt --verify
systemctl daemon-reload
mount -aExpected result: findmnt --verify reports no [E] lines. A typo in the UUID shows up as [E] unreachable on boot required source: UUID=..., which is exactly the kind of mistake you want to catch now and not on the next reboot.
6. Check the result
findmnt /data
df -h /data
lsblk -f /dev/sdbExpected result: /data is mounted from /dev/sdb1 with the filesystem you chose, and df shows the full size of the disk.
Gotchas
- Use the UUID, not
/dev/sdb1. Device names follow the order in which the kernel finds disks. Add another disk or change the controller andsdbmay becomesdc; an fstab line with the device name then mounts the wrong disk or none. - Always add
nofailto data disks. Without it, a disk that is missing or broken at boot drops the whole server into emergency mode, which on a remote machine means a trip to the console. - Run
systemctl daemon-reloadafter editing fstab. systemd generates mount units from fstab and keeps using the old ones until reloaded;findmnt --verifywarns about this too. - SELinux on Rocky, Alma and RHEL. A new mount point gets the default label. If a service such as nginx or a database reads from
/data, give it the right context withsemanage fcontextandrestorecon -R /data, otherwise you get permission errors that look like file permissions but are not. - Need to grow it later? Put the disk under LVM from the start; see how to extend a partition using LVM.
Takeaways
lsblkto find the disk,partedfor a GPT partition,mkfs.xfsormkfs.ext4for the filesystem.- fstab entry by UUID with
nofail, checked withfindmnt --verifybeforemount -a. - The same steps work on any current distribution; only the default filesystem differs.
Links
- findmnt(8) and fstab(5) man pages
- GNU Parted manual
- Rocky Linux documentation
