Updated: 28 September 2026 · Applies to: GNU parted 3.5 and 3.6 on AlmaLinux and Rocky Linux 9 and 10, RHEL 9 and 10, Ubuntu 24.04 and 26.04, Debian 13
This guide takes a new, empty disk (for example a second disk added to a dedicated server or VPS) from nothing to a mounted folder that survives reboots: partition it with parted, create a file system, and add it to /etc/fstab. For more parted commands, such as resizing and recovering partitions, see 8 Linux parted commands.
Before you start
- Every step below erases the disk you name. Make sure it is the new, empty disk.
- Install parted if it is missing:
dnf install partedorapt install parted.
Steps
- Find the new disk. It has no partitions and no mount point:
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
In this example it is/dev/sdb. On a VPS it may be/dev/vdb, on NVMe servers/dev/nvme1n1. - Create a GPT partition table and one partition over the whole disk:
parted -s /dev/sdb mklabel gpt mkpart data 1MiB 100%
GPT works for disks of any size (MBR stops at 2 TB). Starting at 1 MiB keeps the partition aligned. - Check the result:
parted /dev/sdb print. The partition is/dev/sdb1(on NVMe:/dev/nvme1n1p1). - Create a file system. XFS is the default on AlmaLinux, Rocky Linux and RHEL, ext4 on Ubuntu and Debian; both are good choices:
mkfs.xfs /dev/sdb1 # or: mkfs.ext4 /dev/sdb1
- Create the folder and mount it:
mkdir -p /data mount /dev/sdb1 /data df -h /data
- Get the file system's UUID, which stays the same even if disk names change:
blkid /dev/sdb1
- Add a line to
/etc/fstabwith that UUID:UUID=0a1b2c3d-1111-2222-3333-444455556666 /data xfs defaults,nofail 0 0
Useext4instead ofxfsif you chose ext4.nofaillets the server boot even if this disk is missing. - Check the fstab line before you reboot:
umount /data systemctl daemon-reload mount -a findmnt --verify
mount -amust mount/dataagain without errors. A broken fstab line can stop a server from booting, so never skip this check.
Common problems
- "Partition(s) ... have been written, but we have been unable to inform the kernel": run
partprobe /dev/sdb, or reboot, before creating the file system. - Wrong disk chosen: stop at once. Data can sometimes be recovered with
parted rescueor TestDisk if nothing more was written. - Want to use it with LVM instead: skip the file system step and run
pvcreate /dev/sdb1, then add it to a volume group.
Official documentation: GNU parted manual and fstab manual page.
Ucartz services for this topic
- KVM VPS hosting: NVMe SSD and full root access, with Free Basic Managed Support.
- Unmanaged dedicated servers: full root access and free IPMI KVM, with Free Basic Managed Support.
- Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
