Author Topic: How to save your Manjaro installation when it breaks  (Read 2445 times)

0 Members and 1 Guest are viewing this topic.

Offline Heart Of A Lion

  • Sr. Mitglied
  • ****
  • Posts: 313
  • I'm new. Be nice!
  • Branch: Stable
  • Desktop: Xfce, Enlightenment
  • GPU Card: ATi 7770 . . . . . . . CPU: AMD octacore 4GHz
  • GPU driver: Free (video-ATI)
  • Kernel: 4.6 (x64)
  • Skill: Intermediate
How to save your Manjaro installation when it breaks
« on: 09. April 2016, 21:49:11 »
Some of you might have had it happen, a Linux installation on your computer that breaks after installing certain software, after installing updates or after editing a configuration file.

Sometimes you mess up so bad, that the entire system doesn't boot past Grub or doesn't even boot Grub itself if you messed around with its configuration files.

So what can you do when you really messed up big time?

What if you didn't make that Clonezilla backup of your system that you should have made in case of emergencies?

Here is a solution that has saved my system on a number of occasions, when it was so broken, that Manjaro or even Grub didn't load and all that you could see was a black screen at bootup.

1. Start the Manjaro live installation media from a usb-stick (or from a CD/DVD for example).

2. Now you need to find out the name of the disk or partition on which your actual Manjaro installation resides. You do this by opening a terminal and typing: lsblk

This now lists all your disks and partitions in the terminal window in a tree structure. Now you can determine on which partition you have Manjaro installed.
The name of the partition on which Manjaro is installed can look like this for example: sda2

3. Now you need to mount the entire tree of your file system of your installed version of Manjaro into the live environment.
This is very powerful stuff when you think about it. You will be able to access the file system of your Manjaro installation in the live environment!

To do this, you need to choose a mount point in the file system of the live environment first. Typically, people use /mnt as the location to do this.
So to accomplish this step, execute the following command in a terminal: sudo mount /dev/sda2 /mnt

Now you've mounted the filesystem of sda2 into the /mnt mount-point. Powerful stuff!

4. So now you have access to the files of your Manjaro installation, even in a graphical file manager like Thunar (at /mnt). However that's not always enough to save your Manjaro installation. Sure you can edit configuration files now or even delete files that caused issues, but what you really want is full control. You want to be able to execute commands as if your were inside your actual Manjaro installation.

This means that you need to change root to the new mount-point that you just created. And typically this is done with the 'chroot' command, however the chroot command often doesn't allow you to run the commands that are needed to repair a broken Linux installation.

What you need, is a more powerful version of chroot. It's called mhwd-chroot.

You need to download it from the AUR and install it using Manjaro's standard package manager.

5. Once installed, you can now change root to the new mount point. You do that by typing the following command in a terminal: sudo mhwd-chroot /mnt

6. Now a new terminal window will open. In this terminal window you can execute commands as if you were inside your actual Manjaro installation.

You can now uninstall software that caused your system to break or you can roll back updates or you can uninstall drivers like video-drivers that made your screen go black.

It's powerful stuff, because you now have both access to your files and to a terminal which can control your Manjaro installation. The possibilities to repair things, fix issues and backup files are now endless. This and much more. All due to these few simple commands.

In short, here are the steps and commands in a nutshell:

1. Boot into the Manjaro live installation media
2. Open a terminal and type: lsblk
3. Mount your disk into the live environment: sudo mount /dev/sda2 /mnt
4. Download and install mhwd-chroot
5. Change root into the new mount-point: sudo mhwd-chroot /mnt
6. Save your Manjaro installation using the chrooted terminal

One more thing I can add to this is that people who use PCIe storage devices, they need to download and install mhwd-chroot-extended, so that they can mount file systems from NVMe storage devices.
« Last Edit: 10. April 2016, 18:01:29 by Heart Of A Lion »

Offline artoo

  • OpenRC Team
  • ****
  • Posts: 2373
  • Branch: Unstable
  • Desktop: LXQT/Plasma5, openrc & eudev
  • Kernel: x86_64
  • Skill: Advanced
Re: How to save your Manjaro installation when it breaks
« Reply #1 on: 09. April 2016, 21:51:45 »
Boot livecd, run

Code: [Select]
manjaro-chroot -a
done.  8)

Or use systemd-nspawn if you run systemd.

Offline Heart Of A Lion

  • Sr. Mitglied
  • ****
  • Posts: 313
  • I'm new. Be nice!
  • Branch: Stable
  • Desktop: Xfce, Enlightenment
  • GPU Card: ATi 7770 . . . . . . . CPU: AMD octacore 4GHz
  • GPU driver: Free (video-ATI)
  • Kernel: 4.6 (x64)
  • Skill: Intermediate
Re: How to save your Manjaro installation when it breaks
« Reply #2 on: 09. April 2016, 21:56:47 »
Boot livecd, run

Code: [Select]
manjaro-chroot -a
done.  8)

Or use systemd-nspawn if you run systemd.

