Linux VPS

Mount a new disk on a Linux VPS and keep it after reboot

Partition, format and mount an extra disk on your Linux VPS, then add it to /etc/fstab by UUID so it mounts automatically after every reboot.

IntermediateLinux VPS2 min read

When extra storage is attached to a VPS, Linux sees a new empty block device, but it cannot hold files until you partition, format and mount it. This guide shows the safe way to do that and make the mount permanent.

Before you start

  • Root or sudo access over SSH.
  • The new disk attached to the VPS. If your existing disk was enlarged instead, grow it as shown in LVM basics.
  • A current backup (see back up a Linux VPS).

Danger: Formatting erases a disk. Triple-check the device name: formatting the system disk by mistake destroys the server.

Find the new disk

lsblk -f

The system disk has partitions mounted at paths like /. The new disk, for example /dev/vdb or /dev/sdb, has no partitions and no filesystem.

Create a partition

sudo parted /dev/vdb --script mklabel gpt mkpart primary 0% 100%

This creates /dev/vdb1 covering the whole disk. Confirm with lsblk.

Format the partition

sudo mkfs.ext4 /dev/vdb1

ext4 is the usual choice on Ubuntu and Debian; XFS (sudo mkfs.xfs /dev/vdb1) is the default on AlmaLinux and Rocky Linux. Both work well.

Mount it

sudo mkdir -p /data
sudo mount /dev/vdb1 /data
df -h /data

Make the mount permanent

Device names can change between boots, so mount by UUID:

sudo blkid /dev/vdb1

Add a line to /etc/fstab (see editing files with nano and vim):

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

nofail lets the server still boot if the disk is missing. Test without rebooting:

sudo umount /data
sudo mount -a
findmnt /data

Warning: If mount -a prints an error, fix /etc/fstab before rebooting. A broken fstab can stop the VPS from booting.

Set ownership

The new filesystem belongs to root. Give your app user access with sudo chown -R deploy:deploy /data (see chown).

Troubleshooting

  • wrong fs type, bad option: the type in fstab does not match what blkid reports.
  • target is busy when unmounting: a shell or process uses the folder. Run cd / and check sudo lsof +D /data.
  • Disk not visible: reboot the VPS from your control panel, or open a support ticket.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.