Installation Recovery

Recover a Kubuntu Focus System

All general purpose OSes (Windows, MacOS, Linux) can be changed so that the system will no longer boot completely or will behave strangely. A corrupt or full system disk, broken software packages, misconfiguration, and many other situations can cause this. Read on to find how you can use FocusRx and other tools to recover a system.

Recover your system with multiple techniques.

Recover your system with multiple techniques.

Please read the disclaimer before proceeding. We review and update guided solutions regularly. If you have suggestions or requests, please write support@kfocus.org.

Limitations

Before you proceed, first determine if this is actually a system issue. If your system boots fine, this is likely an application issue. We recommend you first visit the Focus Support page and search for a topic using the list or the search box. These are almost always more current and correct for your hardware than HOWTOs or forum posts you might find on the web. You should continue here only if your system does not completely boot or if you are getting warnings about missing dependencies or libraries.

Recovering an installation may be preferable because applications, settings, and other data will not need to be restored. However, like with all OSes, a badly broken system can take hours to recover and still be problematic. While a Clean Install requires recovery of data, it usually takes well under 30 minutes and can solve issues you do not have time to research or understand. For these reasons, we recommend you always keep a clean installation as an alternative and limit the time you dedicate to recovery efforts.

Any system work always has inherent risks. Mistakes happen, and in this context, that can mean data loss. It is important, therefore, to keep your data safe using a backup solution on an external disk. See the Backup Guided Solution to save your data before proceeding if possible.

System Rollback

System Rollback is available on 24.04 LTS (Noble) systems with BTRFS. It may be used to restore system files from a previously saved snapshot. This is particularly useful for recovering from failed software installation or updates. See the Rollback Tool to learn how to create snapshots.

Open System Rollback

System Rollback may be launched in one of two ways - either through Start Menu > Kubuntu Focus Tools > System Rollback, or by clicking the System Rollback icon in the system tray. If neither of these items exist, the system does not support System Rollback.

Open System Rollback.
Restore a Snapshot

1. Open the drop-down menu of the System Rollback window, and select RESTORE Snapshot. Then click [OK].

Choose 'Restore Snapshot' from the drop-down menu.

2. Select the snapshot you wish to restore and click [OK].

Choose the snapshot you wish to restore.

3. Ensure all open work on the system has been saved, then click [OK] to restore the snapshot. You will be prompted for your password. Once you have authenticated, the system will reboot.

Save open work, then confirm snapshot restoration.

4. You will be shown confirmation that the rollback was successful once you are logged in again. Click [OK] to dismiss the notice, or click [More Info] for guidance on how to compare the system's restored state to its previous state.

Close confirmation window.

Rollback Packages

Sometimes the latest version of package has a bug or missing feature that you find unacceptable. When this happens, one may specify a package version, or install a debian package from the archive.

Specify a package version

We can use apt-cache policy to find an older version of a package:

# Find available versions apt-cache policy filezilla #> filezilla: #> Installed: 3.58.0-1ubuntu0.1 #> Candidate: 3.58.0-1ubuntu0.1 #> Version table: #> *** 3.58.0-1ubuntu0.1 500 #> 500 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages #> 500 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages #> 100 /var/lib/dpkg/status #> 3.58.0-1 500 #> 500 http://us.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages

We can use this knowledge to install and hold the earlier version. Notice how we included filezilla-common too, as we discovered this dependency also needed a rollback:

# Install older versions sudo apt install filezilla=3.58.0-1 filezilla-common=3.58.0-1 # Mark hold to prevent an upgrade sudo apt-mark hold filezilla filezilla-common # Show held files sudo apt-mark showhold # Remove holds sudo apt-mark unhold filezilla filezilla-common # Upgrade to latest sudo apt full-upgrade
Install a debian package from the archive

Not all older versions of packages are retained in the repository. For example, google-chrome-stable does not always show as having an earlier available version. However, you can find and downgrade to an earlier version using the local archives.

# Find cached packages ls /var/cache/apt/archives \ |grep -E '^google-chrome-stable*' |sort -V #> google-chrome-stable_120.0.6099.216-1_amd64.deb #> google-chrome-stable_121.0.6167.184-1_amd64.deb #> google-chrome-stable_122.0.6261.111-1_amd64.deb # Install desired version cd /var/cache/apt/archives sudo apt install ./google-chrome-stable_121.0.6167.184-1_amd64.deb # Mark hold to prevent upgrade sudo apt-mark hold google-chrome-stable # Show held files sudo apt-mark showhold # Remove holds sudo apt-mark unhold google-chrome-stable # Upgrade to latest sudo apt full-upgrade

Make sure to regularly check and remove holds. Out-of-date packages can cause incompatibilities and even prevent other packages from installing correctly, so do this with care.

Rollback Repositories

Sometimes you just want get rid of all packages and dependencies that come from a repository. ppa-purge is excellent for this purpose:

# Add a repository to /etc/apt/sources-list.d sudo add-apt-repository ppa:jonathonf/ffmpeg-4 # Disable repo but keep packages from it sudo add-apt-repository --remove ppa:jonathon/ffmpeg-4 # Re-enable it sudo add-apt-repository ppa:jonathonf/ffmpeg-4 # Purge all package from this repo sudo ppa-purge ppa:jonathonf/ffmpeg-4

ppa-purge downgrades packages to their version before the repository was added, if possible. Although it was design for PPA repositories, it can also be used for most commercial 3rd-party repositories. See ppa-purge -h for the switches used in the examples below:

# Inspect and remove Slack repo. This removes the slack app too! cat /etc/apt/sources.list.d/slack.list #> deb https://packagecloud.io/slacktechnologies/slack/debian/ jessie main # ppa-purge, preferring apt-get over aptitude sudo ppa-purge -i -s packagecloud.io -o slacktechnologies -p slack -d jessie
# Inspect and remove MongoDB repo cat /etc/apt/sources.list.d/mongodb-org-7.0.list #> deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse # ppa-purge, preferring apt-get over aptitude sudo ppa-purge -i -s repo.mongodb.org -o apt -p ubuntu -d jammy

You can learn more with this Linuxize article.

Recover from BusyBox Shell

Sometimes the system will boot but drop to a BusyBox Shell as shown below.

BusyBox v1.30.1 (1:1.30.1-4ubuntu6.3) built-in shell (ash) Enter 'help' for a list of built-in commands. (initramfs) _

This frequently results from a corrupt filesystem, as detailed by this Ask Ubuntu ticket. The solution is to enter the command exit into the shell to report the corrupt filesystem. You may then repair it using fsck <device-file> as shown below.

BusyBox v1.30.1 (1:1.30.1-4ubuntu6.3) built-in shell (ash) Enter 'help' for a list of built-in commands. (initramfs) exit The root filesystem on /dev/mapper/vgkubuntu-root requires a manual fsck BusyBox v1.30.1 (1:1.30.1-4ubuntu6.3) built-in shell (ash) Enter 'help' for a list of built-in commands. (initramfs) fsck /dev/mapper/vgkubuntu-root -y fsck from util-linux 2.34 e2fsck 1.45.5 (07-Jan-2020) /dev/mapper/vgkubuntu-root contains a filesystem with errors, check forced.

After the filesystem repair is complete, type in reboot or exit to reboot the system. If the repair was good (which it usually is), the system should now boot normally.

Fix Your System Using FocusRx

Focus systems have a recovery tool called FocusRx which can identify and resolve many issues:

You can run FocusRx as shown below.

Reset a User Password

If you forget your user password, you can reset it using Recovery Mode if the following conditions are met:

1. If the system is already powered on, shut it down.

2a. Boot the system. If the root filesystem is BTRFS, which is the default in 24.04, you should see a GRUB menu appear shortly after pressing the power button.

2b. If the root filesystem is NOT BTRFS, you will need to make it appear: immediately after the boot logo (like the Kubuntu Focus logo) appears, press right-shift (all models except XE) or escape (XE models). If the boot proceeds to a disk decryption or user login screen, it has gone too far and you will need to reboot to try again. If you press and hold the power button to shut down during boot, this will likely cause the GRUB menu to appear on the next boot. Once you see the GRUB menu, proceed to the next step.

To reset a user password, select Advanced Options for Kubuntu at the GRUB menu.

3. When the GRUB menu appears, promptly press the down arrow key to highlight "Advanced Options for Kubuntu" and press Enter.

4. In the next screen, press the down arrow key to highlight the first "(recovery mode)" option shown, then press Enter.

Choose the first recovery mode option on the list.

5. If your disk is encrypted, type your passphrase when prompted and press Enter. You cannot access the system if you do not have the disk passphrase.

Unlock your disk when prompted.

6. You will see a grey box on a colored background with a list of options. Press the down arrow key to highlight the "root" option and press Enter. Directly below the grey box, you will be prompted to "Press Enter for maintenance". Press Enter.

Select 'root' from the list of options, then press Enter twice to gain access to the system.

7. You should now be able to type below the grey box as root. Type sudo mount -o remount,rw / and then press Enter to enable the ability to change the system.

8. Next, type ls /home and press Enter to list the users in the /home directory. Find your username and remember it; it will be required below.

9. Next, type passwd username, replacing username with your username from above, and press Enter. You will be prompted to enter your new password twice. Enter the same password each time.

10. Type reboot and press Enter to perform a normal reboot. After this, you should be able to use your new password to log in.

Enable the ability to change the system, determine your username, then use 'passwd' to reset your password. Reboot when done.

Again, this procedure only works if the root password is NOT set. In the event you DO have the root password set, things get messier. This method can provide some guidance.

Use a Live USB for Recovery

Use a Live USB for Recovery

Please Download the ISO Disk Image and create a bootable, live USB. Then return here to proceed.

Boot using the USB stick as shown below.

24.04 LTS (Noble): Use chroot to Recover a System

1. Use the live USB procedure (above) to boot into the Try Kubuntu mode. Then open a Konsole terminal and enter the lines as shown below.

2a. ENCRYPTED DRIVE ONLY: Decrypt the drive and mount the root filesystem.

sudo -i # Find drive ID and decrypt mount /dev/nvme0n1p2 /mnt [ -d '/mnt/@boot' ] && GRUB_CFG='/mnt/@boot/grub/grub.cfg' \ || GRUB_CFG='/mnt/grub/grub.cfg' DRIVE_ID="$( sed -n '/luks/s/.*\(luks-\([a-z0-9]*-*\)*\).*/\1/p;/luks/q' \ "$GRUB_CFG" )" umount /mnt cryptsetup luksOpen /dev/nvme0n1p3 "$DRIVE_ID" # Mount decrypted drive mount "/dev/mapper/$DRIVE_ID" -o subvol=@ /mnt 2>/dev/null \ || mount "/dev/mapper/$DRIVE_ID" /mnt mount "/dev/mapper/$DRIVE_ID" -o subvol=@home /mnt/home 2>/dev/null # Proceed if you see 'etc' and 'home': cd /mnt ls

2b. UNENCRYPTED DRIVE ONLY: Mount the root filesystem.

sudo -i # Mount drive mount /dev/nvme0n1p3 -o subvol=@ /mnt 2>/dev/null \ || mount /dev/nvme0n1p3 /mnt # Proceed if you see 'etc' and 'home': cd /mnt ls

3. Back up your data.

If you haven’t yet backed up your data, please do so NOW! See Backup for Clean Install to save your important files to a separate drive. You can find your user data under /mnt/home/. While each subsequent step below is usually safe, each brings additional risk because of an unknown system state or human error. Better safe than sorry.

4. Mount the boot and boot/efi filesystems.

# Mount boot and boot/efi cd /mnt mount /dev/nvme0n1p2 -o subvol=@boot boot 2>/dev/null \ || mount /dev/nvme0n1p2 boot mount /dev/nvme0n1p1 boot/efi # Proceed if you see 'vmlinuz' and 'initrd.img': ls boot # Proceed if you see 'EFI': ls boot/efi

5. Set up BTRFS mounts

