Skip to content

Instantly share code, notes, and snippets.

@easeev
Last active March 25, 2026 19:57
Show Gist options
  • Select an option

  • Save easeev/18e818c509f43864fd3cacc2f5bd2533 to your computer and use it in GitHub Desktop.

Select an option

Save easeev/18e818c509f43864fd3cacc2f5bd2533 to your computer and use it in GitHub Desktop.
Extending Netcup root filesystem with Local Block Storage using LVM

Extending Netcup Root Filesystem with Local Block Storage (LVM)

This guide covers migrating a plain-partition Debian root filesystem to LVM and extending it with a second disk (Netcup Local Block Storage). The end result is a single root filesystem spanning both disks.

Prerequisites

  • A Netcup VPS or Root Server running Debian with a plain (non-LVM) root partition
  • A Local Block Storage volume attached via Netcup SCP (will appear as /dev/vdb)
  • Access to Netcup SCP to activate rescue mode

Overview

  1. Boot into rescue mode
  2. Set up LVM on the new disk and copy root to it
  3. Update fstab, regenerate initramfs, reinstall GRUB
  4. Boot into the new LVM root
  5. Add the old disk to the VG for full combined capacity

Step 1: Attach Local Block Storage

In Netcup SCP, navigate to your server and attach the Local Block Storage volume.

Step 2: Boot into Rescue Mode

In Netcup SCP, shut down the server, then go to Media (left sidebar) → click the Rescue System tab in the top-right corner of the page → activate the rescue system. The server will start automatically in rescue mode.

Step 3: Set Up LVM on the New Disk

apt-get install -y lvm2
pvcreate /dev/vdb
vgcreate vg0 /dev/vdb
lvcreate -l 100%FREE -n root vg0
mkfs.ext4 /dev/vg0/root

Step 4: Copy Root Filesystem

mkdir /mnt/old /mnt/new
mount /dev/vda3 /mnt/old
mount /dev/vg0/root /mnt/new
rsync -aAX --info=progress2 --exclude={"/proc/*","/sys/*","/dev/*","/run/*"} /mnt/old/ /mnt/new/

--info=progress2 shows overall transfer progress (total size, speed, ETA). For a 2TB disk expect this to take 20–30+ minutes.

Step 5: Update /etc/fstab

sed -i "s/$(blkid -s UUID -o value /dev/vda3)/$(blkid -s UUID -o value /dev/vg0/root)/" /mnt/new/etc/fstab
cat /mnt/new/etc/fstab

Step 6: Regenerate initramfs and Reinstall GRUB

Mount /boot and bind-mount the required virtual filesystems, then chroot:

mount /dev/vda2 /mnt/new/boot
for d in dev dev/pts proc sys run; do mount --bind /$d /mnt/new/$d; done
chroot /mnt/new /bin/bash

Inside the chroot:

apt-get install -y lvm2
update-initramfs -u -k all   # -k all ensures every installed kernel gets LVM support
update-grub
grub-install /dev/vda
exit

Unmount everything:

umount -Rl /mnt/new

Step 7: Boot into Normal Mode

In Netcup SCP, go to MediaRescue System and deactivate the rescue system, then start the server.

Step 8: Add the Old Disk to the VG (Get Full Combined Capacity)

pvcreate -y /dev/vda3
vgextend vg0 /dev/vda3
lvextend -l +100%FREE /dev/vg0/root
resize2fs /dev/vg0/root

Verify:

df -h /
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment