About Me

A Computer Enthusiast who's learning as much as I can, while attempting to share and re-distribute the knowledge! Enjoy! :D

Wednesday, August 22, 2012

Gentoo 2012 Install on a MacBook Pro via VB

This is quick tutorial and/or notes for myself on installing Gentoo as VM on MacBook Pro using Virtual Box.

Notes
------
* Followed on-line documentation at: http://www.gentoo.org/doc/en/handbook/handbook-x86.xml
* Notes for a quick installation. In depth information ... read/follow the on-line documentation.
* To get a listing of available drives ... `ls /dev`

Installation
-----------
* I started on step 4: Preparing the Disks (from the on-line documentation)
After creating the extended partition, you then create the logical partition; make sure the /boot partition is bootable by using the 'a' option of fdisk;
* m: help
* p: print
* n: new partition
* w: write partition table
* a: make partition bootable
* d: delete partition
----------------------------
fdisk /dev/sda
----------------------------

This is the table I used for creating the partition table
----------------------------
/dev/sda1     /boot           +32M
/dev/sda2     swap           +512M
/dev/sda3     /                  +4G
/dev/sda4     Extended     default (remaining free space)
----------------------------

Logical Partition
----------------------------
/dev/sda5     /home          default (remaining free space)
----------------------------

* Make filesystems
I use ext4 types for the filesystem
----------------------------
mkfs.ext4 /dev/sda1
mkfs.ext4 /dev/sda3
mkfs.ext4 /dev/sda5
----------------------------

* Create and enable swap space
----------------------------
mkswap /dev/sda2
swapon /dev/sda2
----------------------------

* Mount newly created filesystems
This assumes you're following my partition scheme; adjust to your needs
----------------------------
mount /dev/sda3 /mnt/gentoo
mkdir /mnt/gentoo/boot
mkdir /mnt/gentoo/home
mount /dev/sda1 /dev/gentoo/boot
mount /dev/sda5 /mnt/gentoo/home
----------------------------

* Enter into /mnt/gentoo directory
----------------------------
cd /mnt/gentoo
----------------------------

* Configure your network card
Since I'm in a VM, I had to manually set-up my network card; verify network connectivity with ping
----------------------------
net-setup eth0
ping www.google.com
----------------------------

* Download and untar stage3 tarball
Use links; verify you're in /mnt/gentoo (or the mountpoint at which you mounted your root fs; looks like i686 is used for newer processes (64-bit), i486 and lower are used for older/lower processors (32-bit)
* q: quit links
* d: download file
----------------------------
links http://www.gentoo.org/main/en/mirrors.xml
select a mirror
navigate to: releases --> --> current-stage3 --> stage3...bz2
----------------------------

* Download and untar latest portage snapshot
Use links; verify you're in /mnt/gentoo (or the mountpoint at which you mounted your root fs
----------------------------
links http://www.gentoo.org/main/en/mirrors.xml
navigate to: snapshots --> portage-latest.tar.bz2
tar xvjf /mnt/gentoo/port... -C /mnt/gentoo/usr - (port... is the portage name)
----------------------------

* Configure compile options
View /mnt/gentoo/usr/share/portage/config/make.conf.example for make.conf examples; I kept mine standard. If you have multiple processors for the VM, you could add -j2 for parallel compiling
----------------------------
nano /mnt/gentoo/portage/make.conf <-- this file is not created by default
* Optional * MAKEOPTS="-j2" into make.conf for parallel compiling
----------------------------

* Optional: Select a mirror relatively close to your location (speeds DL times)
----------------------------
mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf
mirrorselect -i -r -o >> /mnt/gentoo/etc/portage/make.conf
----------------------------

* Copy DNS servers
----------------------------
cp -L /etc/resolv.conf /mnt/gentoo/etc

* Mount necessary filesystems
----------------------------
mount -t proc none /mnt/gentoo/proc
mount --rbind /dev /mnt/gentoo/dev
mount --rbind /sys /mnt/gentoo/sys
----------------------------

* Chrooting into new environment
----------------------------
chroot /mnt/gentoo /bin/bash
env-update
source /etc/profile
export PS1="(chroot) $PS1"
----------------------------

* Configure Portage
----------------------------
emerge --sync
----------------------------

