Skip to content
Serverküche
Search

Loading search …

netcup Difficulty: Beginner

netcup Local Block Storage: attach, format, mount permanently

Attach extra netcup storage the right way: identify the disk safely, format it, mount it via fstab – with the one switch that otherwise blocks the reboot.

· 9 min read ·Duration: approx. 20 minutes
Table of contents

Photos, films, documents: sooner or later the system disk is full. Instead of booking the bigger server right away, at netcup you simply attach a second disk: the Local Block Storage.

Attaching it is quick. The mistake that costs you later sits in a single line of /etc/fstab. That line is what this article is mostly about.

What are we building?

An extra disk that is available under /mnt/lbs after every reboot, automatically, and on which your Docker applications keep their large data: Jellyfin’s media library, Immich’s photos, Paperless’s archive.

The steps come from a VPS 1000 G12 with 100 GB of Local Block Storage, including an actual reboot. The extra disk there is just as fast as the system disk, by the way (figures at the end).

Requirements

  • A netcup server with root access, set up as in First steps with the netcup VPS.
  • A Local Block Storage booked in the customer area. netcup allows up to five such units per server.
  • A current snapshot of the server. You are about to run commands that wipe a disk, so you want a way back.
🍳 Recommendation Ad

VPS 1000 G12.5

4 vCores · 8 GB RAM · 128 GB SSD

from €14.50/month

The server from this article. Block storage can be added to all current VPS and root server plans.

Go to netcup →

💶 1 month free:

Single use, valid for VPS 1000 G12.5. Redeem in the cart →

💶 €5.95 voucher for new netcup customers: always valid · not for domains or VPS Lite

All netcup vouchers →

Step by step

Step 1: Identify the new disk unambiguously

After booking, the storage shows up in the server as an additional drive. List all drives:

Terminal
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
Ausgabe
NAME     SIZE TYPE FSTYPE MOUNTPOINTS
sr0     1024M rom
vda      256G disk
├─vda1     1M part
├─vda2   244M part vfat   /boot/efi
├─vda3   977M part ext4   /boot
└─vda4 254.8G part ext4   /
vdb      100G disk

vda is the system disk, recognisable by its partitions and the mount point /. The new disk is vdb: exactly the booked size, no partitions, no file system.

Never go by the name, always by the size

The following commands wipe whichever disk you name. Hit the system disk and the server is broken. So always identify the device by its size and its lack of partitions, not by the expectation that it will surely be called vdb.

Also check that there really is nothing on it:

Terminal
wipefs -n /dev/vdb

No output means: no partition table, no file system, nothing to lose.

Step 2: Create a partition

One partition across the whole disk, with a GPT table. sfdisk is already installed on Debian and, unlike interactive tools, can be typed in exactly as shown:

Terminal
echo 'label: gpt
type=linux' | sfdisk /dev/vdb
Ausgabe
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Why GPT rather than the older MBR: MBR can address at most 2 TiB. netcup lets you enlarge the block storage later, and with GPT you will not hit a ceiling.

Step 3: Create the file system

Terminal
mkfs.ext4 -L lbs /dev/vdb1

The -L lbs gives the file system a name. You do not strictly need it, but it makes the output of lsblk and blkid readable at a glance later on.

Step 4: Get the 5 percent back

By default ext4 reserves 5 % of the disk for the root user. On the system disk that makes sense, because the system stays usable when a program fills the disk. On a pure data disk it is wasted space:

Terminal
tune2fs -m 0 /dev/vdb1

At 100 GB that is a good 5 GB:

Ausgabe
before:  /dev/vdb1   98G  2.1M   93G   1% /mnt/lbs
after:   /dev/vdb1   98G  2.1M   98G   1% /mnt/lbs

That df shows 98 rather than 100 in total is down to the file system’s own bookkeeping, mainly the inode table. It is not the units: the disk has exactly 100 GiB (107,374,182,400 bytes), and df -h counts in GiB as well.

Step 5: Mount it

Terminal
mkdir -p /mnt/lbs
mount /dev/vdb1 /mnt/lbs
df -h /mnt/lbs
Ausgabe
Filesystem      Size  Used Avail Use% Mounted on
/dev/vdb1        98G  2.1M   98G   1% /mnt/lbs

The disk is now usable, but only until the next reboot.

Step 6: Make it permanent – with nofail

For the disk to come back after every reboot, it belongs in /etc/fstab. First read the UUID. Device names like /dev/vdb1 can change once a second extra disk is added; the UUID stays.

Terminal
blkid /dev/vdb1
Ausgabe
/dev/vdb1: LABEL="lbs" UUID="8f849e77-858a-4b48-afaa-5391a2dc81a5" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="30e5e236-02df-40d2-b580-e342c236e178"

Make a copy of the fstab first, then append the line with your UUID:

Terminal
cp /etc/fstab /etc/fstab.before
echo 'UUID=YOUR_UUID  /mnt/lbs  ext4  defaults,nofail  0  2' >> /etc/fstab

The nofail is the most important part of this article. Without it, systemd treats the disk as required for booting. You can check that without putting the server at risk. Reload first, then ask:

Terminal
systemctl daemon-reload
systemctl show mnt-lbs.mount -p RequiredBy -p WantedBy
Ausgabe
with nofail:      RequiredBy=                    WantedBy=local-fs.target
without nofail:   RequiredBy=local-fs.target     WantedBy=

