This guide walks you through attaching a new or existing disk to your Linux VPS, formatting it with a filesystem, and mounting it so you can store data on it. You’ll learn how to identify the correct device, create a partition, format it, and make the mount permanent across reboots.
What You’ll Need
- Root or sudo access to your Linux VPS
- An attached disk (in addition to your system disk) – often added via your hosting control panel
- Basic comfort with the command line
Step-by-Step
- Identify the new disk
Runlsblkto list all block devices. Look for a device that is not mounted and has no partitions (e.g.,sdborvdb). Also runsudo fdisk -lto confirm its size and path. Be absolutely sure you have the right device – formatting the wrong disk will destroy data. - Create a partition (optional but recommended)
Usesudo fdisk /dev/sdb(replacesdbwith your device). Inside fdisk:
Typento create a new partition, press Enter to accept defaults for partition number and first/last sector, then typewto write the partition table. This creates/dev/sdb1. - Format the partition
Format with ext4 (widely compatible):sudo mkfs.ext4 /dev/sdb1. If you prefer XFS, usesudo mkfs.xfs /dev/sdb1. Confirm the operation when prompted. - Create a mount point
Choose a directory where the disk will be accessible, e.g.,/mnt/data. Create it withsudo mkdir -p /mnt/data. - Mount the disk temporarily
Runsudo mount /dev/sdb1 /mnt/data. Verify withdf -h– you should see the new filesystem mounted. - Make the mount permanent
Get the UUID of the partition:sudo blkid /dev/sdb1. Edit/etc/fstabwithsudo nano /etc/fstaband add a line like:UUID=your-uuid-here /mnt/data ext4 defaults 0 2
Replace the UUID and adjust the filesystem type if you used XFS. Save and exit. - Test the fstab entry
Runsudo umount /mnt/datathensudo mount -a. If there are no errors, the mount is configured correctly. Reboot or runsudo mount -aagain to confirm it persists.
Common Mistakes
- Formatting the wrong device – Always double-check with
lsblkandfdisk -l. A typo likesdainstead ofsdbcan wipe your OS. - Forgetting the partition – Some guides skip partitioning, but most VPS disks benefit from a partition table. If you format the whole disk without a partition, some tools won’t recognize it.
- Using the wrong filesystem type in fstab – If you formatted with XFS but put
ext4in fstab, the mount will fail at boot. - Not testing fstab – A bad fstab entry can prevent your VPS from booting. Always test with
mount -aafter editing.
Tips
- Use a dedicated mount point like
/mnt/dataor/srv/datarather than mounting at/or/hometo avoid conflicts. - Consider using LVM if you plan to resize the disk later – it’s more flexible but more complex.
- For SSDs, you can add
discardto the fstab options to enable TRIM, but this may reduce performance on some systems. - Always back up important data before formatting, even if the disk is new.
- If the disk is larger than 2TB, use GPT partitioning instead of MBR (fdisk handles this automatically on modern systems).
Troubleshooting
- Mount fails with “wrong fs type” – Check that the filesystem type in fstab matches what you formatted with. Run
sudo blkidto confirm. - Device not showing up – Rescan the SCSI bus with
echo 1 > /sys/class/scsi_disk/0:0:0:0/device/rescan(replace the identifier) or reboot the VPS. - Can’t write to the mounted disk – Check permissions:
sudo chown -R $USER:$USER /mnt/dataor set appropriate permissions. - fstab entry causes boot failure – Boot into recovery mode or use a rescue console, comment out the line, and fix the entry.
- UUID not found – If you formatted the whole disk without a partition, the device might be
/dev/sdbinstead of/dev/sdb1. Adjust accordingly.
Frequently Asked Questions
Can I mount a disk without partitioning?
Yes, you can format the whole disk (e.g., mkfs.ext4 /dev/sdb) and mount it directly. However, partitioning is recommended for flexibility and to avoid issues with some tools.
What filesystem should I use?
Ext4 is the safest default for most VPS workloads. XFS is better for very large files or high throughput. Btrfs offers snapshots but is more complex.
How do I unmount a disk?
Use sudo umount /mnt/data. If it says “target is busy”, close any open files or processes using that mount, or use sudo lsof +f -- /mnt/data to find them.
What does the ‘0 2’ at the end of fstab mean?
The first number is the dump option (0 disables), the second is the fsck order (2 means check after root filesystem). For non-root filesystems, 2 is standard.
Can I resize the disk later?
If you used a partition, you can extend it with growpart and resize2fs after increasing the disk size in your hosting panel. With LVM it’s even easier.
Is it safe to mount a disk at /home?
Yes, but be careful: if you mount over an existing /home, the old files become hidden until unmounted. Better to mount at a separate path and symlink if needed.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Change Google Text-to-Speech Voice on Android
- How to Adjust Volume Levels on a Windows PC
- Reset Chrome Sync to Fix Problems
- Fix Mouse Not Working in Windows 11
- Fix Windows Defender Failed to Initialize Error
- How to Hide or Unhide NFTs on OpenSea Profile