That seems interesting.

Can you explain what this does exactly and which options it gives to repair a broken Manjaro installation?

Offline artoo

  • OpenRC Team
  • ****
  • Posts: 2373
  • Branch: Unstable
  • Desktop: LXQT/Plasma5, openrc & eudev
  • Kernel: x86_64
  • Skill: Advanced
Re: How to save your Manjaro installation when it breaks
« Reply #3 on: 09. April 2016, 21:59:55 »
That seems interesting.

Can you explain what this does exactly and which options it gives to repair a broken Manjaro installation?

Its simply a chroot utility that detects OSes and automounts one.
If multiple have been detected, you can chose one.
It also has manual mode like mhwd-chroot.

Code: [Select]
manjaro-chroot -h
for help.

Offline Heart Of A Lion

  • Sr. Mitglied
  • ****
  • Posts: 313
  • I'm new. Be nice!
  • Branch: Stable
  • Desktop: Xfce, Enlightenment
  • GPU Card: ATi 7770 . . . . . . . CPU: AMD octacore 4GHz
  • GPU driver: Free (video-ATI)
  • Kernel: 4.6 (x64)
  • Skill: Intermediate
Re: How to save your Manjaro installation when it breaks
« Reply #4 on: 09. April 2016, 22:22:34 »
Its simply a chroot utility that detects OSes and automounts one.
If multiple have been detected, you can chose one.
It also has manual mode like mhwd-chroot.

Code: [Select]
manjaro-chroot -h
for help.

Sounds very useful. I just tried running the command in my Manjaro installation, but it returns an error: bash: manjaro-chroot: command not found

Or is it only available in the Live version of Manjaro?

Offline artoo

  • OpenRC Team
  • ****
  • Posts: 2373
  • Branch: Unstable
  • Desktop: LXQT/Plasma5, openrc & eudev
  • Kernel: x86_64
  • Skill: Advanced
Re: How to save your Manjaro installation when it breaks
« Reply #5 on: 09. April 2016, 22:30:24 »
Sounds very useful. I just tried running the command in my Manjaro installation, but it returns an error: bash: manjaro-chroot: command not found

Or is it only available in the Live version of Manjaro?

No, its part of manjarp-tools.

Code: [Select]
sudo pacman -S majaro-tools-base

Offline Heart Of A Lion

  • Sr. Mitglied
  • ****
  • Posts: 313
  • I'm new. Be nice!
  • Branch: Stable
  • Desktop: Xfce, Enlightenment
  • GPU Card: ATi 7770 . . . . . . . CPU: AMD octacore 4GHz
  • GPU driver: Free (video-ATI)
  • Kernel: 4.6 (x64)
  • Skill: Intermediate
Re: How to save your Manjaro installation when it breaks
« Reply #6 on: 09. April 2016, 22:32:26 »
Or use systemd-nspawn if you run systemd.

I found a Youtube video that talks about the chroot-like features of systemd-nspawn. This could be useful for some people for whom mhwd-chroot or manjaro-chroot didn't work when trying to fix their system:

https://youtu.be/s7LlUs5D9p4
« Last Edit: 09. April 2016, 22:33:59 by Heart Of A Lion »

Offline Heart Of A Lion

  • Sr. Mitglied
  • ****
  • Posts: 313
  • I'm new. Be nice!
  • Branch: Stable
  • Desktop: Xfce, Enlightenment
  • GPU Card: ATi 7770 . . . . . . . CPU: AMD octacore 4GHz
  • GPU driver: Free (video-ATI)
  • Kernel: 4.6 (x64)
  • Skill: Intermediate
Re: How to save your Manjaro installation when it breaks
« Reply #7 on: 09. April 2016, 23:42:38 »
Another tip that I can give is that if you want to edit files from your Manjaro-installation's file system that you mounted to /mnt, then you can do that by opening a terminal and typing:

Code: [Select]
sudo thunar /mnt
This opens a superuser version of Thunar at the /mnt location in your file system, which allows you to browse your file system and to right-click on files to edit them using a text-editor like gEdit for example.

If you have to use a terminal text editor for some reason, then I suggest Nano, because it's a relatively easy terminal text editor.

You can open a file in Nano and edit it by typing the following command in a terminal:

Code: [Select]
sudo nano /home/user/SomeTextFile.txt
Here are some essential shortcuts for Nano:

Arrow keys : They move the cursor around the text file
ENTER : Goes to a new line
BACKSPACE : Backspace
DELETE : Delete
CTRL+^ : Starts selecting text (use the arrow keys to select)(press CTRL+^ again to end selecting text)
ALT+^ : Copy the selected text
CTRL+u : Paste the copied text
CTRL+k : Cut the copied text
CTRL+o : Save a file. (You can specify a path. If you don't, then it saves the file to the user directory)
CTRL+x : Asks to save the file and exits Naro. (goes back to the command line prompt in your terminal)

« Last Edit: 10. April 2016, 00:04:48 by Heart Of A Lion »