How to Rescue and Troubleshoot a VPS Using GRML


In this article, we will show you how to use GRML to troubleshoot and recover a VPS when the installed operating system is not booting correctly or cannot be accessed normally.

GRML is a Debian-based live Linux system that includes various utilities useful for system administration, disk management, filesystem repair, data recovery, and troubleshooting.

GRML can be useful for situations such as:

  • The VPS is unable to boot.
  • SSH access is unavailable.
  • The filesystem needs to be checked or repaired.
  • Important files need to be recovered.
  • The bootloader needs to be repaired.
  • You need to inspect or modify files on the installed operating system.

Note: Before performing any filesystem or bootloader operations, we recommend taking a backup of the VPS if possible.

Mount the GRML CD-ROM/ISO Image


First, mount the GRML CD-ROM/ISO image from CrownPanel.

images

Once the GRML ISO has been mounted, boot the VPS from the mounted ISO.

You should see the GRML boot screen.

images

Press Enter to continue with the default GRML boot option.

Wait for GRML to finish booting. You will eventually be presented with a command-line console.

images

Identify the VPS Disk and Partitions

Once you are in the GRML console, we first need to identify the disk and partitions belonging to the installed operating system.

Run:

fdisk -l

images

Look for the disk and partitions containing the installed operating system.

You can use the following command to identify the filesystem type:

lsblk -f

Note: Device names may differ depending on the VPS configuration. Do not assume that /dev/vda1 is the correct partition. Always verify the partition using lsblk -f or fdisk -l.

Mount the VPS Filesystem

Once you have identified the correct Linux root partition, create a directory to use as the mount point.

mkdir /mnt/root

Mount the partition:

mount /dev/vda2 /mnt/root

Note: Replace /dev/vda2 with the actual Linux root partition of your VPS.

Verify that the filesystem has been mounted correctly:

ls -lah /mnt/root

You should see directories such as:

bin
boot
etc
home
root
usr
var

images

Check and Repair the Filesystem

If the VPS is unable to boot because of filesystem errors, you can use fsck to check the filesystem.

Important: Never run fsck against a mounted filesystem.

First unmount the partition:

umount /dev/vda2

Run the filesystem check:

fsck -f /dev/vda2

Note: Replace /dev/vda2 with the correct partition. The appropriate filesystem-specific utility may be required if the partition does not use ext4.

After the filesystem check has completed, mount the partition again:

mount /dev/vda2 /mnt/root

Access the Installed Operating System

GRML can also be used to access the installed operating system using chroot.

First, mount the required system filesystems:

mount --bind /dev /mnt/root/dev
mount --bind /dev/pts /mnt/root/dev/pts
mount -t proc /proc /mnt/root/proc
mount -t sysfs /sys /mnt/root/sys

Copy the DNS configuration:

cp -L /etc/resolv.conf /mnt/root/etc/resolv.conf

Now enter the installed operating system:

chroot /mnt/root /bin/bash

You can verify the installed operating system using:

cat /etc/os-release

images

You can now perform troubleshooting or configuration changes within the installed operating system.

Check System Logs


If the VPS is not booting correctly, checking the system logs may help identify the issue.

Exit the chroot environment if you are currently inside it:

exit

You can then inspect the log directory:

ls -lah /mnt/root/var/log/

Depending on the operating system, you may find logs such as:

/mnt/root/var/log/syslog

or:

/mnt/root/var/log/messages

For example:

less /mnt/root/var/log/syslog

Systemd journal logs may also be available under:

/mnt/root/var/log/journal/

images

Recover Important Files

GRML can be used to recover files from a VPS that cannot boot normally.

Mount the VPS filesystem:

mount /dev/vda2 /mnt/root

User files can generally be found under:

/mnt/root/home/

For example:

ls -lah /mnt/root/home/

You can then copy important files to another attached storage device or transfer them to another system.

Reset the Root Password

If you have lost access to the root account, you can reset the root password from the GRML environment.

Mount the root filesystem and enter the installed operating system using the chroot procedure described above.

Run:

passwd root

Enter the new password when prompted.

Once completed, exit the chroot environment:

exit

Troubleshoot Network Connectivity


GRML includes various networking utilities that can be used to troubleshoot connectivity problems.

Check the available network interfaces:

ip addr

Check the routing table:

ip route

Test connectivity to an external IP:

ping -c 4 1.1.1.1

Test DNS resolution:

ping -c 4 google.com

You can also check listening ports using:

ss -lntup

images

Unmount the VPS Filesystem

Once you have completed the required troubleshooting or recovery operations, exit the chroot environment if you are inside it:

exit

Unmount the VPS filesystem:

umount -R /mnt/root

Verify that there are no remaining mounts:

mount | grep /mnt/root

If there is no output, the filesystem has been successfully unmounted.

Boot the VPS Normally


After completing the recovery process:

  1. Unmount the VPS filesystem.
  2. Unmount/detach the GRML ISO from the VPS.
  3. Set the VPS to boot from its normal disk.
  4. Reboot the VPS.

Run:

reboot

Once the VPS has rebooted, connect to it normally and verify that the operating system and required services are working correctly.

That's how you can use GRML to troubleshoot and recover a CrownCloud VPS.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS