Install Gentoo Linux from Debian

Installing Gentoo Linux from chroot. This will take a long time but usually worth it.

Before We Begin

This article is my personal notes on installing a Gentoo Linux on a Dell Studio 1535 laptop. This article is not intended to be a step-by-step guide. You may want to visit the Gentoo Wiki for documentation and more information.

What does this article cover:

  1. Basic installation of a Gentoo Linux on a Dell Studio 1535 laptop
  2. Installation of some system tools
  3. Installation and configuration of wireless for a Broadcom Corporation BCM4312 Wi-Fi card

What does this article not cover:

  1. Installation of Xorg, GUI etc.

Hardware

Some hardware specs are listed below for references.

  1. CPU: Intel Core 2 Duo CPU T5750 @ 2.00GHz
  2. Graphics: ATI Mobility Radeon HD 3450
  3. Wireless: Broadcom Corporation BCM4312 802.11b/g LP-PHY (rev 01)
# lspci
00:00.0 Host bridge: Intel Corporation Mobile PM965/GM965/GL960 Memory Controller Hub (rev 03)
00:01.0 PCI bridge: Intel Corporation Mobile PM965/GM965/GL960 PCI Express Root Port (rev 03)
00:1a.0 USB controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #4 (rev 04)
00:1a.1 USB controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #5 (rev 04)
00:1a.7 USB controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 1 (rev 04)
00:1c.1 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 2 (rev 04)
00:1c.3 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 4 (rev 04)
00:1c.5 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 6 (rev 04)
00:1d.0 USB controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #1 (rev 04)
00:1d.1 USB controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #2 (rev 04)
00:1d.2 USB controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #3 (rev 04)
00:1d.7 USB controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #1 (rev 04)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev f4)
00:1f.0 ISA bridge: Intel Corporation 82801HM (ICH8M) LPC Interface Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] (rev 04)
00:1f.3 SMBus: Intel Corporation 82801H (ICH8 Family) SMBus Controller (rev 04)
01:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI RV620 [Mobility Radeon HD 3400 Series]
01:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI RV620 HDMI Audio [Radeon HD 3400 Series]
03:01.0 FireWire (IEEE 1394): Ricoh Co Ltd R5C832 IEEE 1394 Controller (rev 05)
03:01.1 SD Host controller: Ricoh Co Ltd R5C822 SD/SDIO/MMC/MS/MSPro Host Adapter (rev 22)
03:01.2 System peripheral: Ricoh Co Ltd R5C592 Memory Stick Bus Host Adapter (rev 12)
03:01.3 System peripheral: Ricoh Co Ltd xD-Picture Card Controller (rev 12)
09:00.0 Ethernet controller: Broadcom Corporation NetLink BCM5784M Gigabit Ethernet PCIe (rev 10)
0c:00.0 Network controller: Broadcom Corporation BCM4312 802.11b/g LP-PHY (rev 01)

Prepare Chroot Environment

We will need a wget:

# apt-get install wget

We are going to use an ext4 formatted /dev/sdb6 partition for Gentoo, mounted on /mnt/gentoo:

# mkdir /mnt/gentoo
# mount /dev/sdb6 /mnt/gentoo
# cd /mnt/gentoo

Installation Media

Download the Stage3 Tarball

Check the Gentoo webpage for the newest tarballs.

# wget http://distfiles.gentoo.org/releases/amd64/current-iso/stage3-amd64-20141204.tar.bz2
# wget http://distfiles.gentoo.org/releases/amd64/current-iso/stage3-amd64-20141204.tar.bz2.DIGESTS

Verify integrity:

# sha512sum ./stage3*bz2 && cat ./stage3*DIGESTS

Extract the tarball:

# tar xvjpf ./stage3*.bz2 -C /mnt/gentoo/

Download and Install Portage

# wget http://distfiles.gentoo.org/releases/snapshots/current/portage-latest.tar.bz2
# wget http://distfiles.gentoo.org/releases/snapshots/current/portage-latest.tar.bz2.md5sum

Verify integrity:

# md5sum -c portage-latest.tar.bz2.md5sum 
portage-latest.tar.bz2: OK

Extract the tarball:

# tar xvjf ./portage-latest.tar.bz2 -C /mnt/gentoo/usr/

