Using an additional disk on your server: partition, format and mount permanently
1. What you should know first
A disk added from the panel arrives on your server as a raw, empty disk. The server sees it, but it has no file system, so it is not mounted anywhere. You will do three things:
- Find the disk (it appears as
sdb,sdcand so on). - Create a file system on it (format it).
- Mount it on a folder and make that permanent.
The commands below are the same on Ubuntu, Debian, AlmaLinux and Rocky Linux; differences are noted where they matter. An HDD (large storage) additional disk is used with exactly the same steps.
Formatting erases everything on the disk. Do not pick the wrong disk. Your root disk is usually sda; the new disk comes after it. In these examples the new disk is sdb; yours may differ.
2. Step by step: preparing the disk
-
Find the disk. Connect to the server and list disks:
bashlsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTExample output (25 GB root disk, 20 GB new disk):
codeNAME SIZE TYPE FSTYPE MOUNTPOINT sda 25G disk ├─sda1 24G part ext4 / ├─sda14 4M part ├─sda15 106M part vfat /boot/efi └─sda16 913M part ext4 /boot sdb 20G diskThe new disk has the size you entered in the panel, no partitions below it, and empty
FSTYPEandMOUNTPOINTcolumns (heresdb). In the following commands use your own disk name instead ofsdb. -
Partition it (recommended). Write a GPT partition table and create a single partition:
bashparted -s /dev/sdb mklabel gpt mkpart data 1MiB 100% lsblk /dev/sdb # you should now see sdb1 underneathIf
partedis missing, install it withapt install parted(Ubuntu/Debian) ordnf install parted(AlmaLinux/Rocky).NoteYou can also format the disk directly without partitioning (use
/dev/sdbinstead of/dev/sdb1in Step 3). It is simpler and makes growing easier later, but some tools may mistake an unpartitioned disk for an empty one and write over it. If unsure, partition. -
Format it. Choose a file system:
bashmkfs.ext4 -L data /dev/sdb1 # ext4: available everywhere, reliable, the common choice # or mkfs.xfs -L data /dev/sdb1 # xfs: for large files and heavy writes; the AlmaLinux/Rocky defaultOn Ubuntu/Debian xfs may need
apt install xfsprogs. If unsure, choose ext4. Changing the file system later means formatting again, which erases the data. -
Mount it. Create a folder and mount the disk on it:
bashmkdir -p /mnt/data mount /dev/sdb1 /mnt/data df -hT /mnt/dataIf
dfshows the disk size and file system, the disk is ready. To try it, writeecho hello > /mnt/data/file.txt. -
Make it permanent.
mountonly lasts for that session; after a reboot the mount is gone. To make it permanent, add a line to/etc/fstab. Use the disk's UUID in that line, not/dev/sdb1(device names can change across reboots, the UUID does not):bashecho "UUID=$(blkid -s UUID -o value /dev/sdb1) /mnt/data ext4 defaults,nofail 0 2" >> /etc/fstab systemctl daemon-reload mount -a && echo "fstab ok"If you used xfs, write
xfsinstead ofext4in that line. Thenofailoption at the end matters: if the disk cannot be mounted one day, the server still boots instead of hanging (see Section 5). -
Test it. To verify it survives a reboot, restart the server and check the disk is still mounted:
bashreboot # reconnect df -hT /mnt/data cat /mnt/data/file.txt
3. File permissions
When you format and mount as root, the folder is owned by root. To let another user (for example your web application's user) write to it, give ownership:
chown -R appuser:appuser /mnt/data # replace appuser with your own user name
chmod 750 /mnt/data
SELinux is on in these distributions. For plain file storage no extra setting is needed; but if a service (such as a database) will keep its data in this folder, the service's SELinux context must be set separately. See that service's documentation; turning SELinux off completely is not recommended.
4. Common uses
- Database data: stop the service, copy the existing data folder to the new disk (
rsync -a), then change the data folder in the service's configuration. Do not rush; take a snapshot first. - Backups: point your backup script's target to
/mnt/data/backup. A backup on the server's own disk is lost when the server is deleted; copy important backups off the server too. - Several disks: repeat Steps 1-6 for each new disk, with a different folder (
/mnt/media,/mnt/logs) and a separatefstabline.
5. Common problems
The disk does not show in lsblk.
Check in the panel that the disk was added and the task finished. If the server was not told about the new disk, ask it to rescan:
for h in /sys/class/scsi_host/host*/scan; do echo "- - -" > $h; done
lsblk
mount: wrong fs type, bad option, bad superblock error.
The disk is probably not formatted yet, or you are mounting the wrong partition. Check the FSTYPE column with lsblk -f; if it is empty, do Step 3.
mkfs says the disk "contains a ... file system" or asks for confirmation.
The disk may have been used before. If you are sure it is the right disk and you do not need its content, continue; if not, stop and check the disk again with lsblk -f.
The disk is not mounted after a reboot.
Check the fstab line: if mount -a prints an error, there is a typo. Make sure the UUID matches the output of blkid /dev/sdb1.
The server does not boot because of an fstab error.
The nofail option largely prevents this: if the disk cannot be mounted the system still boots and only that folder stays empty. If the server still stops in "emergency mode", open the Console in the panel, log in as root and fix the faulty line, or comment it out with # (nano /etc/fstab), then run reboot. Copying fstab before editing is a good habit: cp /etc/fstab /etc/fstab.bak.
I deleted the disk in the panel; how does the server react?
Before deleting, unmount the disk on the server (umount /mnt/data) and remove the fstab line or disable it with #. The data of a deleted disk cannot be recovered. Thanks to nofail, a forgotten line does not stop the server from booting.
Disk names changed (sdc instead of sdb).
With several disks, names can shift when a disk is added or removed. That is why we always use the UUID in fstab.
6. Frequently asked questions
Which file system should I choose, ext4 or xfs?
If unsure, ext4. It works everywhere and its growing and repair tools are widespread. xfs is good for large files and heavy writes but cannot be shrunk. (Additional disks on Gyro cannot be shrunk anyway.)
Do I have to partition the disk?
No; you can format it directly. Partitioning is a safe habit if you want to keep other tools from touching the disk by accident.
What happens to the additional disk when I delete the server?
Additional disks are deleted with the server. Reinstalling the operating system also deletes them; back up your data first.
What do I do when the disk fills up?
You can grow the disk in the panel; then you must expand the space inside the server. See the growing the disk and expanding the space guide.
Next step
Thanks for your feedback!