* Choose profile
I kept the default profile: option 1 default/linux/x86/10.0 *
----------------------------
eselect profile list
----------------------------

* Configure USE variable
I kept the default USE variable (will research more on this)

* Optional: Select your timezone
After select your timezone region
----------------------------
ls /usr/share/zoneinfo
cp /usr/share/zoneinfo/US/Pacific /etc/localtime
echo "US/Pacific" > /etc/timezone
----------------------------

* Configure your kernel
2 possibilities: Manual or Genkernel

* Manual Configuration Version *
----------------------------
emerge gentoo-sources
ls -l /usr/src/linux
emerge pciutils <-- for lspci: hardware detection
cd /usr/src/linux
make menuconfig

* Configure your kernel; assistance found on Gentoo's website

* Compile your manual config kernel
After completion, write down your kernel name (for bootloader)
----------------------------
make && make modules_install
----------------------------

* Install the manual config kernel
----------------------------
cp arch/x86/bzImage /boot/kernel-3.3.8-gentoo <-- insert your kernel name

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

* Genkernel Version *
----------------------------
emerge gentoo-sources
emerge genkernel
genkernel all
ls /boot/kernel* /boot/initramfs* (for bootloader)
----------------------------

* Create fstab
defaults: rw, suid, dev, exec, auto, nouser, async
----------------------------
nano /etc/fstab
----------------------------

Based upon my partitioning scheme, here's my fstab
                                           FS
device        mount point       type       mount options       dump | fsck
--------------------------------------------------------------------
/dev/sda1     /boot                 ext4       defaults,noatime              1 2
/dev/sda2     none                  swap     sw                                  0 0
/dev/sda3     /                        ext4      defaults,noatime               0 1
/dev/sda5     /home                ext4      defaults,noatime               0 2
/dev/cdrom   /mnt/cdrom       auto       noauto,ro,user                 0 0 
--------------------------------------------------------------------

* Configure hostname
----------------------------
nano /etc/conf.d/hostname
hostname="gentoo-node"
----------------------------

* Configure network
----------------------------
nano /etc/conf.d/net
config_eth0="dhcp" <-- add into net
----------------------------

For automatically starting at boot
----------------------------
cd /etc/init.d
ln -s net.lo net.eth0
rc-update add net.eth0 default
----------------------------

* Change root password
----------------------------
passwd
----------------------------

* Optional: Add users; make sure wheel group is added for su access
* m: create home directory
* G: group listing
----------------------------
useradd -m -G users,wheel
----------------------------

* Confirm clock/date; Install optional system logger, etc ...

* Install bootloader (GRUB)
Skip if not in a VM and have another bootloader installed (Fedora, Ubuntu, etc)
----------------------------
emerge grub
nano /boot/grub/grub.conf
----------------------------

My grub.conf - manual config kernel
(hd0,0): (hard drive letter, device number)
Example: (hd0,0) translates to hard drive 1, /dev/sda1
----------------------------
default 0
timeout 30
splashimage=(hd0,0)/grub/splash.xpm.gz

# My Gentoo
title Gentoo 3.3.8
root (hd0,0)
kernel /boot/kernel-3.3.8-gentoo root=/dev/sda3
----------------------------

My grub.conf (based upon genkernel
----------------------------
default 0
timeout 30
splashimage=(hd0,0)/grub/splash.xpm.gz

# My Gentoo
title Gentoo 3.3.8
root (hd0,0)
kernel /boot/kernel-genkernel-x86-3.3.8-gentoo real_root=/dev/sda3
initrd /boot/initramfs-genkernel-x86-3.3.8-gentoo
----------------------------

* Install GRUB
----------------------------
grep -v rootfs /proc/mounts > /etc/mtab
grub-install --no-floppy /dev/sda (if no other Linux/UNIX distribution is installed yet)
----------------------------

* Exit, unmount FS's, and SHUTDOWN (or REBOOT)
Exit out of chroot environment, umount fs's, and shutdown the system.
** I'm installing inside a VM, with the ISO image mounted. To avoid errors, shut system down, and unmount the ISO image.**
----------------------------
exit
cd
/sbin/shutdown -h now ( or reboot)
----------------------------