If you are with a hosting provider that uses WHMCS+VPS management platform architecture like Classic VPS, then you need to upgrade the entire VPS hosting package yourself to expand the hard drive. However, if you purchase a VPS host from a cloud host provider such as Linode, Alibaba Cloud, Tencent Cloud, etc., then when the hard drive is full, it supports independent expansion of the hard drive.

Another benefit of hard drive mounting is that you can store data on a mountable hard drive. When you change the VPS host, you can first uninstall the hard drive from the original VPS host, and then remount it on the new VPS host, so that the original storage The data in the hard disk is still retained in the new VPS host, which is especially beneficial for the migration of large storage websites.

Here we will share how to mount a hard drive on Linode, Alibaba Cloud and Tencent Cloud VPS hosts. Since the hard drive generally needs to be formatted before mounting the hard drive, it is recommended that you make a backup of your website before mounting the hard drive. For work, Linode, Alibaba Cloud and Tencent Cloud all have their own snapshot functions. You can create a snapshot before mounting the hard disk.

Linux mounted hard disk expansion method-Alibaba Cloud, Tencent Cloud, Linode mounted hard disk expansion method

For more information on how to use Linux VPS hosts and operating tips, here are:

  1. Summary of Linux system monitoring commands - master CPU, memory, disk IO, etc. to find performance bottlenecks
  2. Linux php-fpm optimization experience-php-fpm process takes up large memory and does not release memory problems
  3. Three ways to share folder directories in Linux - NFS remote mounting, GlusterFS shared storage and samba shared directories

PS: Updated on March 1, 2019, If your hard disk storage is always changing, you can try dynamic expansion to solve the problem of insufficient storage capacity "once and for all": Linux dedicated servers and VPS hosts Dynamic expansion of hard disk - LVM logical volume expansion and reduction method.

1. Alibaba Cloud VPS mounting disk expansion

1.1  Mounting precautions

If you want to mount the cloud disk purchased separately from Alibaba Cloud VPS on the VPS, you need to pay attention to the following two points:

1. Cloud disks can only be mounted to instances in the same availability zone in the same region and cannot be mounted across availability zones.

2. An ECS instance can mount up to 16 cloud disks for data disk use. At the same time, a cloud disk can only be mounted on one instance.

When Alibaba Cloud mounts a disk, the status of the cloud disk must be Available. In the left navigation bar, select Storage > Cloud Disk . Select region . Find the cloud disk to be mounted , and in the operation column, select More > to mount.

In the pop-up dialog box, complete the following settings:

1. Target instance: can only select ECS instances in the same availability zone.

2. Disk is released with the instance: If selected, when the instance is released, the cloud disk will also be released at the same time.

3. Automatic snapshots are released with the disk: If selected, when the cloud disk is released, all automatic snapshots created by the cloud disk will be released together, but manual snapshots will not be released. It is recommended that you do not select this option and keep the backup data.

4. After completing the settings, click to perform the mount.

2. Data disk partition

To mount a disk on Tencent Cloud, first execute the   fdisk /dev/vdb  command to partition the data disk.

Follow the prompts on the interface, enter "n" (new partition), "p" (new extended partition), "1" (use the first primary partition), press Enter twice (use the default configuration), and enter "w" ( Save the partition table) and start partitioning.

Note: This is an example of creating one partition. Developers can also create multiple partitions according to their own needs. When executing the following command, please pay attention to modifying the data drive letter. You can use "fdisk -l" to view the drive letter and other related information. The following uses vdb as an example. If it is another drive letter, just replace vdb with the drive letter. For example, replace fdisk /dev/vdb with fdisk /dev/xvdb. Please confirm that the path is "/dev/vdb". If it is incorrectly filled in as "/dev/vda", the cloud host will crash.

3.  View new partition

Use the fdisk -l command to see that the new partition vdb1 has been created.

4.  Format new partition

When formatting a partition, developers can decide the file system format themselves, such as ext2, ext3, etc. This example takes "ext3" as an example, enter   mkfs.ext3 /dev/vdb1

5.  Mount new partition

Use the   mkdir /mydata  command to create the mydata directory, then use the   mount /dev/vdb1 /mydata  command to manually mount the new partition, and finally use the   df -h  command to view it. . If the information shown in the figure appears, the mounting is successful and the data disk can be viewed.

6.  Automatically mount data disk

If you want the cloud server to automatically mount the data disk when restarting or starting up, you must add the partition information to /etc/fstab. If it is not added, the data disk will not be automatically mounted after the cloud server is restarted or powered on. Use the   echo ‘/dev/vdb1 /mydata ext3 defaults 0 0’ >> /etc/fstab  command to add partition information. Use the   cat /etc/fstab command to check. If the information shown in the figure appears, it means that the partition information has been added successfully.

Note: Please confirm whether the partition path is "/dev/vdb1". If the path is wrong, the cloud host will fail to restart.

3. Linode VPS mounted hard drive expansion

There are two methods for Linode VPS host to achieve hard disk expansion. One is to directly increase the space capacity on the original disk through Linode's disk editing to achieve expansion; the other is to use Linux to mount the hard disk to achieve expansion. For more information on how to use Linode host, see: Linode excellent VPS host experience - Linode VPS performance speed evaluation and usage issues.

3.1  Linode VPS hard drive upgrade

First, enter the Linode VPS management background and click Upgrade. Different VPS hosting packages will be listed here.

List all disks

lsblk

Format disk

Enter the main disk interface and find Filesystem Path, and use the command mkfs.ext4 Filesystem Path to format the disk.

mkfs.ext4 /dev/disk/by-id/scsi-0Linode_Volume_test-1

Mount disk

Create a directory as a mount point

mkdir /mnt/test-1

Mount disk to mount point

mount /dev/disk/by-id/scsi-0Linode_Volume_test-1 /mnt/test-1

View all mounted disks

df -kh

Unmount disk

umount /mnt/test-1

Used when transferring disks between different VPS

Store files

The mount point path is the disk entry. You only need to save the file to the path /mnt/test-1. After FTP connection, enter the /mnt/test-1 directory to see the file system under the disk

4. Summary

Above we used the ext3 file system when formatting the new hard drive. In fact, there is also an ext4 file system. Generally speaking, ext3 is enough for our use. The advantage of ext4 over ext3 is that Ext4 supports 1EB file system and files up to 16TB respectively, an unlimited number of subdirectories, and supports larger inodes.

Whether it is Alibaba Cloud, Tencent Cloud or Linode, you must remember to back up the original data before purchasing a mounted hard drive. Especially when some Linux directories need to mount a hard disk to expand the capacity, the data in the original directory will be cleared after mounting the hard disk. If your original website data is in this directory, please remember to transfer them out first.

Leave a Reply