Personal tools
     DOCUMENTATION

FAQ:Application Recovery Using Chroot

From rPath Wiki

Jump to: navigation, search
FAQ
Question: How is it possible to recover if system changes cause a Conary-packaged application to no longer work correctly?


Answer: If changes to your Conary-based system configuration result in an application no longer working properly, often the problem can be resolved by using Conary to reinstall the malfunctioning application. However, when the malfunctioning application is Conary itself, a different approach is required.

This document describes how to use a "donor" system (with a properly-functioning Conary) to create a directory tree that can be used (via the chroot(1) command) to make the necessary repairs on the malfunctioning system.

Image:Bulbgraph.png   The donor system you select must have the same architecture as the malfunctioning system. Although not strictly necessary, the version of Conary on both systems should also match (Conary versions on the 1.0/1.1 branch include backward database compatibility).

On the Donor System:

First, create a directory that will contain the chroot environment:

[user@donor ~]$ mkdir chroot

Next, install the latest version of group-core from conary.rpath.com@rpl:1 into the chroot directory:

[user@donor ~]$ conary update group-core=conary.rpath.com@rpl:1 --root chroot

(This group contains a minimal set of packages needed to boot a system and use Conary.)

If desired, other debugging tools (such as vim or strace) can also be added using additional conary update <trove> --root chroot commands.

The chroot environment is now complete. Create a compressed tarball:

[user@donor ~]$ tar -cjvf chroot.tar.bz2 chroot

Finally, use whatever method is appropriate (for example, scp) to move the chroot.tar.bz2 file onto the malfunctioning system.

On the Malfunctioning System:

Extract the contents of the tarball:

[root@broken ~]# cd /
[root@broken /]# tar -jxvf chroot.tar.bz2

Next, bind mount /proc and /dev into /chroot:

[root@broken /]# mount -o bind /proc /chroot/proc
[root@broken /]# mount -o bind /dev /chroot/dev

Create a mount point for the malfunctioning system's root directory, and bind mount that as well:

[root@broken /]# mkdir /chroot/realroot
[root@broken /]# mount -o bind / /chroot/realroot

To complete configuration of the chroot environment, copy the resolv.conf and conaryrc files into chroot/etc. This is necessary so that the Conary in the chroot environment will have your system's network and Conary configuration:

[root@broken /]# cp /etc/resolv.conf /chroot/etc/resolv.conf
[root@broken /]# cp /etc/conaryrc /chroot/etc/conaryrc

Finally, change root into the chroot environment:

[root@broken /]# chroot /chroot

At this point any conary commands will run the Conary in the chroot environment. Use the --root /realroot/ option to cause Conary to perform its packaging operations in the malfunctioning system's root instead of the chroot environment. For example:

[root@broken /]# conary update conary --root realroot