RequiredBy means: if the disk is missing at boot, the local-fs.target target fails and the server ends up in emergency mode, with no network and no SSH. Then it is reachable only through the console in the Server Control Panel. The disk can go missing sooner than you think: after cancelling the add-on, during maintenance, after moving to another server. With nofail the server boots anyway, just without /mnt/lbs.

Do not forget daemon-reload

After every change to the fstab, systemd keeps working with the old version until you run systemctl daemon-reload. mount reminds you with your fstab has been modified, but systemd still uses the old version.

Step 7: Check before you reboot

Otherwise a typo in the fstab only shows up at the next reboot. So check twice: first the syntax, then whether the line actually mounts.

Terminal
findmnt --verify
Ausgabe
/media/cdrom0
   [W] cannot detect on-disk filesystem type (No medium found)
/media/cdrom1
   [W] unreachable source: /dev/sr1: No such file or directory
   [W] cannot detect on-disk filesystem type (No such file or directory)

0 parse errors, 0 errors, 3 warnings

The three warnings concern the CD-ROM lines netcup puts into the fstab by default. They were there before and are harmless. What matters is 0 errors and no warning under /mnt/lbs.

Terminal
umount /mnt/lbs && mount -a && findmnt /mnt/lbs
Ausgabe
TARGET   SOURCE    FSTYPE OPTIONS
/mnt/lbs /dev/vdb1 ext4   rw,relatime

If the disk is mounted again after mount -a, the entry is right.

Step 8: The real reboot

In the end all that counts is whether it is really back after a reboot. Create a test file and restart:

Terminal
echo test > /mnt/lbs/marker.txt
systemctl reboot

After the reboot:

Terminal
findmnt /mnt/lbs; cat /mnt/lbs/marker.txt; systemctl --failed
Ausgabe
TARGET   SOURCE    FSTYPE OPTIONS
/mnt/lbs /dev/vdb1 ext4   rw,relatime
test
  UNIT LOAD ACTIVE SUB DESCRIPTION

0 loaded units listed.

After about 40 seconds the server is reachable again, the disk mounted and the file there. Docker restarts running containers such as Traefik by itself.

Step 9: Put Docker applications on it

The best way to use the disk is to give each application its own subdirectory, which it mounts as a bind mount:

Terminal
mkdir -p /mnt/lbs/jellyfin/media /mnt/lbs/immich/library

In the Compose file the large data path then points at the block storage, while the small configuration stays on the system disk:

YAML
    volumes:
      - ./config:/config                   # small, system disk
      - /mnt/lbs/jellyfin/media:/media     # large, block storage

How this looks for the individual applications is covered under Jellyfin and Immich. Mind the ownership: if an application runs as user 1000, it needs chown -R 1000:1000 on its directory.

How fast is the extra disk?

According to netcup, the block storage uses the same disk type as the server, so NVMe on NVMe systems. Measured with fio on our test server, warm-up run discarded, median of three runs:

MeasurementSystem disk vdaBlock storage vdb
4K random read101,000 IOPS101,000 IOPS
4K random write97,900 IOPS100,000 IOPS
1M sequential read4,128 MiB/s4,129 MiB/s
1M sequential write2,743 MiB/s2,842 MiB/s

No difference that matters day to day. Something else stands out instead: both disks top out at exactly 101,000 IOPS and 4,128 MiB/s on reads. We measured the same values on a different server too. That looks like a fixed ceiling netcup sets per disk, not a limit of the hardware.

When things go wrong

After a reboot the server can no longer be reached over SSH. Most likely it is stuck in emergency mode because an fstab line could not be mounted and carries no nofail. Open the console in the Server Control Panel, log in as root, fix the line in /etc/fstab or comment it out with #, and reboot. The copy /etc/fstab.before from step 6 helps here.

mount reports wrong fs type, bad option, bad superblock on /dev/vdb. You named the disk instead of the partition. The file system lives on /dev/vdb1, not on /dev/vdb.

df shows clearly less than you booked. In the Avail column it is usually the 5 % reserve that is still active (step 4). In Size, about 2 % less is normal: that is the file system’s bookkeeping, and both the booking and the display are in GiB.

An application cannot write to the block storage. The new file system belongs to root. If the container runs as a different user, give it its directory with chown -R 1000:1000 /mnt/lbs/APPLICATION. The number is the user ID from the Compose file.

After enlarging it in the customer area, /mnt/lbs is still the same size. netcup only enlarges the drive; you grow the partition and the file system yourself. That works while the disk is in use, though a snapshot first does no harm. Once lsblk shows the new size for vdb, first extend the partition to the end, have the kernel re-read it, then grow the file system: echo ', +' | sfdisk --no-reread -N 1 /dev/vdb, then partx -u /dev/vdb and resize2fs /dev/vdb1. The message Re-reading the partition table failed from sfdisk is normal here; that is exactly what partx is for.

Your problem is not listed? Search all error messages →

Maintenance & backups

Block storage is not a backup. It sits in the same data centre and hangs off the same server; netcup itself calls it less suitable for backups. Whatever lives on it belongs in your restic backup just like everything else, precisely because this is usually where the large, irreplaceable data ends up.

Snapshots have a restriction. According to netcup, online snapshots are currently not possible for Local Block Storage, only offline snapshots. So plan a short downtime for a snapshot.

Shrinking is not possible. netcup can enlarge block storage later, but not shrink it. Book on the small side and top up later rather than the other way round.

Keep an eye on the fill level. Media libraries grow quietly. A df -h /mnt/lbs in the monthly round or an alert in your Prometheus monitoring at 85 % stops an application from grinding to a halt one night in the middle of an import.

You might also like