Installing the Gentoo Base System

Copy DNS info from Debian and mount the necessary filesystems:

# cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
# mount -t proc none /mnt/gentoo/proc
# mount -o bind /dev /mnt/gentoo/dev

Chroot into the new environment:

# chroot /mnt/gentoo /bin/bash

Reload the environment in memory:

# /usr/sbin/env-update && source /etc/profile

Remind yourself you are in chroot:

# export PS1="(chroot) $PS1"

Configure the USE variable according to your needs. Check http://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Base#Configuring_the_USE_variable and https://www.gentoo.org/dyn/use-index.xml pages for more info.

Configure timezone:

(chroot)# cp /usr/share/zoneinfo/GB /etc/localtime

Configure locales:

(chroot)# nano -w /etc/locale.gen
(chroot)# locale-gen

Reload the environment in memory:

(chroot)# /usr/sbin/env-update && source /etc/profile

Configure the Linux Kernel

Optionally, add a nearest Gentoo mirror to /etc/portage/make.conf, i.e.:

GENTOO_MIRRORS="http://www.mirrorservice.org/sites/distfiles.gentoo.org/"

Download a list of packages which you can install from the rsync server:

(chroot)# emerge --sync

Download kernel sources:

(chroot)# emerge gentoo-sources

Change to directory containing the source and configure the kernel:

(chroot)# cd /usr/src/linux && make menuconfig

Some of the Linux kernel 3.17 configuration options are listed below.

64-bit Kernel (*)
Processor type and features –> Processor family (Core 2/Xeon)
Processor type and features –> Dell laptop support (M)

Power management and ACPI options –> Suspend to RAM and standby (*)
Power management and ACPI options –> Hibernation (*)

Networking Support (*)
Networking Support –> Wireless –> Generic IEEE 802.11 Networking Stack (mac80211)

Device Drivers –> Serial ATA and Parallel ATA drivers (*)
Device Drivers –> SCSI device support –> SCSI device support (*)
Device Drivers –> Multiple devices driver support (RAID and LVM) (*)
Device Drivers –> Multiple devices driver support (RAID and LVM) –> Device mapper support (*)
Device Drivers –> Multiple devices driver support (RAID and LVM) –> Crypt target support (M)
Device Drivers –> Network device support (*)
Device Drivers –> Network device support –> Ethernet driver support (*)
Device Drivers –> Network device support –> Universal TUN/TAP device driver support (M)
Device Drivers –> Network device support –> Wireless LAN (*)
Device Drivers –> Network device support –> Wireless LAN –> Broadcom 43xx wireless support (mac80211 support) (M)
Device Drivers –> Network device support –> Wireless LAN –> Broadcom 43xx debugging (*)
Device Drivers –> Network device support –> Wireless LAN –> Intel PRO/Wireless 2100 Network Connection (M)
Device Drivers –> Sound card support (*)
Device Drivers –> Sound card support –> Advanced Linux Sound Architecture (*)
Device Drivers –> Sound card support –> Advanced Linux Sound Architecture –> HD-Audio –> (2048) Pre-allocated buffer size for HD-audio driver
Device Drivers –> USB support (*)

File systems –> Second extended fs support (*)
File systems –> Ext3 journalling file system support (*)
File systems –> The Extended 4 (ext4) filesystem (*)
File systems –> FUSE support (M)
File systems –> Network File System (*)
File systems –> DOS/FAT/NT filesystesm –> MSDOS fs support (*)
File systems –> DOS/FAT/NT filesystesm –> VFAT (Windows-95) fs support (*)
File systems –> DOS/FAT/NT filesystesm –> NTFS file system support (M)

Cryptographic API –> MD5 digest algorithm (*)
Cryptographic API –> SHA256 digest algorithm (*)
Cryptographic API –> SHA512 digest algorithm (*)
Cryptographic API –> AES cipher algorithm (*)
Cryptographic API –> Blowfish cipher algorithm (*)
Cryptographic API –> Twofish cipher algorithm (*)

Virtualization –> Kernel-based Virtual Machine (KVM) support (M)
Virtualization –> KVM for Intel processors support (M)

Compile the Linux Kernel

Compilation may take from several minutes up to hours, depending on the speed of the hardware and the number of kernel features you’re compiling. Build the kernel:

(chroot)# make -j2

The -j2 parameter enables two parallel processes. Install kernel and its modules:

(chroot)# make modules_install install

Command “make install” serves as a shortcut for copying the kernel file, the System.map and the config files where “make modules_install” installs kernel modules under /lib/modules/3.17.7-gentoo/

Configure the Gentoo System

Create the fstab File

(chroot)# cat > /etc/fstab << EOL
/dev/sbd6   /  ext4   noatime  0 1
EOL

Host and Network Configuration

(chroot)# echo 'config_eth0="dhcp"' >> /etc/conf.d/net
(chroot)# echo 'hostname="gentoo"' > /etc/conf.d/hostname

Automatically Start Networking at Boot

(chroot)# cd /etc/init.d
(chroot)# ln -s net.lo net.eth0
(chroot)# rc-update add net.eth0 default

Root Password

Set the root password:

(chroot)# passwd root

Create a Regular User

(chroot)# useradd -m -s /bin/bash sandy
(chroot)# passwd sandy

Optionally, add the regular user to the wheel group to be allowed to execute the “su” command to become root:

(chroot)# usermod -aG wheel sandy

Installing System Tools

Install a system logger, cron daemon and add them to the default runlevel:

(chroot)# emerge --ask syslog-ng vixie-cron
(chroot)# rc-update add syslog-ng default
(chroot)# rc-update add vixie-cron default

Install a DHCP client:

(chroot)# emerge --ask dhcpcd

Optionally, install less pager and vim text editor:

(chroot)# emerge --ask less vim

Exit chroot.

(chroot)# exit

Now it’s a good time to run update-grub, or alternatively add the following entry to the /boot/grub/grub.cfg on the Debian system:

menuentry 'Gentoo' --class debian --class gnu-linux --class gnu --class os {
        set root='(hd1,msdos6)'
        linux /boot/vmlinuz-3.17.7-gentoo root=/dev/sdb6
}

Unmount all mounted partitions and reboot the Debian system:

# umount -l /mnt/gentoo/dev{/shm,/pts,}
# umount /mnt/gentoo{/boot,/sys,/proc,}
# reboot

After reboot, choose the Gentoo option from a GRUB menu.

Configure Wireless for Broadcom Corporation BCM4312

We are working from the Gentoo system now.

# emerge --ask linux-sources
# emerge --autounmask-write broadcom-sta
# etc-update
# emerge --ask broadcom-sta
# emerge --ask wpa_supplicant wireless-tools pciutils

Add the following to /etc/conf.d/net:

modules_wlan0="wpa_supplicant"
wpa_supplicant_wlan0="-Dnl80211"
config_wlan0="dhcp"

Add wifi details to /etc/wpa_supplicant/wpa_supplicant.conf. Create the file if one does not exist.

# Allow users in the 'wheel' group to control wpa_supplicant
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
#ap_scan=0

# To make this file writable for wpa_gui
#update_config=1

 network={
 ssid="wifi-name"
 psk="wifi-passwd"
 scan_ssid=1
 proto=WPA2
 key_mgmt=WPA-PSK
 group=CCMP TKIP
 pairwise=CCMP TKIP
 priority=5
}

Start wireless at boot:

# cd /etc/init.d
# ln -s net.lo net.wlan0
# rc-update add net.wlan0 defaults

Reboot.

See which modules conflict with wl:

# lsmod
Module                  Size  Used by
b43                   411277  0 
bcma                   32211  1 b43
wl                   6263139  0 
ssb                    39298  1 b43

Remove conflicting modules and reload wl:

# modprobe -r b43 wl
# modprobe wl

Add conflicting modules to blacklist:

# cat > /etc/modprobe.d/blacklist.conf << EOL
blacklist bcma
blacklist ssb
blacklist b43
EOL

Reboot. Wifi should be connected automatically.

2 thoughts on “Install Gentoo Linux from Debian

  1. Automatically Start Networking at Boot

    (chroot)# cd /etc/init.d
    (chroot)# ln -s net.lo net.eth0
    (chroot)# rc-update add net.eth0 “””defaults””” must be “default”

Leave a Reply

Your email address will not be published. Required fields are marked *