Cloud VPS from $1.98/mo · pay with Bitcoin, Ethereum, Monero, USDT or Solana · paid in crypto
Linux

Rescue files from a Linux or Windows VPS that will not boot

A VPS that will not boot still holds your data: snapshot it, read the console, mount Linux or Windows disks read-only, copy files off, then repair.

CloudSat teamNovember 18, 20266 min read
Abstract illustration of a dark server box with a small hatch open, a thin beam of light carrying glowing folders out to a waiting second box.
On this pagePreserve the current state first

A server that stops booting rarely loses its files. Usually one piece of the start-up chain broke: the bootloader, a line in /etc/fstab, an initramfs after a kernel update, a driver on Windows. The disk underneath is intact, and the data on it is reachable. The order that keeps it that way: preserve the current state, find out how far the boot gets, copy the important files off, and only then repair.

Preserve the current state first

Take a snapshot of the broken server before you change anything. fsck, chkdsk and boot repairs write to the disk, and a repair that goes wrong can make recovery harder. With a snapshot you can always return to the broken-but-intact state and try another way. Snapshots taken from the CloudSat console (take a snapshot) cost $0.0384 per GB per month and can be deleted once the server works again.

Read the console

SSH and Remote Desktop only work once the system is up, so the out-of-band console (VNC or a serial console) is where diagnosis starts. What it shows decides the route:

What the console shows Likely cause Where to go
"You are in emergency mode" a bad /etc/fstab line or a failed filesystem check fix from the console
grub> or "no bootable device" bootloader or partition table damage rescue system
Kernel panic, "unable to mount root fs" broken initramfs or kernel update older kernel from the boot menu
Login prompt, but no network firewall or network configuration fix from the console
Windows "Automatic Repair" loop or a stop code a driver, an update or file system damage Windows Recovery Environment
INACCESSIBLE_BOOT_DEVICE storage driver or disk problem Windows Recovery Environment

On CloudSat, the server's Recovery tools card gives you the VNC console, and support can boot the server into a rescue system on request (recovery tools).

Fixes that need only the console

Emergency mode asks for the root password and gives you a shell with the root filesystem mounted. Look at what failed, then neutralize the bad mount:

journalctl -xb | tail -n 50
systemctl --failed
mount -o remount,rw /
nano /etc/fstab          # comment out the failing line, or add nofail to it
systemctl daemon-reload && mount -a && reboot

A full root disk stops services one after another and can hang the boot. Check with df -h /, then make room where it is safe to: journalctl --vacuum-size=200M trims the journal, apt clean or dnf clean all empties the package cache, and old archives in /var/log can go. Find the real cause once the server is up again.

A kernel that panics after an update usually leaves the previous one installed. Press Esc (or hold Shift on BIOS systems) as the console shows the boot, choose Advanced options in the GRUB menu and start the older kernel. Once up, rebuild the initramfs for the new kernel or remove it.

Boot a rescue system

When the system cannot start at all, boot a separate Linux environment (your provider's rescue mode, or a live ISO) and work on the server's disk from outside. Identify the disks and filesystems first:

lsblk -f

Mount Linux filesystems read-only

Read-only mounts with journal replay switched off guarantee that looking does not write:

mkdir -p /mnt/root
mount -o ro,noload /dev/vda1 /mnt/root          # ext4
mount -o ro,norecovery /dev/vda1 /mnt/root      # XFS
vgchange -ay && mount -o ro,noload /dev/mapper/vg0-root /mnt/root    # root on LVM
cryptsetup open /dev/vda3 cryptroot             # LUKS, then mount /dev/mapper/cryptroot

Mount Windows disks read-only

The Windows partition is the large NTFS one in lsblk -f. Current kernels include the ntfs3 driver; ntfs-3g works as well:

mkdir -p /mnt/win
mount -t ntfs3 -o ro /dev/vda3 /mnt/win

If Windows was hibernated, or Fast Startup left the volume marked as in use, write access is refused but read-only mounts work. Do not run ntfsfix on a disk you care about; let chkdsk repair NTFS from Windows later.

For a BitLocker volume, you need the 48-digit recovery key. cryptsetup reads BitLocker directly, after which you mount the opened device:

cryptsetup open --type bitlk /dev/vda3 win      # asks for the password or recovery key
mount -t ntfs3 -o ro /dev/mapper/win /mnt/win

User files live under C:\Users, IIS sites usually under C:\inetpub, and SQL Server databases in the instance's DATA folder.

Copy the files off

Send the files to another server over SSH. From the rescue system:

rsync -aHAX --info=progress2 /mnt/root/var/www/ backup@203.0.113.20:/srv/rescue/www/
rsync -rt --info=progress2 /mnt/win/Users/ backup@203.0.113.20:/srv/rescue/users/    # NTFS: skip Linux metadata
tar -C /mnt/root -czf - etc home | ssh backup@203.0.113.20 'cat > /srv/rescue/etc-home.tgz'

Copy configuration as well as data: /etc, web server and application configs, crontabs in /var/spool/cron, and TLS keys. They are what turns a rebuild from days into hours. Moving files over SSH covers rsync options in depth.

Databases need care. Raw files copied from a crashed database are only usable by the same database version, so copy the whole data directory, start it on another machine with that version and let it run its own crash recovery. Your latest dump is often the better source.

Repair, once the data is safe

Linux

Check filesystems only while they are unmounted. If xfs_repair complains about a dirty log, mount the filesystem once to replay it; xfs_repair -L throws the log away and can lose recent changes, so keep it as a last resort.

umount /mnt/root
e2fsck -f /dev/vda1          # ext4
xfs_repair /dev/vda1         # XFS

To repair the boot chain, enter the installed system with chroot:

mount /dev/vda1 /mnt/root
for d in dev proc sys run; do mount --rbind /$d /mnt/root/$d; done
chroot /mnt/root
update-grub && grub-install /dev/vda      # Debian and Ubuntu, BIOS boot
dracut --regenerate-all --force           # RHEL family, and Ubuntu 26.04, which uses dracut
update-initramfs -u -k all                # older Debian and Ubuntu releases

On UEFI systems, mount the EFI system partition at /boot/efi inside the chroot before reinstalling GRUB. On the RHEL family the configuration command is grub2-mkconfig -o /boot/grub2/grub.cfg.

Windows

After two failed starts, Windows opens the Recovery Environment by itself. In the console choose Troubleshoot, Advanced options, then Command Prompt. The Windows volume is not always C: there; check with diskpart and list volume.

chkdsk C: /f
sfc /scannow /offbootdir=C:\ /offwindir=C:\Windows
DISM /Image:C:\ /Cleanup-Image /RestoreHealth
bcdboot C:\Windows

The same menu offers Uninstall Updates and System Restore, which are faster when a monthly update or a new driver started the trouble. To reach Safe Mode and roll a driver back from Device Manager, run bcdedit /set {default} safeboot minimal in the recovery prompt and restart; once fixed, bcdedit /deletevalue {default} safeboot returns to a normal start.

Know when to stop

Once the data is copied, compare the time a repair is taking with the time a rebuild takes. A fresh image plus your rescued files and configuration is often the faster way to a clean server, and it leaves no hidden damage behind.

FAQ

Can I recover deleted files the same way?

No. Deleted files need undelete tools such as PhotoRec, run against a copy of the disk, and on SSD or NVMe storage with TRIM the blocks are often already erased. Snapshots and backups are the dependable route.

Why mount read-only first?

A read-write mount can replay a journal, update timestamps or start a cleanup, all of which change the disk before you know what state it is in. Read-only first, copies second, repairs third.

The rescue system shows no partitions at all. Is the data gone?

Not necessarily. A damaged partition table hides partitions that are still there, and testdisk can often find and restore them. Work on a snapshot or a copy, never on the only one.

Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.