Introduction / Why This Is Needed
Linux system recovery is the process of returning an operating system to a working state after a crash, file corruption, or bootloader errors. This guide is useful if your system won't boot, you've forgotten your password, or lost data. After completing it, you will be able to:
- Restore the system from a backup.
- Fix the GRUB bootloader.
- Regain access to files via a LiveCD.
- Reset the root password.
The instructions are suitable for Ubuntu, Debian, Fedora, CentOS, and other systemd-based distributions.
Requirements / Preparation
Before starting, ensure you have:
- A bootable medium (Live USB/DVD) with any Linux distribution (Ubuntu 22.04 or similar is recommended). If the system won't boot, create it on another computer.
- Terminal access — basic knowledge of Linux commands.
- A system backup (recommended) — created via
tar,timeshift, or other tools. If no backup exists, file recovery will be limited. - Administrator privileges (sudo) in the Live session.
- A list of partitions (if you remember the disk structure) — this will simplify the process.
💡 Tip: If the system partially boots, create a backup of important data before recovery to avoid information loss.
Step-by-Step Instructions
Step 1: Prepare the Bootable Medium
If the system won't boot, use another computer to create a Live USB.
- Download a Linux image (e.g., Ubuntu 22.04 LTS).
- Write the image to a USB drive (minimum 4 GB). On Linux/macOS:
Replacesudo dd if=ubuntu-22.04.iso of=/dev/sdX bs=4M status=progress && syncsdXwith your USB device (e.g.,sdb). On Windows, use Rufus. - Eject the medium and proceed to the next step.
Step 2: Boot from LiveCD and Identify Partitions
- Insert the USB into the affected computer, boot from it (boot key: F12, ESC, Del — depends on manufacturer). Select "Try Ubuntu" (or a similar option).
- Open the terminal (Ctrl+Alt+T).
- Identify disk partitions:
Example output:sudo lsblk -f
Find the root partition (usuallyNAME FSTYPE LABEL UUID MOUNTPOINT sda ├─sda1 ext4 root 1234abcd-5678-ef90-1234-567890abcdef ├─sda2 swap swap abcd1234-5678-ef90-1234-567890abcdef [SWAP] └─sda3 vfat boot ABCD-1234 /boot/efiext4, mountpoint not listed) and, if present, the/bootpartition (typevfatorext2). Note the names (e.g.,sda1,sda3).
Step 3: Mount Partitions
- Create a mount point:
sudo mkdir -p /mnt/root - Mount the root partition (replace
sda1with yours):sudo mount /dev/sda1 /mnt/root - If there is a separate
/boot, mount it:sudo mount /dev/sda3 /mnt/root/boot - For partitions requiring filesystems (e.g.,
/var,/home), mount them similarly under/mnt/root/var, etc. - Verify mounts:
mount | grep /mnt/root
Mounted partitions should be displayed.
Step 4: Restore Files from Backup
If you have a backup, restore your data:
tarbackup (e.g.,backup.tar.gzon an external drive):sudo tar -xzf /path/to/backup.tar.gz -C /mnt/roottimeshiftbackup (if saved in/timeshift):
Or manually copy from thesudo timeshift --restore --snapshot-days 1 --target /mnt/root/timeshiftfolder to/mnt/root.- Manual copy: if the backup is on another partition, mount it and copy files.
⚠️ Important: Ensure the backup matches your system's architecture and version. Restoring a backup from a different version may cause errors.
Step 5: Reinstall the GRUB Bootloader
If the system fails to boot due to a corrupted GRUB:
- Prepare the chroot environment:
sudo mount --bind /dev /mnt/root/dev sudo mount --bind /proc /mnt/root/proc sudo mount --bind /sys /mnt/root/sys - Enter chroot:
sudo chroot /mnt/root - Reinstall GRUB (replace
/dev/sdawith your disk, not a partition):
For UEFI systems, also ensure thegrub-install /dev/sda update-grubgrub-efipackage is installed. - Exit chroot:
exit
Step 6: Final Check and Reboot
- Unmount all partitions:
sudo umount -R /mnt/root - Remove the USB drive.
- Reboot:
sudo reboot - After booting, check:
- If services are running:
systemctl status. - If your files are accessible.
- If the system boots without errors (review
dmesgor logs in/var/log).
- If services are running:
Verify the Result
- Successful boot: the login screen appears.
- File check: ensure home directories and system files are intact.
- GRUB: the GRUB menu with a list of kernels appears during boot.
- Network settings: if a backup was used, check
ip aand/etc/resolv.conf.
If the system boots but has errors (e.g., network not working), check configuration in /etc/network/interfaces or netplan.
Possible Issues
| Problem | Solution |
|---|---|
Mount error: mount: /mnt/root: wrong fs type, bad option, bad superblock | Check the filesystem: sudo fsck /dev/sda1 in the Live session. Ensure the partition is not corrupted. |
GRUB fails to install: error: cannot find a device for /boot | Ensure you mounted the /boot partition (if separate). For UEFI, verify the EFI system partition (/dev/sda1 of type vfat) is mounted. |
System fails to boot after recovery, hangs at initramfs | The filesystem may be corrupted. Boot with LiveCD, run fsck on the root partition. Check fstab for correct UUIDs. |
| No network access in Live session | Enable networking: sudo dhclient or configure via nmcli. For network backups (e.g., NFS), install the client: sudo apt install nfs-common. |
| Backup restored but application doesn't work | Check dependencies: ldd /path/to/binary. Libraries may not have been included in the backup. Reinstall packages via apt --reinstall install <package>. |
If the issue persists, consult specific guides on FixPedia (e.g., for recovering a particular distribution or tool).