How to Add or Expand SSD Disks on your Cloud VPS

Estimated reading time: 4 min

Introduction

At Snel.com you can easily add additional SSD storage to your VPS via your client area. This is quite handy when you run out of free space on your existing disk. 

In this tutorial, we will go through how to purchase additional SSD disk space and attach it to your Cloud VPS. We can either use the additional space as a new disk and mount it on a separate directory or, we can expand the existing disk. In this tutorial, we will look at both options. 

Prerequisites

Step 1: Purchase Additional Storage

To purchase additional storage, click on Upgrade icon in your VPS dashboard. Now, change the slider on SSD only Storage to the required storage and click Continue button. Complete the transaction by paying the generated invoice. 

Now, you can either choose to create a new disk in your system and mount it on a separate directory. You will not lose any data stored on the original disk. You can also choose to expand the existing disk to the new size without any loss of data.

For adding the new storage as a new disk and mount on the separate mount point, follow Step #2

You also have the option to expand the existing disk to a new size without losing your data. Follow Step #3

Step 2: Add New Disk

In this method, we will create a new disk from the additional storage we have purchased. We will create a new partition after attaching the new disk to the Cloud VPS. Finally, we will mount the partition on the VPS filesystem.

In this example, I already have a 100 disk attached to my system. I will demonstrate the steps by attaching another 100 GB to the Cloud VPS.

Step 2.1: Create New Disk and Attach to VPS

Navigate to storage tab in Cloud VPS dashboard and click on Add new disk option.

Change the slider according to your wish and click on button Add new disk. Your VPS will reboot as soon as you make this change. In a few moments, a new disk will be created and attached to your VPS.

Step 2.2: Find Newly Attached Disk

Get current filesystem information using the df -h command.

Notice that in the above output, we only have a single filesystem of 100GB mounted on /.

Run the following command to get the information about the attached disks.

sudo fdisk -l

As you can see in the above example output in label 1, you can see the existing disk which has a partition /dev/sda1. However, in label 2, you can see it does not have a partition.

To use the disk, we will need to create a partition. Please note the disk name /dev/sdb as we will need it for the next steps. The disk name may be different in your case, please note the actual value you get from the output of the above command.

Step 2.3: Create New Partition

To create a new partition, run the following command.

sudo fdisk /dev/sdb

Here, /dev/sdb is the disk name which you have obtained from the last step. Running the above command will run a wizard to create a new partition.

  1. Put command n to create a new partition.
  2. Next, It will ask for the partition type. Input p for selecting primary.
  3. Now, It will ask you for a partition number. You can enter 1, or you can simply press Enter key to choose the default option.
  4. Next, It will ask you for partition start sector number, press Enter key to choose the default value. Similarly, for the last sector also, choose the default value.
  5. Finally, press w to write the partition table.

You can now run sudo fdisk -l command to see that a new partition named /dev/sdb1 has been added to the disk /dev/sdb. Make a note of the partition name /dev/sdb1 as we will need it for the next step.

Step 2.4: Format New Partition and Create a Filesystem

Now that we have created a new partition, let’s format the partition and create a new file system. In Linux, we have the option to use many types of the available file system. To keep things simple, we will create a file which same as the filesystem on the other disk /dev/sda1.

Find out the filesystem of the existing partition of the disk which was attached to the VPS from the start using the command sudo df -h -T.

In the above output, we can see that my existing file system is xfs. So, I will also format the new partition using the xfs filesystem. Run the command for the same.

sudo mkfs.xfs /dev/sdb1

The above command will format the partition and will create a new partition with xfs filesystem.

If you see your existing filesystem type as ext4, please use the command sudo mkfs.ext4 /dev/sdb1 to create a new filesystem as ext4 type.

Step 2.5: Mount New Filesystem

Create a new directory to act as a mount point.

sudo mkdir /data

Here, you can choose any directory as the mount point instead of /data.

Mount the filesystem we created in the previous step to the directory we just created by running the command.

sudo mount /dev/sdb1 /data

To automatically remount the new filesystem on system restarts, open /etc/fstab in your favorite editor.

sudo vi /etc/fstab

Now add the following line at the end of the file.

/dev/sdb1       /data        xfs     defaults        0 0

If your filesystem type is ext4, make sure to replace xfs in the above line.

Your new disk is now ready to be used.

Step 3: Expand Existing Disk

Step 3.1 Expand the Disk from Snel Panel

Login to your dashboard and navigate to Storage tab of your VPS. You will see your existing disk there. Click on the Expand link next to it.

Now, scroll the disk to all the maximum or desired size and save the changes.

Wait for few minutes for the system to provision disk and VPS to reboot.

Step 3.2 Verify Disk

Now that we have expended the disk from Snel side. Now we will need to expand the partition. You can verify that the additional disk space has been added to your VPS or not by running the following command.

sudo lsblk

Notice the disk size of /dev/sda, it is 200 GB, but partition /dev/sda1 is of 100 GB.

Step 3.3 Find Filesystem of Existing Partition

Find the file system of the existing partition by running the following command.

sudo df -h -T

In the above output, we can see that my existing file system is xfs. In some cases, it can be ext4 also. Also, note the name of the partition and mount point, in my case, it is /dev/sda1 and mount point is /.

Step 3.4 Resize the partition

If your filesystem is of xfs type, run the following command to expand the partition.

sudo xfs_growfs /

In above command / is the mount point of the partition.

If your filesystem is of ext4 type, run the following command to expand the partition.

sudo resize2fs /dev/sda1

Where /dev/sda1 is the name of the partition.

You can now verify that disk has been expended by running the command df -h

Conclusion

In this tutorial, we have learned how to purchase additional disk on your Snel Cloud VPS and use it. We have gone through the steps required to use the additional space as a new disk or expanding the existing disk.

Was this article helpful?
Dislike 0
Views: 134

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *

snel-knowledgebase