Difference between revisions of "System resurrection"

From Funtoo Linux
Jump to: navigation, search
(Building binary packages)
Line 1: Line 1:
Here is some ideas on how to resurrect a dead Funtoo system without reinstalling everything from scratch.   
+
Although it is always possible to resurrect a machine back to life by reinstalling it, it is not always suitable to reinstall from scratch and sometimes the best is to try to fix a broken system even with as a last resort option before a full system reinstallation. Here are some ideas on how to resurrect a dead Funtoo system without reinstalling everything from scratch.   
  
 
= Core package removal =
 
= Core package removal =
Line 5: Line 5:
 
Several packages at the heart of your Funtoo system, these mainly are:
 
Several packages at the heart of your Funtoo system, these mainly are:
  
* '''Python:''' As Portage (the software package management system used in Funtoo) is written in Python, the romoval of Python has obvious consequences;
+
{| {{Table}}
* '''GNU Compiler collection:''' GNU/GCC is a compiler collection for various languages like C or C++. Many of your Funtoo packages are written in C and C++ and a dead compiler suite will prevent you to recompile those (GCC contains some bootstrap code that allows it to compile itself).  
+
|-
* '''Binutils:''' GNU Binutils are several tools used behind the scene by the GNU Compiler collection (e.g. assembler, linker, so on) to produce executables. No binutils leaves you with the impossibility to recompile the vast majority of Funtoo packages.
+
!Component
* '''LibC:''' LibC is a kind of software interface between a program launched by the user and the lower services provided by the system kernel. It is used by the huge majority of the binary executables present in a Funtoo box and its mostly common implementation used in the Funtoo Linux world is the GNU Lib C (glibc). '''This component is probably the most critical one because on removal or corruption most of the binary executables (such as the C compiler or the Python interpreter) will simply cease to function. '''
+
!Package
* '''Zlib:''' Zlib is a general compression library used by some Python bindings. In the case zlib is removed or corrupted, Portage will no longer be functional.
+
!Functional role
* '''wget:''' Wget is the tool used by portage to fetch source archives on a remote servers
+
|-
* '''
+
|GNU Binutils
 +
|sys-devel/binutils
 +
|Binutils are a set a tools (linker, assembler...) used behind the scene by the GNU Compiler Collection to produce executable files.
 +
|-
 +
|GNU Compiler collection (GCC)
 +
|sys-devel/gcc
 +
|GCC is a collection of compilers or several languages (FORTRAN, Java, C and C++, plus some libraries like the Standard Template Library or ''STL''). A wide spectrum of software in a Funtoo system is written in C/C++.
 +
|-
 +
|C Library
 +
|sys-libs/glibc
 +
|The C library contains an implementation of a wide range of commonly needed functionalities like memory allocation, strings manipulation, I/O operations and so on. It is maybe of one most critical system components as nearly everything on a Funtoo system depends on this component (including the Python interpreter which executes the vairous Python scripts at the heart of the Funtoo core utilities and package management system).
 +
|-
 +
|Z library
 +
|sys-libs/zlib
 +
|This library contain several lossless compression/decompression routines.It is used by many other components on a Funtoo system like the bzip2/bunzip2 commands (app-arch/bzip2) for example (xz archive utilities depends on another standalone set of libraries).  
 +
|}
 +
  
 
== How to recover from core packages removal? ==
 
== How to recover from core packages removal? ==
 
Although it is always possible to resurrect a machine back to life by reinstalling it, it is not always suitable to reinstall from scratch and sometimes the best is to try to fix a broken system even with some last resort options.
 
  
 
* If your portage is totally knocked out, the only options you are to get binaries archives of pre-compiled core packages and untar them in your live arborescence (e.g. live VFS), notice the '''-C /''' at the end:
 
* If your portage is totally knocked out, the only options you are to get binaries archives of pre-compiled core packages and untar them in your live arborescence (e.g. live VFS), notice the '''-C /''' at the end:

Revision as of 12:04, 23 March 2011

Although it is always possible to resurrect a machine back to life by reinstalling it, it is not always suitable to reinstall from scratch and sometimes the best is to try to fix a broken system even with as a last resort option before a full system reinstallation. Here are some ideas on how to resurrect a dead Funtoo system without reinstalling everything from scratch.

Contents

Core package removal

Several packages at the heart of your Funtoo system, these mainly are:

Component Package Functional role
GNU Binutils sys-devel/binutils Binutils are a set a tools (linker, assembler...) used behind the scene by the GNU Compiler Collection to produce executable files.
GNU Compiler collection (GCC) sys-devel/gcc GCC is a collection of compilers or several languages (FORTRAN, Java, C and C++, plus some libraries like the Standard Template Library or STL). A wide spectrum of software in a Funtoo system is written in C/C++.
C Library sys-libs/glibc The C library contains an implementation of a wide range of commonly needed functionalities like memory allocation, strings manipulation, I/O operations and so on. It is maybe of one most critical system components as nearly everything on a Funtoo system depends on this component (including the Python interpreter which executes the vairous Python scripts at the heart of the Funtoo core utilities and package management system).
Z library sys-libs/zlib This library contain several lossless compression/decompression routines.It is used by many other components on a Funtoo system like the bzip2/bunzip2 commands (app-arch/bzip2) for example (xz archive utilities depends on another standalone set of libraries).


How to recover from core packages removal?

  • If your portage is totally knocked out, the only options you are to get binaries archives of pre-compiled core packages and untar them in your live arborescence (e.g. live VFS), notice the -C / at the end:
# tar -jxvf /tmp/glibc-2.11.2-r2.tbz2 -C /

It is always recommended to use -t instead of -x to make sure no critical configuration file is overwritten in case of doubt.

  • If your portage is still functional, prefer to use it it is a good way to not bring in potential additional problems

Building binary packages

At this point you have tree options:

  • Boot on a SystemRescueCD (which is a Gentoo liveCD).
  • Use a more or less recent system backup (e.g. snapshot if you use a BTRFS or ZFS filesystem or LVM voulume, a copy taken off-line of your hard drive...) and chroot there
  • Log on another functional machine of your network with similar architecture, it is of course possible to use a Gentoo host instead of a Funtoo host but again remember not all of packages are exactly the same.
  • Build a parallel stage3 chroot environment on the same machine with a stage 3 downloaded from a Funtoo mirror. Again, the downloaded stage must match your CPU and architecture and of course the Portage tree you are using (stable or current).

No matter of the way you jump in a functional Funtoo/Gentoo environment, the magic command to create a binary package archive is quickpkg. quickpkg will capture the package in the exact form it is actually deployed on the environment and create an archive of it placed in /usr/portage/packages/<package-category>/<package-name>-<package-version>.tbz2

In the following example capture everything deployed by sys-devel/gcc(4.4.5 is present on the system) and put the captured files in a single archive named gcc-4.4.5.tbz2 located in /usr/portage/packages/sys-devel.

# quickpkg sys-devel/gcc

If you need to recompile a package instead of archiving an already deployed version (and of course without installing it on your "life boat"), just do:

# emerge --buildpkgonly  sys-devel/gcc

Restoring the binary packages on the dead system

Now copy the archives created in the step above in the exact same location on your dead system (e.g. in /usr/portage/packages/sys-devel in the case of sys-devel/gcc) and emerge them with -k:

# emerge -k  sys-devel/gcc

In the case of a non-functional Portage is always possible to directly extrat the tar archive in your filesystem.

I don't have pre-packages binaries what can I do?

In last resort, one the Gentoo developer setup a public server known as tinderbox with various pre-compiled binary packages for various platforms (x86, AMD64 and SPARC64 amongst others) ready for deployment. They act as kind of spare tires, one everything is in place it is recommended to recompile @system:

# emerge -e @system

Various weird issues

P1: I have a local distfiles mirror and wget complains about not being able to resolve 'localhost'.
S1: libnss (which handles name resolution) is probably damaged or suffers of inconsistencies, in your /etc/make.conf, change 'localhost' in GENTOO_MIRRORS for 127.0.0.1 (IPv4) or ::1 (IPv6)

P2: Same problem as described in P1 but I use another machine on my network or a public mirror on the Internet
S2: See the solution given in S1 but with providing the IP of the machine you are downloading for.

Personal tools
Namespaces

Variants
Actions
Categories
Toolbox
Stuff