« Home | Stock Market Crash Ahead? » | [Perl] Search and Replace Copyright in Source Code... » | [subversion] Using patches to manage temporary cod... » | We are now debt free... » | Screen Utility (and my .screenrc) » | Back to Zero. » | Spammers are forging e-mail to appear from this do... » | How to recursively delete files and directories (*... » | My Financial Goal for 2009: 100% Debt Free (foreve... » | Apple and Stanford to offer free iPhone developmen... »

Gentoo: Recovering from installing a bad kernel

Arguably, Gentoo is the best Linux distribution available.  If you have patience and don't mind tweaking you can have a system that is built from the ground up with only the features you want with a minimum of what you don't.  However, for new users, it can be intimidating. 

The price of being able to build a system and kernel with exactly the features you want (my kernel is down to 3.1MB), there are some pain points.  The biggest headache is that after spending time configuring the kernel and you reboot only to get a kernel panic.  Here is how to get back to recompile the kernel. 

Insert the CDROM and boot.  At the livecd prompt remount your drives (swap out sda with your device):

# swapon /dev/sda2
# mount /dev/sda3 /mnt/gentoo
# mount /dev/sda1 /mnt/gentoo/boot

Next, mount the proc and dev mount points, and then change root:

# mount -t proc none /mnt/gentoo/proc
# mount -o bind /dev /mnt/gentoo/dev
# chroot /mnt/gentoo /bin/bash
# env-update
>> Regenerating /etc/ld.so.cache...
# source /etc/profile

Now you can work on getting the kernel.

# cd /usr/src/linux
# make menuconfig
make && make modules_install
make install

(change the grub.conf file)
exit
umount /mnt/gentoo/proc /mnt/gentoo/dev /mnt/gentoo
reboot

Labels: ,