# Using an additional disk on your server: partition, format and mount permanently

https://www.gyrohosting.com/en/knowledgebase/article/gyro-cloud-istanbul-using-additional-disk

- **What you will learn**: How to find the **empty** disk you added in the panel, partition it, format it, mount it on a folder and keep it mounted after reboots.
- **Time**: 10 minutes

## 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:

1. Find the disk (it appears as `sdb`, `sdc` and so on).
2. Create a file system on it (format it).
3. 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.**

> **Warning**
> 
> 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

1. **Find the disk.** Connect to the server and list disks: bash`lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT` Example output (25 GB root disk, 20 GB new disk): code`NAME 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 disk` The new disk has the size you entered in the panel, no partitions below it, and empty `FSTYPE` and `MOUNTPOINT` columns (here `sdb`). In the following commands use your own disk name instead of `sdb`.
2. **Partition it (recommended).** Write a GPT partition table and create a single partition: bash`parted -s /dev/sdb mklabel gpt mkpart data 1MiB 100% lsblk /dev/sdb # you should now see sdb1 underneath` If `parted` is missing, install it with `apt install parted` (Ubuntu/Debian) or `dnf install parted` (AlmaLinux/Rocky). Note You can also format the disk directly without partitioning (use `/dev/sdb` instead of `/dev/sdb1` in 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.
3. **Format it.** Choose a file system: bash`mkfs.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 default` On Ubuntu/Debian xfs may need `apt install xfsprogs`. If unsure, choose **ext4**. Changing the file system later means formatting again, which erases the data.
4. **Mount it.** Create a folder and mount the disk on it: bash`mkdir -p /mnt/data mount /dev/sdb1 /mnt/data df -hT /mnt/data` If `df` shows the disk size and file system, the disk is ready. To try it, write `echo hello > /mnt/data/file.txt`.
5. **Make it permanent.** `mount` only 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): bash`echo "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 `xfs` instead of `ext4` in that line. The `nofail` option at the end matters: if the disk cannot be mounted one day, the server still boots instead of hanging (see Section 5).
6. **Test it.** To verify it survives a reboot, restart the server and check the disk is still mounted: bash`reboot # 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
```

> **Note (AlmaLinux / Rocky)**
> 
> 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](https://www.gyrohosting.com/en/knowledgebase/article/gyro-cloud-istanbul-rdns-snapshots) 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 separate `fstab` line.

## 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](https://www.gyrohosting.com/en/knowledgebase/article/gyro-cloud-istanbul-expanding-disk-space).

## Next step

- [Growing the disk and expanding the space](https://www.gyrohosting.com/en/knowledgebase/article/gyro-cloud-istanbul-expanding-disk-space)
- [Adding disks: price and limits](https://www.gyrohosting.com/en/knowledgebase/article/gyro-cloud-istanbul-additional-disks)
- [Snapshots and backups](https://www.gyrohosting.com/en/knowledgebase/article/gyro-cloud-istanbul-rdns-snapshots)
