Partition Additional Hard Drive KVM VPS
If for some reason you need more space in your KVM VPS, you can opt to have a second hard drive. It’s not possible to add additional space to your existing VPS hard drive because they are encrypted inside a logical volume. Having a second drive has great benefits. You could use your additional hard drive to store backups, host cPanel accounts on, or host a database. The possibilities are endless.
When you order your additional hard drive it’s assigned to your server but not setup. This guide will show you how to partition your additional drive, mount it to a folder, and configure it inside FSTAB so it’s mounted at boot time.
View Your Additional Drive Information
Before you start first, check the drive information. This will give you the hard drive information like its path which is needed to partition the drive. We do this fdisk -l
Here you can see your main hard drive and the additional drive. In our NVMe VPS servers, additional drives are usually mounted as /dev/vdb and the main hard drive as /dev/vda. You can see the total amount of space and other drive information.
Partition Additional Hard Drive
Now that you know your additional hard drive details it’s time to get to work. We’re going to partition this drive to use all of the space but you can add more partitions if you want. To start, issue the fdisk command and the path to the hard drive.
To see a full list of commands enter the letter m and hit enter. Here you see all the options that you can use. We’re going to create a new partition so enter n. This will be a primary partition so next, enter p. The partition number will be 1 because it’s our only partition so next, enter 1.
Next is the section that you assign the space to the partition. We are going to use all the space so just hit enter twice to use the default values.
Write Partition To Disk
You have your partition setup but it’s only in the memory. Next, we need to write the partition tables to the server. To write the changes enter w and press enter. You should see this message;
The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
To use the new drive you will have to format it. To format the drive with ext4 file system
You can use different file systems like xfs when formatting a hard drive. Just replace the ext4 in the command. You should get a message once the format is complete.
mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 655360 inodes, 2621440 blocks 131072 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2151677952 80 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 82768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
Using blkid you can now see the additional drive and information.
Mount Additional Hard Drive To Folder
To use your new hard drive you need to mount it to a folder. We are going to mount this to the backup folder but you can use any folder name. First make the folder
Now we can mount the additional hard drive to the backup folder.
mount /dev/vdb /backup
At this point you can see the additional drive mounted to the backup folder using the df -h command
So far you have partitioned your additional hard drive, formatted it, and mounted it to a folder. It can already be used but, let’s ensure the drive mounts when you boot your NVMe VPS. You mount drives at boot using FSTAB. If you have a remote fuse folder here is where you would mount it. Edit the existing file.
Mount Additional Drive At Boot
Enter your additional drive information using the TAB key to enter the rest of the information as in the image below.
Save and close the file. Your good to go! Reboot your server and your additional hard drive will be mounted and ready for use.
How was this article?
You might also like
More from Linux VPS Servers
DHCP or Dynamic Host Configuration Protocol is used on networks to assign and manage IPs. A Proxmox DHCP server is …
Why your current CentOS version will likely be your last Back in December 2020, when CentOS announced CentOS 8 would become …