Mounting a file system on a Virtual Private Server (VPS) is a fundamental task for managing storage effectively. Whether you're adding extra disk space for applications, databases, or backups, this process allows you to attach a block device (like a new hard drive or partition) to your server's directory structure. On a Linux-based VPS, which is common for many providers including those using KVM virtualization like VPS.DO, this is typically done via command-line tools. This guide provides a practical, step-by-step approach assuming a Debian-based system such as Ubuntu, but the concepts apply broadly to CentOS or other distributions with minor adjustments.
Understanding the Basics
Before diving in, note that mounting integrates a storage device into your VPS's file system hierarchy. You'll need:
- Root or sudo access to execute privileged commands.
- SSH access to your VPS (usually via tools like PuTTY or the terminal).
- Knowledge of your disk devices, which you can check using commands like lsblk or fdisk -l.
If your VPS provider offers full root access—as is standard with VPS.DO's KVM-based plans—you can perform these operations directly without restrictions.
Step-by-Step Guide to Mounting a File System
Step 1: Identify the Disk Device
First, log in to your VPS via SSH:
Switch to root if needed:
List available block devices to identify the one you want to mount (e.g., a new SSD volume might appear as /dev/sdb):
Or for more details:
Look for unmounted devices without a file system. Avoid touching your root disk (usually /dev/sda).
Step 2: Create a File System (If Necessary)
If the device is raw (no existing file system), format it. For an ext4 file system (common for Linux):
Replace /dev/sdb with your device. Warning: This erases all data on the device, so double-check!
For other formats like NTFS (if cross-compatible with Windows) or XFS:
or
Step 3: Create a Mount Point
Create a directory where the file system will be attached:
You can name it anything descriptive, like /mnt/data for a data storage volume.
Step 4: Mount the File System Temporarily
Mount the device to the directory:
Verify it's mounted:
You should see /dev/sdb listed under /mnt/newdrive. Now, you can read/write files there.
Step 5: Make the Mount Permanent
To ensure the mount persists after reboots, edit /etc/fstab:
Add a line like this (using the device's UUID for reliability—find it with blkid /dev/sdb):
Save and exit, then test:
If no errors, it's good. Reboot to confirm:
Handling Common Scenarios
- Adding Extra Storage: Many VPS plans include scalable SSD storage. If you've upgraded your plan (e.g., via a provider's control panel like SolusVM, which VPS.DO uses for resource management), the new space might appear as a new partition. Use growpart and resize2fs for existing file systems:
textgrowpart /dev/sda 1resize2fs /dev/sda1
- Mounting Network File Systems: For remote storage like NFS:
textapt install nfs-common # On Debian/Ubuntumount -t nfs remote-server:/share /mnt/nfs
- Automounting with systemd: For on-demand mounting, use /etc/systemd/system/mnt-newdrive.mount files, but stick to fstab for simplicity.
Troubleshooting Tips
- Mount Fails with "Wrong fs type": Ensure the file system matches (e.g., install ntfs-3g for NTFS: apt install ntfs-3g).
- Device Not Found After Reboot: Check UUID in fstab; use blkid to confirm.
- Permission Issues: Use chown or chmod on the mount point for user access.
- Full Disk Errors: Run fsck /dev/sdb to check and repair file systems. If issues persist, consult your VPS provider's support, as hardware-level problems (e.g., disk attachment) might require their intervention.
Best Practices
- Always back up data before formatting or mounting.
- Use labels for devices: e2label /dev/sdb mydata and reference in fstab as LABEL=mydata.
- Monitor usage with tools like df -h or du -sh /mnt/*.
- For security, consider encrypting with LUKS if handling sensitive data.
Mounting file systems expands your VPS's capabilities, enabling better resource utilization for web hosting, development, or data storage. With straightforward tools and root access, you can customize your setup efficiently. If you're starting fresh, ensure your VPS supports flexible OS options for easy experimentation.