SELFHOST.COMPUTER

netcup rescue system: boot it, mount your disk and repair a server that won't start

#netcup#vps#troubleshooting

The netcup rescue system is a small Linux that boots instead of your installed system. When a VPS or root server won't boot, SSH is broken or the filesystem is damaged, it is the way back in. This guide covers how to start it, how to get at your disk, and the three jobs people use it for: resetting a root password, checking a filesystem and checking the network.

Every netcup-specific step below comes from netcup's help center; I link each page. The mount and chroot commands are netcup's own example, so check device names against your own server. If you haven't used the Server Control Panel yet, read the netcup SCP guide first.

What the rescue system is

netcup describes it as a minimal operating system that runs independently of the installed one. It is the Linux distribution Grml. netcup lists these uses: testing performance and stability, checking network problems, backing up data and repairing the main system.

One thing to know up front: while the rescue system is active, the netcup firewall is disabled and cannot be switched on. Don't leave it running longer than you need.

Start the rescue system

From netcup's rescue system page:

  1. Log in to the SCP and select the server.
  2. Under Control, click ACPI Shutdown. The server must be off before you activate the rescue system.
  3. Go to Media, then Rescue System, click Activate and confirm with OK.
  4. Note the password the SCP shows. The server then boots into the rescue system.

Connect with the Screen console in the SCP, or over SSH as root with that password:

ssh root@YOUR_SERVER_IP

SSH will probably warn that the host key changed, because the rescue system has different keys from your installed server. That is expected. Remove the old entry with ssh-keygen -R YOUR_SERVER_IP and connect again. Afterwards, the same warning will appear in reverse when you go back to the normal system, so remove the entry again.

netcup says the server normally has IPv4 and IPv6 in the rescue system. If the network isn't up, run grml-network, choose netcardconfig, answer No to "Configure VLAN on this interface?" and Yes to enabling the interface at boot.

Mount your disk

Your disk is not mounted when the rescue system starts. netcup's hard drive page shows how to find and mount it:

lsblk
mount /dev/vda3 /mnt

Replace /dev/vda3 with the root partition lsblk shows on your server. Your files are now under /mnt, which is enough to copy data off. If the disk is encrypted, you have to unlock it before it can be mounted. netcup's page doesn't cover that, so follow your distribution's documentation for your encryption setup.

If you only need files, copy them away now (rsync or scp to another machine) and keep the server untouched. Backups made before things broke are better, so see the restic backup guide for a setup that doesn't rely on the server itself.

Work inside the installed system with chroot

To change things in the installed system, such as a password or the bootloader, you run a shell inside it. netcup gives this as an example only, and says it needs advanced Linux knowledge. With the root partition already on /mnt:

mount /dev/vda2 /mnt/boot      # only if /boot is a separate partition
mount -t proc proc /mnt/proc
mount -t sysfs sys /mnt/sys
mount -o bind /dev /mnt/dev
chroot /mnt /bin/bash

Inside the chroot, you may need nameservers in /etc/resolv.conf before the network works. When you are done:

exit
umount /mnt/boot               # only if you mounted it
umount /mnt/{proc,sys,dev}
umount /mnt

Reset the root password

With the chroot active, passwd sets a new root password for the installed system. The SCP also has a Set Root Password option on its Access page, which netcup says works only on Linux servers with an unencrypted disk. For a simple forgotten password, try that first, because it needs no chroot.

Fix a broken SSH or firewall change

If a bad sshd_config or firewall rule locked you out, the chroot lets you undo it. Edit the file under /etc inside the chroot, leave, unmount and reboot. Before reaching for the rescue system, the SCP Screen console may be enough. Plan changes with the firewall rule generator and the SSH hardening guide so that you keep a way back in. Docker adds its own twist, covered in Docker ignores ufw.

Reinstall the bootloader

netcup mentions this as a chroot job but gives no commands, because they depend on your distribution and on BIOS or UEFI boot. Use your distribution's documentation for the exact steps.

Repair filesystem errors

If you see filesystem errors during boot, netcup's filesystem page says to try fsck:

lsblk
fsck -C0 -y -f /dev/vda3

Replace the partition with the one that has the errors. -y answers yes to every repair question, so the check does not stop to ask. netcup warns that this can lose data if the filesystem is badly damaged, tells you to back up first and says it needs good Linux administration knowledge. One note of my own: the disk isn't mounted when the rescue system starts, so run fsck before you mount anything, because checking a mounted filesystem is not safe.

Check network problems

netcup uses the rescue system to rule out your installed system when you report network trouble. Its network issues page walks through these steps:

  1. Check the SCP firewall policies. Switch the firewall off, or put an allow-all policy first.
  2. Boot the rescue system. netcup notes the tests have to be run while it is active.
  3. Check DHCP with dhclient -v eth0 (find your interface name with ip a).
  4. Check packet loss with mtr SERVER_IP, using at least 500 pings in both directions. netcup wants MTR output, not plain traceroute.
  5. Measure speed with iperf3 against netcup's test server, in both directions and for IPv4 and IPv6. The exact commands are on the page.

If it still looks wrong, netcup asks for a support ticket with your customer number, the server name and IP, the command outputs as a text attachment and a note that you tested in the rescue system. For current outages, check netcup's status page.

Leave the rescue system

It doesn't turn itself off. In the SCP, open Rescue System and click Deactivate, then OK. The server shuts down, and you start it manually. The boot sequence goes back to its previous setting. Then check that the firewall is active again and that your services came up.

A short checklist

  • Take a snapshot or a backup before repair work, if the server still has one.
  • Write down the rescue password the SCP shows.
  • Use lsblk to confirm partition names before every mount and fsck.
  • Unmount, deactivate the rescue system, then start the server.

To be set up so you rarely need this, work through the first 15 minutes on a fresh VPS checklist and keep off-site backups. Looking for a server in the first place? The netcup VPS vouchers list the current offers.

< all posts · netcup voucher codes

Keep reading