# Using Gentoo CD to repair a broken system

## delta407

The Gentoo install CD is very flexible; is is essentially just a Linux boot disk with a lot of useful utilities. So, if you botched your install, deleted /etc/fstab, or did something else preventing your computer from booting up right, just grab your trusty Gentoo disk.

Booting up is relatively easy, just pop it in your CD-ROM, make sure the BIOS is set to boot off of the CD, and wait for the boot: prompt. At this point, you could (if you wanted to) pass custom kernel options, but that's probably not going to be helpful, so just press enter. It will let you select a few things (most of which you can probably press enter at), and you will finally arrive at a prompt.

Now, you have to get access to your computer's filesystem(s). Assuming you know what partition mounts where, reassembling your filesystem can be done without too much trouble either.

```
# mkdir /mnt/gentoo                     <-- create a mountpoint for your / filesystem

# mount /dev/hda3 /mnt/gentoo           <-- attach your root partition (substitute hda3)

# mount /dev/hda1 /mnt/gentoo/boot      <-- attach your boot partition (substitute hda1)

# mount -o bind /proc /mnt/gentoo/proc   <-- since you never know when something might need it
```

At this point, your computer's filesystem should be accessible at /mnt/gentoo. You can use nano, the text editor included on the CD-ROM, to edit your configuration files as necessary (but remember to use "nano -w", otherwise nano will format it improperly). You can chroot into your computer ("chroot /mnt/gentoo /bin/sh"), if necessary, to do things like recompile your kernel (since installing modules will likely put them in /lib) or run Portage.

Once you're all done, run "umount -a" to unmount your filesystems correctly, and reboot.Last edited by delta407 on Sat Sep 28, 2002 11:03 pm; edited 1 time in total

----------

## Zu`

Thanks for these tips, I'm sure they'll come in hand one day  :Smile: 

Greets

----------

## Mike_McCready

That day is today.

----------

## get sirius

After performing the above, it is then necessary to enter "#chroot /mnt/gentoo /bin/bash" in order to finally gain access to files written to one's hard drive (at least, in my quite-recent experience).  Then perform the steps listed at code listing 41 in the Gentoo Installation Guide.

----------

## pjp

Made this one sticky.  I've run across many occaisions when it would help someone out.  Hopefully there aren't too many others in here that need to be sticky.

EDIT:  Unsticking as there is a FAQ on this.

----------

## HamuNaptra

I get this error:

# mount --bind /proc /mnt/gentoo/proc 

mount: invalid option -- -

mount: invalid option -- b

mount: invalid option -- i

mount: invalid option -- d

mount: Mounting /proc on /mnt/gentoo/ptoc failed: Block device required

--------------------------------------

mount -o bind /proc /mnt/gentoo/proc worked  :Smile: 

----------

## pilla

Great, I've seen some lads that have erased their gcc-2.95 before emerging gcc-3.2 in some threads. I hope they'll find their way  :Cool: 

 *kanuslupus wrote:*   

> Made this one sticky.  I've run across many occaisions when it would help someone out.  Hopefully there aren't too many others in here that need to be sticky.

 

----------

## theneopro

HamuNaptra wrote:

 *Quote:*   

> I get this error: 
> 
> # mount --bind /proc /mnt/gentoo/proc 

 

this is the proper syntax:

# mount -o bind /proc /mnt/gentoo/proc

-Mykey

----------

## RagManX

And while you are at it, seems like you should turn on your swap:

```
swapon /dev/hda2
```

RagManX

----------

## Ard Righ

Could I suggest this gets added to the documentation for future Gentoo install ISOs, like for the 1.4 releases.

 I just screwed up my kernel install, and without this guide handy, I would have to reinstall from scratch  :Sad: 

----------

## sheepdog

This is all well and good.  But the problem is that I am having the same problem exactly as in 

https://forums.gentoo.org/viewtopic.php?p=108169#108169

for which there was apparantly no resolution.  So I am trying to go back an rebuild a different kernel.  Instead of OpenMosix I want the vanilla kernel.  So I emerge sys-kernel/vanilla.  That works.  But the build is still using th openmosix sources.  So i emerge unmerge openmosix.  That works.  Now I try to build in /usr/src/linux but there is no longer a Makefile there so nothing happens.  So I go back and emerge unmerge sys-kernel/vanilla and then emerge sys-kernel/vanilla.  Still there is no Makefile for building.  How is this done?

-- Michael

P.S.  Found my own answer.  The /usr/src/linux was still linked to /usr/src/linux-2.4.19-openmosix.  This was switched to link to /usr/src/linux-2.4.19 and all is well.Last edited by sheepdog on Thu Oct 24, 2002 4:45 am; edited 1 time in total

----------

## pjp

You have to link /usr/src/linux to the appropriate directory.  For example, on my system:

```
# ls -l /usr/src/linux

lrwxrwxrwx    1 root     root           15 Apr 18  2002 /usr/src/linux -> linux-2.4.19-r1/
```

linux-2.4.19-r1 (or whatever) should be a directory under /usr/src

----------

## barnaclebarnes

It may also be handy to have the default .config file which the CD sources are built off. That way if the CD booted OK then a kernel built with the same config should as well. You can find the default config here:

Default .config

This should get you up and running. Note that this works with the Vanilla kernel. Not sure about the others.

----------

## weeds2001

thank you all for this info!!  for some reason my grub.conf file got screwed up.....it was booting, but it was booting to grub>  .... so now I'll be able to at least get back and change what I need to!!    :Very Happy: 

----------

## ckwall

Thank you so much for posting this, I was seconds away from reinstalling linux from scratch after jackin up my system. This seems like what I have been praying for.

----------

## sephtin

From a compilation of this thread, and from the install doc... Here's what I threw together for my personal OH S#!T docs.

 :Wink: 

