For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /general/disk_management/How_to_Attach_Additional_Disk_on_your_KVM_based_VPS.md.

How to Attach Additional Disk on your KVM based VPS

Attaching an additional disk to your KVM-based Virtual Private Server (VPS) can provide you with extra storage space for data, applications, or any other specific needs. This process allows you to expand your server's storage capacity, making it a useful task for managing your VPS efficiently.

In this guide, we'll walk you through the steps to attach an additional disk to your KVM-based VPS. The process generally involves verifying the new disk, formatting it with a filesystem, mounting it, and configuring it for persistent mounting.


Warning

Make sure you identify the correct disk before proceeding. Formatting the wrong disk can result in permanent data loss. In this guide, the new disk is /dev/vdb, but the disk name may vary for your VPS.

Verify the New Disk

Once the additional disk has been assigned to your server, verify the disk by using the fdisk -l command:

fdisk -l

Output:

root@vps:~# fdisk -l
Disk /dev/vda: 150 GiB, 161061273600 bytes, 314572800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: CA147C86-F18D-46FC-A68E-BC0F0EFB040E

Device       Start         End     Sectors     Size Type
/dev/vda1     2048        4095        2048       1M BIOS boot
/dev/vda2     4096     1052671     1048576     512M Linux swap
/dev/vda3  1052672   314570239   313517568   149.5G Linux filesystem

Disk /dev/vdb: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

As you can notice from the above output, there are two disks present on the server. The first disk /dev/vda contains the main system partitions, while the second disk /dev/vdb is the newly added disk with no partitions present.

Partition, Format, and Mount the Disk

Format the Disk

Note

The following command is for EXT4 filesystems only.

Format the new disk with the EXT4 filesystem using the following command:

mkfs.ext4 /dev/vdb

Create a Mount Directory

Create a mount directory on the server where the new disk will be mounted. This can be named as per your requirements (for example, /disk2):

mkdir /disk2

Mount the Disk

Mount the disk onto the /disk2 directory:

mount /dev/vdb /disk2/

Configure Persistent Mounting

Add an entry into /etc/fstab so the disk is mounted automatically upon reboot:

vi /etc/fstab

Add the following line to the end of the file:

/dev/vdb    /disk2    ext4    defaults    0 0
Important

Make sure the device name, mount point, and filesystem type are correct before saving /etc/fstab.

Save changes and exit the file.

Verify the Mounting

Verify that the disk is mounted correctly on /disk2 using the following commands:

fdisk -l

df -Th

Output:

root@vps:~# fdisk -l
Disk /dev/vda: 150 GiB, 161061273600 bytes, 314572800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: CA147C86-F18D-46FC-A68E-BC0F0EFB040E

Device       Start         End     Sectors     Size Type
/dev/vda1     2048        4095        2048       1M BIOS boot
/dev/vda2     4096     1052671     1048576     512M Linux swap
/dev/vda3  1052672   314570239   313517568   149.5G Linux filesystem

Disk /dev/vdb: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
root@vps:~# df -Th
Filesystem     Type   Size  Used Avail Use% Mounted on
tmpfs          tmpfs   96M 1008K   95M   2% /run
/dev/vda3      ext4   148G  3.1G  137G   3% /
tmpfs          tmpfs  479M     0  479M   0% /dev/shm
tmpfs          tmpfs  5.0M     0  5.0M   0% /run/lock
tmpfs          tmpfs   96M  4.0K   96M   1% /run/user/0
/dev/vdb       ext4    49G   24K   47G   1% /disk2

What Changed

  1. Added import { Steps } from '@rspress/core/theme'; at the top of the file.
  2. Wrapped formatting, directory creation, mounting, and /etc/fstab configuration steps into a <Steps> block with ### headings.
  3. Converted GitHub-style warnings and notes (> [!WARNING], > [!NOTE], > [!IMPORTANT]) into proper Rspress container syntax (:::warning, :::note, :::important) with correct blank lines.
  4. Added language tags (bash, text) to all code blocks.
  5. Fixed duplicated "Save changes and exit the file." line from the original text.

Check Before Pushing

  • Disk Device Names: Verify that users are cautioned to check their actual disk identifier (e.g., /dev/vdb) using fdisk -l before running mkfs.ext4, as secondary disks can vary across environments.
  • File Extension: Ensure the file is renamed to .mdx when placed in the repository.

Remember to rename the file to .mdx, update any links that include the .md extension, and keep the blank lines around <Steps>, inside <details>, and inside callouts.