# Look for BTRFS mount directories ls /mnt # If 'btrfs_main' and 'btrfs_boot' are not present, skip to step 6, # otherwise continue mount /dev/nvme0n1p2 -o subvolid=5 /mnt/btrfs_boot # FOR ENCRYPTED SYSTEMS: GRUB_CFG='/mnt/boot/grub/grub.cfg' DRIVE_ID="$( sed -n '/luks/s/.*\(luks-\([a-z0-9]*-*\)*\).*/\1/p;/luks/q' \ "$GRUB_CFG" )" mount "/dev/mapper/$DRIVE_ID" -o subvolid=5 /mnt/btrfs_main # FOR UNENCRYPTED SYSTEMS: mount /dev/nvme0n1p3 -o subvolid=5 /mnt/btrfs_main

6. Prepare and use chroot.

cd /mnt mount -t proc /proc proc mount --rbind /sys sys mount --rbind /dev dev rm etc/resolv.conf cp /etc/resolv.conf etc/resolv.conf chroot .

7. Once the system has successfully switched to chroot mode, you may run FocusRx (above) to fix packages and other common issues.

focusrx -f # One may also repair /etc/default/grub # and run update-grub

8. Here are a few more steps you might try if FocusRx does not solve the problem:

Aptitude package management

See this article for additional details on using chroot.

9. When you are finished fixing the chroot environment, enter exit into terminal. Close the terminal and restart. If the repairs worked, the system should start as normal.

22.04 LTS (Jammy): Use chroot to Recover a System

1. Use the live USB procedure (above) to boot into the Try Kubuntu mode. Then open a Konsole terminal and enter the lines as shown below.

2a. ENCRYPTED DRIVE ONLY: Decrypt the drive and mount the root filesystem.

sudo -i # Decrypt drive cryptsetup luksOpen /dev/nvme0n1p3 nvme0n1p3_crypt # Mount decrypted drive mount /dev/mapper/vgkubuntu-root /mnt # Proceed if you see 'etc' and 'home': cd /mnt ls

2b. UNENCRYPTED DRIVE ONLY: Mount the root filesystem.

sudo -i # Mount drive mount /dev/nvme0n1p2 /mnt # Proceed if you see 'etc' and 'home': cd /mnt ls

3. Back up your data.

If you haven’t yet backed up your data, please do so NOW! See Backup for Clean Install to save your important files to a separate drive. You can find your user data under /mnt/home/. While each subsequent step below is usually safe, each brings additional risk because of an unknown system state or human error. Better safe than sorry.

4a. ENCRYPTED DRIVE ONLY: Mount the boot and boot/efi filesystems.

# Mount boot and boot/efi cd /mnt mount /dev/nvme0n1p2 boot mount /dev/nvme0n1p1 boot/efi # Proceed if you see 'vmlinuz' and 'initrd.img': ls boot # Proceed if you see 'EFI': ls boot/efi

4b. UNENCRYPTED DRIVE ONLY: Mount the boot/efi filesystem.

# Mount boot/efi cd /mnt mount /dev/nvme0n1p1 boot/efi # Proceed if you see 'EFI': ls boot/efi

5. Prepare and use chroot.

cd /mnt mount -t proc /proc proc mount --rbind /sys sys mount --rbind /dev dev rm etc/resolv.conf cp /etc/resolv.conf etc/resolv.conf chroot .

6. Once the system has successfully switched to chroot mode, you may run FocusRx (above) to fix packages and other common issues.

focusrx -f # One may also repair /etc/default/grub # and run update-grub

7. Here are a few more steps you might try if FocusRx does not solve the problem:

Aptitude package management

See this article for additional details on using chroot.

8. When you are finished fixing the chroot environment, enter exit into terminal. Close the terminal and restart. If the repairs worked, the system should start as normal.

Troubleshooting

Content will be added as needed.

Revisions

This is a partial revision history. See the git repository for all entries.

Disclaimer

We try hard to provide a useful solution validated by professionals. However, we cannot anticipate every situation, and therefore cannot guarantee this procedure will work for your needs. Always backup your data and test the solution to determine the correct procedure for you.

THIS SOLUTION IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOLUTION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

HAVE QUESTIONS?Call 844-536-2871 or write
TellMeMore@kfocus.org   |  GET FOCUS MERCH