Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Installing/fixing Gentoo with livedvd & chroot
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

Joined: 19 Dec 2012
Posts: 40

PostPosted: Tue Jan 08, 2013 11:54 pm    Post subject: Installing/fixing Gentoo with livedvd & chroot Reply with quote

Why another tutorial on chroot? There are so many out there!

Well, there are many tutorials out there but none of them, at least through my searching, seemed to have all of the information in the one post. Many were missing critical information that would have saved a lot of hassle, such as turning swap on, adding the ability to use the network in chroot, or unmounting...

When should I use chroot?

1. You want to have a full suit of easy to use gui tools at your disposal when installing Gentoo, ie; internet browswer, xchat, partition manager...

2. You only have one computer and you don't want it tied down for a day or two whilst packages are being emerged.

3. You've messed something up badly and cannot boot the system.

Does this really work?
I've had success with doing a full Gentoo installation plus installing X, a window manager, all drivers, and several other packages... Only once did I reboot into my new Gentoo install to check if the initial install was okay, which it was. I will not promise this will work for you. You may end up destroying your partitions or ruining your install or just wasting your time. I'll not be responsible! You do this at your own risk!

Note: If you just want to chroot into an already installed system then jump down to the section: I want to chroot into my installed system - How do I do it?.

I'm in! Where do I start?
I'm going to assume you're installing using the Gentoo x86 manual and that you are 'going by the book'. If you've decided to install on different partitions then specified in the book then you'll have to change some steps accordingly to fit your situation. I did the install using the Gentoo 12.1 (at this time) livedvd installation medium which can be found here:

Burn the dvd and boot it up. You'll be starting the install at chapter 4. So open up a browswer and go to this link:

Open a terminal and follow the handbooks instructions until you get to Chapter 5b: Code Listing 2.5: Unpacking the stage. Enter this command instead:

tar --numeric-owner -xvjpf stage3-*.tar.bz2

Continue on until you get to Chapter 6a: Copy DNS Info and then enter the following commands instead:

Mount the partitions:
mount /dev/sda3 /mnt/gentoo
mount /dev/sda1 /mnt/gentoo/boot
mount -t proc none /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev

Copy DNS info to allow us to use the net within chroot:
cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf

Chroot into the system:
chroot /mnt/gentoo /bin/env -i TERM=$TERM /bin/bash
source /etc/profile
export PS1="(chroot) $PS1"

.. resume the install at Chapter 6.b. Configuring Portage and finish the install.

Reboot into the new Gentoo install, that is, without the livedvd, and check to see if all is fine. If something has messed up or you just want to keep using chroot then follow the section below:

I want to chroot into my installed system - How do I do it?

Boot the Gentoo livedvd and open a terminal and browser to this link.

Copy and paste this into the terminal:
# Create mounting directories
mkdir /mnt/gentoo
cd /mnt/gentoo
# Enter root
sudo -i
# Activate swap
swapon /dev/sda2
# Mount partitions
mount /dev/sda3 /mnt/gentoo
mount /dev/sda1 /mnt/gentoo/boot
mount -t proc none /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev
# Copy netowrk information so we can use the net inside chroot
cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
# Chroot into system
chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="(chroot) $PS1"
# Do stuff here:

Do whatever you want to do in choot. You will have net access and activated swap, so you can easily merge stuff, replace the kernel, edit files... like you would on an ordinary non-chrooted system. I should note that this chroot guide does not have the ability to run x, but that's not really necessary in most cases anyways.

When you're done simply paste the following into terminal:
# Exit chroot:
# Unmount
umount /mnt/gentoo/boot /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo
# Deactivate swap
swapoff /dev/sda2
# Return to user prompt

You're done!

If anyone has any suggestions or information to add please post and I'll add it and credit you. I'd love to get X working in chroot but have only got so far as to have X run the Gentoo livedvd's X, and not the X in the chroot environment.
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