Difference between pages "System resurrection" and "User:Abillygoatknows"

From Funtoo
(Difference between pages)
Jump to: navigation, search
(Fixing broken portage)
 
(Installation of Funtoo onto Toshiba NB505 netbook (1.6 Ghz AtomN455 2GB ram 60GB 2.5" sandisk extreme SsD))
 
Line 1: Line 1:
Although it is always possible to resurrect a machine back to life by reinstalling it, it is not always suitable to reinstall from scratch. Sometimes the best approach is to try to repair, or "resurrect," a broken system so that is it fully functional again. This document will show you how to resurrect a broken Funtoo system without reinstalling everything from scratch. 
+
Toshiba NB505 installation.
+
== Building binary packages ==
+
  
The best approach for critical system repair is to boot on a SystemRescueCD or other similar LiveCD, and use this as working platform to resurrect your system.
 
  
For creating binary packages, you can use any of the following for a ''source environment'':
+
I am installing from Crunchbang waldorf (based on Debian Wheezy).
  
* Use the most recent Funtoo stage3 for your architecture
+
First, I create a logical volume called "funtoo" that is 10 Gigabytes large in the volume group "toshiba".
* If available, use a recent system backup (tar or cpio archive) or snapshot
+
  
On a working Linux system, which can be either your broken system booted with a LiveCD, or any type of Linux system on your network with similar processor, you will want to build a chroot environment using the "source environment" you selected above, and use this as a platform for building binary packages to restore your system. Once these packages are created, they can be copied to your broken system and installed using the steps later in this document.
+
"sudo lvcreate -nfuntoo -L10G toshiba"
  
The binary package creation environment would typically be set up as follows:
+
Now, this logical volume can be access via its handle "/dev/mapper/toshiba-funtoo".
  
<console>
+
So what's next... I format it with the ext4 file-system.
# ##i##install -d /mnt/rescue
+
# ##i##tar xpvf backup.tar.bz2 -C /mnt/rescue
+
# ##i##cp /etc/resolv.conf /mnt/rescue/etc
+
# ##i##mount --bind /proc /mnt/rescue/proc
+
# ##i##mount --bind /sys /mnt/rescue/sys
+
# ##i##mount --bind /dev /mnt/rescue/dev
+
# ##i##mount --bind /dev/pts /mnt/rescue/dev/pts
+
# ##i##chroot /mnt/rescue
+
# ##i##source /etc/profile
+
# ##i##env-update
+
</console>
+
  
No matter of the way you jump in a functional Funtoo/Gentoo environment, the magic command to create a binary package archive once inside is to use the <tt>quickpkg</tt> command. <tt>quickpkg</tt> will capture the package in the exact form it is actually deployed on the environment and create an archive of it placed in <tt>/usr/portage/packages/<package-category>/<package-name>-<package-version>.tbz2</tt>.
+
"sudo mkfs.ext4 /dev/mapper/toshiba-funtoo"
  
In the following example capture everything installed within the "source environment" that is related <tt>sys-devel/gcc</tt> (4.4.5 is present on the system) is captured in a single archive named gcc-4.4.5.tbz2 located in <tt>/usr/portage/packages/sys-devel</tt>:
+
Then I create a mount-point. In this case, I will mount my funtoo logical volume on /mnt/funtoo.
  
<console>
+
"sudo mkdir /mnt/funtoo"
# ##i##quickpkg sys-devel/gcc
+
</console>
+
  
If you need to recompile a package instead of archiving an already deployed version (and of course without installing it on your "source environment"), just do:
+
Next, I will set permissions on this logical volume (so that my $username can read/write to the volume).
  
<console>
+
In my case, let $myusername be 'daisuke'.
# ##i##emerge --buildpkgonly sys-devel/gcc
+
"sudo chown daisuke:daisuke /mnt/funtoo"
</console>
+
  
== Restoring the binary packages on the broken system ==
+
Then, i download a stage 3 tarball of funtoo from one of their mirrors to a folder called "backup" in my crunchang installation's home directory "~/".
 +
"wget $urltostage3tarball ~/backup"
 +
In my case, $urltostage3tarball is "http://ftp.osuosl.org/pub/funtoo/funtoo-current/x86-64bit/atom_64/stage3-latest.tar.xz"
  
There are a couple of methods that can be used to restore binary packages to a broken system.
+
Then, I untar this file into /mnt/funtoo. First I put myself into the target directory (/mnt/funtoo), then I untar the stage3 file.
 +
"cd /mnt/funtoo && sudo tar xvJpf ~/backup/$stage3tarballfilename"
 +
In my case, $stage3tarballfilename = "stage3-latest.tar.xz"
  
=== Chroot/Emerge Method ===
+
After that... Uhh.. we gotta chroot into this new installation..first, I gotta mount some stuff.
 +
"sudo mount -l proc /proc /mnt/funtoo/proc && sudo mount --rbind /dev /mnt/funtoo/dev && sudo mount --rbind /sys /mnt/funtoo/sys"
 +
Then.. copy my wifi dns-resolve info
 +
"sudo cp -L /etc/resolv.conf /mnt/funtoo/etc/resolv.conf"
 +
Then..chroot
 +
"sudo chroot /mnt/funtoo /bin/bash"
 +
BAM!
  
This first approach can be used for lightly damaged systems that still have a functional Portage and to which you can still <tt>chroot</tt> and perform all basic Linux commands. To use this method, you would mount your broken system to <tt>/mnt/broken</tt> using steps similar to the way we set up <tt>/mnt/rescue</tt>, above.  
+
And, until next time.. I'm doneGotta get out of this cafe.
 
+
Before or after chrooting, copy the binary packages created in the step above in the exact same location on your broken system (e.g. in <tt>/usr/portage/packages/'''sys-devel'''</tt> in the case of <tt>'''sys-devel'''/gcc</tt>).
+
 
+
Once chrooted inside your system, you will be able to merge your packages using <tt>emerge</tt> as follows:
+
 
+
<console>
+
# ##i##emerge -k sys-devel/gcc
+
</console>
+
 
+
=== Tbz2 Extract Method ===
+
 
+
This alternate method for installing binary packages is simpler and does not require the use of the <tt>chroot</tt> command. To prepare for using this approach, you just need to mount all key filesystems to <tt>/mnt/broken</tt> as follows -- and bind mounts are not necessary:
+
 
+
<console>
+
# ##i##install -d /mnt/broken
+
# ##i##mount /dev/sdaX /mnt/broken
+
# ##i##mount /dev/sdaY /mnt/broken/usr
+
</console>
+
 
+
Then, use the following commands to extract the .tbz2 archive to your broken filesystem that you mounted at <tt>/mnt/broken</tt>:
+
 
+
<console>
+
# ##i##tar xjpvf gcc-4.4.5.tbz2 -C /mnt/broken
+
</console>
+
 
+
You will see a note about the trailing garbage at the end of the file being ignored. This is normal -- tar is ignoring the Portage .tbz2 metadata that is tacked on to the end of the file.
+
 
+
At this point, you can set up bind mounts (see <tt>/mnt/rescue</tt> example earlier in this document for those steps), <tt>chroot</tt> inside <tt>/mnt/broken</tt>, and perform a few tests to determine if your issue has been resolved.
+
 
+
== Fixing broken portage ==
+
Sometimes {{Package|sys-apps/portage}} may fail and the above <tt>binpkg</tt> mentioned way to ressurect system will not work because of portage being broken itself. To fix portage manually the following steps required:
+
<console>
+
# ##i##cd /tmp
+
# ##i##wget https://www.github.com/funtoo/portage-funtoo/tarball/funtoo-2.3.6-r2
+
# ##i##tar xf funtoo-2.3.6-r2
+
# ##i##cd funtoo-portage-funtoo-e491673
+
# ##i##rm -rf /usr/lib/portage/*
+
# ##i##cp -a bin pym /usr/lib/portage/
+
# ##i##ln -s /usr/lib/portage/bin/emerge /usr/bin/emerge
+
</console>
+
This will back a working portage again. To ensure everything is consistent re-emerge portage itself immediately.
+
<console>
+
# ##i##emerge portage </console>
+
File collision warning, if any, can be skipped at this point.
+
 
+
= Critical System Packages =
+
 
+
 
+
Several packages at the heart of your Funtoo system, these mainly are:
+
 
+
{| {{Table}}
+
|-
+
!Component
+
!Package
+
!Functional role
+
|-
+
|GNU Binutils
+
|{{Package|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)
+
|{{Package|sys-devel/gcc}}
+
|GCC is a collection of compilers for 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
+
|{{Package|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 one of the 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
+
|{{Package|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).
+
|-
+
|Python
+
|{{Package|dev-lang/python}}
+
|The Python interpreter is the heart of Portage as is written in Python (the same is also true for various second line utilities).
+
|}
+
 
+
= Various weird issues =
+
 
+
'''P1:''' I have a local distfiles mirror and wget complains about not being able to resolve 'localhost'. <br>
+
'''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)<br>
+
 
+
'''P2:''' Same problem as described in P1 but I use another machine on my network or a public mirror on the Internet  <br>
+
'''S2:''' See the solution given in S1 but with providing the IP of the machine you are downloading for.
+
 
+
[[Category:Internals]]
+
[[Category:Portage]]
+
[[Category:HOWTO]]
+

Latest revision as of 16:35, 1 February 2014

Toshiba NB505 installation.


I am installing from Crunchbang waldorf (based on Debian Wheezy).

First, I create a logical volume called "funtoo" that is 10 Gigabytes large in the volume group "toshiba".

"sudo lvcreate -nfuntoo -L10G toshiba"

Now, this logical volume can be access via its handle "/dev/mapper/toshiba-funtoo".

So what's next... I format it with the ext4 file-system.

"sudo mkfs.ext4 /dev/mapper/toshiba-funtoo"

Then I create a mount-point. In this case, I will mount my funtoo logical volume on /mnt/funtoo.

"sudo mkdir /mnt/funtoo"

Next, I will set permissions on this logical volume (so that my $username can read/write to the volume).

In my case, let $myusername be 'daisuke'. "sudo chown daisuke:daisuke /mnt/funtoo"

Then, i download a stage 3 tarball of funtoo from one of their mirrors to a folder called "backup" in my crunchang installation's home directory "~/". "wget $urltostage3tarball ~/backup" In my case, $urltostage3tarball is "http://ftp.osuosl.org/pub/funtoo/funtoo-current/x86-64bit/atom_64/stage3-latest.tar.xz"

Then, I untar this file into /mnt/funtoo. First I put myself into the target directory (/mnt/funtoo), then I untar the stage3 file. "cd /mnt/funtoo && sudo tar xvJpf ~/backup/$stage3tarballfilename" In my case, $stage3tarballfilename = "stage3-latest.tar.xz"

After that... Uhh.. we gotta chroot into this new installation..first, I gotta mount some stuff. "sudo mount -l proc /proc /mnt/funtoo/proc && sudo mount --rbind /dev /mnt/funtoo/dev && sudo mount --rbind /sys /mnt/funtoo/sys" Then.. copy my wifi dns-resolve info "sudo cp -L /etc/resolv.conf /mnt/funtoo/etc/resolv.conf" Then..chroot "sudo chroot /mnt/funtoo /bin/bash" BAM!

And, until next time.. I'm done. Gotta get out of this cafe.