Sunday, February 5, 2012

Installing Gentoo from a LiveCD (SystemRescueCD)

This is a guide for you to install Gentoo Linux in a much easier way than using the Minimal Installation CD (install-x86-minimal-<release>.iso). By using this way, you can skip the first three parts and start with part 4 in the "Installing Gentoo" section of Gentoo Linux Handbook. (The link is for the x86 architecture. For other archs, refer here.) I'm going to aware on installing Gentoo by using SystemRescueCD live cd by this blog post.

Why I choose to use this method? Firstly, because I didn't know that it's this easy. The other one is I was stuck at setting up a WPA protected Wifi connection via command-line. Believe me when I tell you that configuring a WPA protected WiFi network via command-line is a nightmare. The net-setup only support WEP, and no WPA. You have to use wpa_supplicant for that. While I'm thanking for the hard work of wpa_supplicant developers, they really should think on automating this or at least writing a good documentation. After couple of hours of trying I got fed up. Someone from #gentoo IRC suggested me to use SystemRescueCD. With this you don't have to worry about setting up network connection. You can simply use the live cd's internet connection. NetworkManager takes care of all the needed details. You just need the SSID (The wifi network name), and the WPA password. Here,

SystemRescueCD is also a Gentoo based live cd, and provides enough graphical user interface to do the installation. It has XFCE Desktop Environment with shortcuts to the most needed apps (GParted, networkmanager, Terminal, Firefox etc.) in the bottom panel.


  • First, download it from http://www.sysresccd.org/Download
  • Now, burn it to a CD, or make a bootable USB-stick. The choice is upto you. In this case, I preferred CD because I believe that this will be useful in future too.
  • Do the needful, and boot from your SystemRescueCD. Choose the default (first) option when it asks on what kernel to boot. The interface looks almost like GRUB. See the screenshot.

  • Just wait until it provides the command prompt. What? No GUI? Yes, there is. Make sure you read the message just above the prompt as well. Now use one of the following commands to load the UI.
wizard
startx 
Both of these worked for me.
  •  Now, you will see the xfce desktop getting loaded. Now, setup the network connection via NetworkManager ui client. It's at the bottom-right side. For wireless connections, right-click on it -> 'edit connections' -> wireless tab -> press 'Add' -> Provide SSID (the network name), and set password if necessary. Save and close it. Click on NetworkManager. Click on your connection. You should be connected to the network now. \yay/  

  • Then, just load the Terminal, and you may proceed with part 4 in Gentoo handbook as I told you before. There are very few changes to the commands with this approach. Those are listed under Installation from non-Gentoo LiveCDs. I will brief those here too.
  • To make your life further easier - For part 4, "Preparing the Disks" you may just use GParted that comes with System Rescue CD. Which is in my opinion, highly reliable because if you made mistake with the commands, you may gonna get screwed.
  • At the end of it, make sure you install a desktop environment like GNOME or KDE too. Otherwise you will end up in a Gentoo command prompt anyway. The good news is you can always boot in to the system rescue cd, and continue the installation later on. I learned that I have to install a DE this way ;-). You wanna know how to do this "continuation" after a machine a reboot? Read on.

Changes to the commands

Following is just for the sake of future reference for me.

Mounting of /proc should be done at part 6, not part 4.

When you're ready to unpack the stage tarball in part 5you will need to use a different tar command to ensure that proper group IDs are enforced on the unpacked stage:


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

Now, when you are asked to mount /proc system in part 6, issue the following command instead:

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

Once you're ready to chroot into your unpacked stage in part 6, you will need to use a different chroot command sequence. This ensures that your environment variables are properly setup.

# chroot /mnt/gentoo /bin/env -i TERM=$TERM /bin/bash
# env-update
# source /etc/profile
# export PS1="(chroot) $PS1"

That's it. Other commands in the handbook should be the same. 
Following section describes you how to continue/resume a Gentoo installation in case you are in need of it. 


Resume/Continue a Gentoo Installation

Say, you've run started Gentoo installation, and run past part 6.  Up to this level, your changes will be persisted such that you can easily restart the installation. But in part 6, you chroot to the new environment, and do the changes there. Gentoo installation takes time. In case a power failure occurred after this step or you missed to do one step in the handbook that you remembered just after rebooting the system, or any other case you may need to get back to the installation where you stopped, and resume from there.

With Gentoo, it's far easier to do this. Do mind that this guide is tested only for installing Gentoo via a live cd only. I haven't tested other scenarios but your may give it a try.

Before starting the work from where you left, you need to do following things. Get to a terminal by booting the live cd. For SystemRescueCD case, use the xfce terminal.
Now, mount your root partition.

  # mount /dev/sda3 /mnt/gentoo

(You may need to mount /boot too. I didn't needed that because I didn't use a separate partition for /boot. # mount /dev/sda1 /mnt/gentoo/boot )

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

Following set commands are just the chroot procedure:

# chroot /mnt/gentoo /bin/env -i TERM=$TERM /bin/bash
# env-update
# source /etc/profile
# export PS1="(chroot) $PS1"

You are good to go now. Enjoy the ride!

==========================================

You may try the following if you are using Gentoo minimal cd. I haven't tested this, so I can't be sure that this works. Let me know in the comments how it goes?

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

 # mount -t /proc none /mnt/gentoo/proc
 # mount --rbind /dev /mnt/gentoo/dev

Following is the chroot procedure:
 # chroot /mnt/gentoo /bin/bash
 # env-update
 # source /etc/profile
 # export PS1="(chroot) $PS1"

Much like to hear about your experience regarding this. Did my blog help you at least a little?