How to use mount and chroot to fix a broken OM system

From Wiki [en] OpenMandriva
Jump to: navigation, search

Briefly to mount and chroot in to an OM system from 'Live' ISO (perhaps best) or another Linux system:

You have to know where your root partition is, that is the root partition of the system you wish to repair. Using /dev/sdxx as an example. Substitute your partition location for /dev/sdxx. You also need to know the file system type. Usually that's ext4 on OpenMandriva systems but could be something else. Running df -Th as regular user will list partitions with their file system type. Running as root user fdisk -l will list all available partitions.

Also for urpmi to work the host system needs to use urpmi that's one reason why it may be best to use OM 'Live' media. The closer the 2 systems are the more you can do. This is critical for package management. You won't be able to chroot from a Debian or Ubuntu system in to an OM system and be able to use urpmi or rpm commands. In other words you can only use commands supported by the host system. Ideally if you use OM Lx 3 'Live' media to chroot into an OM Lx 3 system you should be able to do most (but not all) common tasks.

OK we are either in a 'Live' media or in a Linux host system. Open Konsole or other terminal and become root.

1. First we are going to mount the system we wish to repair to the /mnt directory in the host system.

# mount -t ext4 /dev/sdxx /mnt

Substitute your file system type for ext4 if different. Substitute you partition location for /dev/sdxx.

2. Now we're going to mount some directories from the host system to the system to be repaired so we can run commands and do common tasks. Run these one at a time:

# mount -o bind /sys /mnt/sys

# mount -o bind /run /mnt/run

# mount -o bind /dev /mnt/dev

# mount -o bind /proc /mnt/proc

3. And if we are working on a UEFI system with a boot problem:

# mount -o bind /boot/efi/ /mnt/boot/efi/

4. Now we chroot in to the system to be repaired to do work:

# chroot /mnt

You will see the location in Konsole change slightly reflecting that we have changed directories and you are now in the system to be repaired.

You'll see once you do this a few times that this takes more time to read than it does to do it. Well just imagine how long it took to write it compared to doing it!

With great power come great responsibility, which is a way of saying to be careful and know what you are doing or you can really muck up your system. In fact now you can break it beyond all repair if you are not careful. (That's called FUBARing your system.) Don't FUBAR your system.