Ya never know when you might need such a thing....

```

To Fix things using the Gentoo install CD:

1) Boot from the CD

2) swapon /dev/hd??

3) mount /dev/hd?? /mnt/gentoo

4) mount /dev/hd?? /mnt/gentoo/boot

5) mount -t proc proc /mnt/gentoo/proc

6) chroot /mnt/gentoo /bin/bash

7) env-update

8) source /etc/profile

9) --fix whatever and reboot.

```

----------

## clocker

[quote="sephtin"]From a compilation of this thread, and from the install doc... Here's what I threw together for my personal OH S#!T docs.

 :Wink: 

Ya never know when you might need such a thing....

[code]

To Fix things using the Gentoo install CD:

1) Boot from the CD

2) swapon /dev/hd??

3) mount /dev/hd?? /mnt/gentoo

4) mount /dev/hd?? /mnt/gentoo/boot

5) mount -t proc proc /mnt/gentoo/proc

6) chroot /mnt/gentoo /bin/bash

7) env-update

 :Cool:  source /etc/profile

9) --fix whatever and reboot.

[/code][/quote]

Hi there...

I wish my install had a nice little "--fix" option..heh   I have had some trouble with my /boot partition.  There was some corruption on it and once that was fixed up with "e2fsck" for it's ext2 formatting most of the information was missing.  I still had a /boot/grub but the /boot was otherwise empty.

So.. I'm several attempts into this attempt to live in Gentoo.  I've build this system up before over a dial-up from scratch and I'm not too anxious to begin again.  

Is there some way to rebuild the contents of the /boot without starting from scratch?  I tried putting "bzImage" and the "system.map" in and editing my "/etc/fstab" to reflect my partition scheme and not references like "/dev/BOOT"

linux-2.4.20-gentoo-r5  linux-2.4.21 are both built and all the software is installed and portage is updated and and and... I want this dang thing to boot already! 

The "/boot" is ext2fs like I said but the rest are all reiserfs.  

I have built this Gentoo install from a "chroot" shell on my Redhat 7.2 box.

Any ideas will be welcomed.

Cheers!  Ian.

----------

## sephtin

There may be more that I'm missing.. (but I don't know what it would be)...

But in /boot, all I'm aware of there is the boot loader, it's config file, and the kernel image.  Here is what I would try to get things back into running order:

-  Rebuild your kernel

(There are a couple different ways listed in the install docs):

http://www.gentoo.org/doc/en/gentoo-x86-install.xml#doc_chap16

Install Grub:

http://www.gentoo.org/doc/en/gentoo-x86-install.xml#doc_chap23

Other than that.. you should be ok.  If you have questions.. post them...   :Smile: 

HTH

John

----------

## clocker

Thanks for the hand.. 

I put my copy of a good bzImage and a system.map in and tried to boot but that seems to be a bit short of the mark.  I have a ton of other errors screaming at me but I can get to a prompt.  I can't log in but I can get to a prompt..ehhe

I am back in my chroot from my redhat box so I can begin to repair what I can.  I have moved this to the install forum under a similar topic.

Thanks again.

Ian.

----------

## sephtin

are the errors regarding modules/etc?

Probably making modules again, would help?

What types of errors?

John

----------

## clocker

sephtin.

I don't believe they were actually.. but your suggestion is a good one.. If I don't hear back from others shortly I'll try to rebuild the kernel and modules before I go and do anything drastic... heh  I'm so close I can taste it!  

Cheers!  Ian.

----------

## clocker

sephtin.

You did the deed.. thanks.. silly me for not testing with the single bzImage.. I just did not believe it was going to work..

Replacing the kernel image "bzImage" and working on my "/etc/fstab" I"m back in gear.  Oh me of little faith.. heh 

Thanks.  By your clear thought I'm back on the learning curve.. cheers.. 

Ian.

----------

## sephtin

And may your learning curve go smoothly!

Without knowing the error messages or specifics of what was exactly done to the system, I have to admit that it was simply a guess based on my experiences of trying to get my system back up after Genkernel hosed it.  

<ot> I think genkernel has a lot of potential, but it's not quite there yet.   :Wink: 

</ot>

Anyway, when I got the "tons of error messages screaming at me", recompiling modules, etc. didn't quite do it for me.. I had to move the config file, make dep, move the config file back, and go through the process again... so I know how you felt...  Think of it this way.. rather than detracting you from learning, it was simply another step along the way..  :Wink: 

After all the help I've received on this forum, I'm just glad I could help out.   :Smile: 

John

----------

## clocker

It seems like a great community.. I'm building a Debian box at the same time and this community seems a little looser all round.. ;^)

gracias.. nice guess... hehe

----------

## TecHunter

hehe,i've already used knoppix livecd to repaire grub,very useful.

----------

## bus_drivr

OK just my 2 cents,

To Fix things using the Gentoo install CD:

1) Boot from the CD

2) swapon /dev/hd??

3) mount /dev/hd?? /mnt/gentoo 

4) mount -t proc proc /mnt/gentoo/proc

5) chroot /mnt/gentoo /bin/bash 

I follow these lines to here, if i need to check my filesystem i can fsck from here and I can use my /etc/fstab to...

6) mount /boot

For me /usr is a different partition so

7) mount /usr

 :Cool:  env-update

9)source /etc/profile

10) --fix whatever and reboot.

----------

## bus_drivr

Actually to fsck you can do that from the LiveCD. If you don't have a hard copy of /etc/fstab cfdisk provides partition info.

----------

## kotik

I cannot edit my grub.conf as this FAQ says. 

```
nano -w /boot/grub/grub.conf
```

It gives an error that says no such file or folder excists. I cannot even create a new one  :Confused: 

----------

