Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Mini-HOW-TO: Recover a broken / partial Gentoo installation
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Helena
Veteran
Veteran


Joined: 02 Apr 2003
Posts: 1030
Location: De Meern, The Netherlands

PostPosted: Sat Jan 17, 2004 8:53 am    Post subject: Mini-HOW-TO: Recover a broken / partial Gentoo installation Reply with quote

Sometimes an error occurs while installing Gentoo, or you forget to install a boot loader before you reboot. At other times your partitions get messed up, or you've done a backup of an entire installation and after restoring partitions you find that GRUB is unable to boot.

In such a situation, you would like to go into your (partial) installation, repair things and get working. Fortunately this is possible and even easy. Thanks to Linux' simple yet powerful architecture there are even multiple ways to do this. However, I wil describe only 1 method, which use the Gentoo LiveCD, since that will probably always be available.

To use the Live CD to boot into a partial or non-booting Gentoo Linux installation, perform the following steps:

1. Boot your computer from the LiveCD
Any version that boots on that computer will do, even the basic CD if you don't need the stage tarballs. However, I recommend using the same LIveCD that was used for the installation, this will be much easier generally. Of course, you ,may have to specify certain LiveCD parameters, like
    acpi
    doataraid
    ...
Consult the installation handbook http://www.gentoo.org/doc/en/handbook/handbook.xml?part=1 for information.

2. Mount the partitions you want to use
Normally this would be achieved by
Code:
mount /dev/hdax /mnt/gentoo
mount /dev/hday /mnt/gentoo/boot
swapon /dev/hdaz]
mount -t proc none  /mnt/gentoo/proc
Replace x, y and z in the above command lines with the correct numbers, of course. If your network installation was not finished you may have to insert another
Code:
cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf

3. Enter the installation
with
Code:
cd /mnt/gentoo
chroot /mnt/gentoo /bin/bash
env-update
source /etc/profile
From here you may resume the installation at any point.
Back to top
View user's profile Send private message
scorchen
n00b
n00b


Joined: 18 Sep 2003
Posts: 23

PostPosted: Sat Jan 17, 2004 9:02 am    Post subject: Reply with quote

and this actually works quite well. I had to do this exact thing a few days ago.
Back to top
View user's profile Send private message
tristure
Apprentice
Apprentice


Joined: 30 Oct 2003
Posts: 270
Location: France

PostPosted: Sat Jan 17, 2004 11:40 am    Post subject: Reply with quote

Thanks for these useful tips!

I wish I had read such a post one or two months ago... Could have saved time!
Back to top
View user's profile Send private message
humpback
Retired Dev
Retired Dev


Joined: 19 Oct 2002
Posts: 394
Location: Coimbra - Portugal

PostPosted: Sat Jan 17, 2004 3:17 pm    Post subject: Reply with quote

Nice information. If you could extend this info on how to recover from a broken system i would move it to the Documentation, Tips and Tricks.
Also, the Gentoo Live cd is a very good recover tool. I have used it to fix problems in many Linux (non Gentoo) systems.
_________________
Gustavo Felisberto
Humpback @ #gentoo-pt
------------
It's most certainly GNU/Linux, not Linux. Read more at
http://www.gnu.org/gnu/why-gnu-linux.html .
-------------
Back to top
View user's profile Send private message
ett_gramse_nap
Apprentice
Apprentice


Joined: 01 Oct 2003
Posts: 252
Location: Göteborg, Sweden

PostPosted: Sat Jan 17, 2004 4:43 pm    Post subject: Reply with quote

Ah! I was just wondering about this... Thanks!
_________________
Don't bother!
Back to top
View user's profile Send private message
D. M. P. inc
Apprentice
Apprentice


Joined: 29 Sep 2003
Posts: 228
Location: /home/dmpinc

PostPosted: Sat Jan 17, 2004 5:57 pm    Post subject: Reply with quote

i have a few time in my hand so ill finish up on behalf of Helena work. ill start it again due to somepoeple get confuse fast.

Quote:
Sometimes an error occurs while installing Gentoo, or you forget to install a boot loader before you reboot. At other times your partitions get messed up, or you've done a backup of an entire installation and after restoring partitions you find that GRUB is unable to boot.

In such a situation, you would like to go into your (partial) installation, repair things and get working. Fortunately this is possible and even easy. Thanks to Linux' simple yet powerful architecture there are even multiple ways to do this. However, I wil describe only 1 method, which use the Gentoo LiveCD, since that will probably always be available.

To use the Live CD to boot into a partial or non-booting Gentoo Linux installation, perform the following steps:





HOW TO Fix Basic Gentoo Installation Errors Using Gentoo LiveCD :

1st Step :

Boot your computer from the LiveCD
Any version that boots on that computer will do, even the basic CD if you don't need the stage tarballs. However, I recommend using the same LIveCD that was used for the installation, this will be much easier generally. Of course, you ,may have to specify certain LiveCD parameters, like

acpi
doataraid
...

Consult the installation handbook http://www.gentoo.org/doc/en/handbook/handbook.xml?part=1 for information.

2nd Step :

Mount the partitions you want to use
Normally this would be achieved by
Code:

mount /dev/hdax /mnt/gentoo
mount /dev/hday /mnt/gentoo/boot
swapon /dev/hdaz]
mount -t proc none  /mnt/gentoo/proc

Replace x, y and z in the above command lines with the correct numbers, of course. If your network installation was not finished you may have to insert another
Code:

cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf


3rd Step :
Enter the installation with
Code:

cd /mnt/gentoo
chroot /mnt/gentoo /bin/bash
env-update
source /etc/profile


From here just look for Errors You Got

- ERROR ON : /etc/fstab
Code:
nano -w /etc/fstab

Code:

/dev/BOOT           /boot       ext2        noauto,noatime  1 2
/dev/ROOT           /           reiserfs    noatime         0 1
/dev/SWAP           none        swap        sw              0 0
/dev/cdroms/cdrom0  /mnt/cdrom  iso9660     noauto,ro,user  0 0
none                /proc       proc        defaults        0 0

- ERROR ON : GRUB
just re-emerge grub to make sure your doing it right

Code:

# emerge -k grub
# grub


Code listing 23.2: GRUB on the MBR
Quote:
this is if u have only gentoo on ur system

Code:

grub> root (hd0,0) (Your boot partition)
grub> setup (hd0) (Where the boot record is installed; here, it is the MBR)


Code listing 23.3: GRUB not on the MBR
Quote:
this is if u have another operating system


Alternatively, if you wanted to install the bootloader somewhere other than the MBR:

Code:
grub> root (hd0,0) (Your boot partition)
grub> setup (hd0,4) (Where the boot record is installed; here it is /dev/hda5)
grub> quit


- ERROR ON : grub.conf

Code:
# nano -w /boot/grub/grub.conf


Code:

 Code listing 23.4: grub.conf for GRUB

default 0
timeout 30
splashimage=(hd0,0)/boot/grub/splash.xpm.gz

# If you compiled your own kernel, use something like this:
title=My example Gentoo Linux
root (hd0,0)
kernel (hd0,0)/boot/bzImage root=/dev/hda3

# If you're using genkernel, use something like this instead:
title=My example Gentoo Linux (genkernel)
root (hd0,0)
kernel (hd0,0)/boot/kernel-KV root=/dev/hda3
initrd (hd0,0)/boot/initrd-KV

# Below needed only for people who dual-boot
title=Windows XP
root (hd0,5)
chainloader (hd0,5)+1


- ERROR ON : Kernel
Code listing 16.1: Emerging Kernel Sources
Code:

# emerge -k gentoo-sources

Code listing 16.2: Emerging genkernel
Code:

# emerge -k genkernel

Code:

If you're using genkernel 1.2 (included in the 1.4-20030803 x86/i686 GRP set), use the following:
# genkernel gentoo-sources
If you're using genkernel 1.4 or newer, there's no need to specify a kernel:
# genkernel

Code listing 16.5: Configuring the Linux Kernel
Quote:
Manual Configuration

Code:

# cd /usr/src/linux
# make menuconfig


Code listing 16.6: make menuconfig options
Code:

Code maturity level options --->
[*] Prompt for development and/or incomplete code/drivers"
(You need this to enable some of the options below)
...

File systems --->
<*> Reiserfs support
(Only needed if you are using reiserfs)
...
<*> Ext3 journalling file system support
(Only needed if you are using ext3)
...
[*] Virtual memory file system support (former shm fs)
(Required for Gentoo Linux)
...
<*> JFS filesystem support
(Only needed if you are using JFS)
...
[*] /proc file system support
(Required for Gentoo Linux)
[*] /dev file system support (EXPERIMENTAL)
[*]   Automatically mount at boot         
(Required for Gentoo Linux)
[ ] /dev/pts file system for Unix98 PTYs
(Uncheck this, it is not needed unless you use a 2.6 kernel)
...
<*> Second extended fs support
(Only needed if you are using ext2)
...
<*> XFS filesystem support
(Only needed if you are using XFS)


Code listing 16.7: Compiling and Installing the kernel
Quote:
Do This After genkernell or even manual config of kernel


Code:

# make dep && make clean bzImage modules modules_install
# cp /usr/src/linux/arch/i386/boot/bzImage /boot




hope this helps all
_________________
Live And Learn.
Back to top
View user's profile Send private message
ian!
Bodhisattva
Bodhisattva


Joined: 25 Feb 2003
Posts: 3827
Location: Essen, Germany

PostPosted: Sat Jan 17, 2004 10:20 pm    Post subject: Reply with quote

Moved to 'Documentation, Tips & Tricks'.
_________________
"To have a successful open source project, you need to be at least somewhat successful at getting along with people." -- Daniel Robbins
Back to top
View user's profile Send private message
Braempje
l33t
l33t


Joined: 31 Jan 2003
Posts: 748

PostPosted: Sun Jan 18, 2004 9:10 am    Post subject: Reply with quote

Don't forget mounting dev for non-livecd installers. This guide is awsome, I just posted a bug last night regarding this information :D
_________________
Dictionary of the Flemish Sign Language - Woordenboek Vlaamse Gebarentaal
Back to top
View user's profile Send private message
Helena
Veteran
Veteran


Joined: 02 Apr 2003
Posts: 1030
Location: De Meern, The Netherlands

PostPosted: Sun Jan 18, 2004 9:58 am    Post subject: Reply with quote

Thanks D. M. P. inc for your contribution. I will update the guide later, using your work and maybe some others'; I also want to correct a few minor errors. I feel something useful work is being done! :D
Back to top
View user's profile Send private message
viperlin
Veteran
Veteran


Joined: 15 Apr 2003
Posts: 1317
Location: UK

PostPosted: Mon Jan 19, 2004 9:53 pm    Post subject: Reply with quote

although i knew this i guess it wasn't as pbvious to everyone else, so thanks for giving the community this howto :-)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum