How to add a second disk to your server, partition and mount it on Linux and FreeBSD, enlarge it, and attach it again after a reinstall.
Contents
An additional disk is separate from the system disk. It is a good place to keep data, databases and backups: when you reinstall the system, the additional disk stays, along with everything on it, while the system disk is wiped.
How to add a disk
In your control panel, open your server’s resources, find the list of disks and choose to add a disk, then pick a size. The size can be from 10 to 1,000 GB in steps of 10 GB, and a server can have up to three additional disks.
The disk is attached to the running server automatically; you don’t need to reboot it. It appears in the system empty — you need to partition it and mount it on a directory, as described below.
Linux: partitioning and mounting
Find the new disk: lsblk lists all the server’s disks. The system disk is sda, the first additional disk is usually sdb, and the next is sdc. The new disk has no partitions or mount point, and its size is the one you ordered.
If the disk isn’t in the list, ask the system to scan for it again:
for h in /sys/class/scsi_host/host*/scan; do echo '- - -' | sudo tee $h; doneCreate a file system on the disk. You don’t need a separate partition: the file system takes up the whole disk, which makes it easier to enlarge later. On Ubuntu and Debian, use ext4:
sudo mkfs.ext4 -L data /dev/sdbOn AlmaLinux, use XFS, as on the system disk:
sudo mkfs.xfs -L data /dev/sdbMount the disk on a directory — for example, /data:
sudo mkdir -p /data
sudo mount /dev/sdb /data
df -h /dataTo have the disk mounted after a reboot too, add it to /etc/fstab. Refer to it by UUID: the name sdb can change, but the UUID doesn’t.
echo "UUID=$(sudo blkid -s UUID -o value /dev/sdb) /data ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstabFor XFS, write xfs instead of ext4 and change the last digit to 0. The nofail option makes sure the server still boots if the disk can’t be found for any reason.
Check the entry without rebooting the server. If the commands run without errors and df shows the disk again, everything is fine:
sudo systemctl daemon-reload
sudo umount /data
sudo mount -a
df -h /dataFreeBSD: partitioning and mounting
On FreeBSD, disks are named da0, da1…: the system disk is da0 and the first additional disk is da1. To list the disks, run geom disk list. If the new disk isn’t there, scan for it again with sudo camcontrol rescan all.
sudo gpart create -s gpt da1
sudo gpart add -t freebsd-ufs -l data da1
sudo newfs -U /dev/gpt/data
sudo mkdir -p /data
sudo mount /dev/gpt/data /data
echo '/dev/gpt/data /data ufs rw 2 2' | sudo tee -a /etc/fstabThe partition has the label data: the system uses it to find the disk at boot, even if its number changes.
How to enlarge a disk
In your control panel, open your server’s resources, choose to enlarge the additional disk, then pick the new size and confirm. The disk grows while the server is running, but you need to extend the file system yourself. A disk can’t be made smaller.
Linux, ext4:
echo 1 | sudo tee /sys/class/block/sdb/device/rescan
sudo resize2fs /dev/sdb
df -h /dataXFS — after the same first command, run sudo xfs_growfs /data.
FreeBSD:
sudo camcontrol reprobe da1
sudo gpart recover da1
sudo gpart resize -i 1 da1
sudo growfs -y /dataThe system disk is enlarged in the same place; the system extends its partition itself, sometimes after a reboot.
After reinstalling the system
Reinstalling wipes only the system disk — additional disks and the data on them stay. The new system doesn’t know about them: mount them again, but without creating a file system — it already exists, and your data is intact.
On Linux, sudo lsblk -f shows the disk’s file system and its label, data. After that, create the directory, add the line to /etc/fstab and check it, as in the Linux section, but without mkfs. On FreeBSD, add the same /dev/gpt/data line to /etc/fstab and run sudo mount -a.
If the server has snapshots, you can’t reinstall it while it has additional disks — delete the snapshots first.
Shrinking or removing a disk
You can shrink or remove an additional disk on request — contact our support team through the contact form. Before removal, move any data you need and delete the disk’s line from /etc/fstab.
Didn’t find the answer? Ask our support team — we’ll help.