gentoo install x86 btrfs

this as a quick start guide to the much longer and more comprehensive gentoo handbook. but please understand what i have done, and not blindly copy. you should definitely read the gentoo install handbook a few times before even attempting an install.

x86 install handbook: wiki.gentoo.org/wiki/handbook:x86
alternative install: wiki.gentoo.org/wiki/installation_alternatives
download: distfiles.gentoo.org/releases/x86/autobuilds/current-install-x86-minimal
sysresccd: sysresccd.org

i'll quickly run through the various handbook sections, and how i adapted those.

install media

gentoo suggests install from bootcd, and also offers many alternatives. i'm most impressed by the wildly flexible options available, and documented!

i have a sysresccd usb bootable. so i skip the download/create bootcd.

sysresccd startx, networkmanager, midori.. open new tabs with this page and gentoo handbook. keep them handy during the installation.

partitions

i don't usually use swap. anything that is a memory hogger is either tolerated, or purged off asap. i'm always looking for smaller applications to replace whatever i currently use. any more features than i use is bloatware.

i used to have /tmp on a dedicated partition. now i just use tmpfs, or a raw file if need be.

i have a large btrfs data partition, and i wanted to add another subvolume for gentoo. but i had second thoughts, as this was to be my first time with gentoo, and i didn't want accidents with existing data.

i created another btrfs partition, with two subvolumes - @gentoo32 and @home. if this works and is stable, i can send these subvolumes to my main btrfs partition.

sysresccd has /mnt/gentoo. if not, we create that directory for our gentoo root.

# mkdir -p /mnt/gentoo/
# mount -L gentoo -o subvol=@gentoo32 /mnt/gentoo

gentoo stage3

$ date

now we are ready for gentoo stage3, which we download from the above link, verify, and extract.
# sha512sum -c stage3-*.tar.bz2.DIGESTS
# tar --numeric-owner --xattrs -xvapf stage3-*.tar.bz2 -C /mnt/gentoo

filesystems

physical filesystems
# mount -L gentoo -o subvol=@home /mnt/gentoo/home

psuedo filesytems
# mount -o bind /proc /mnt/gentoo/proc
# mount --rbind /sys /mnt/gentoo/sys
# mount --make-rslave /mnt/gentoo/sys
# mount --rbind /dev /mnt/gentoo/dev
# mount --make-rslave /mnt/gentoo/dev

gentoo handbook says "--make-rslave operations are needed for systemd support later". if so, we probably don't need these.

on non-gentoo install media, check /dev/shm and /run/shm
$ ls -lhid /dev/shm /run/shm
$ mount | grep shm

links outside chroot become invalid. making /dev/shm/ a proper tmpfs mount can fix this.
# rm /dev/shm && mkdir /dev/shm
# mount -t tmpfs -o nosuid,nodev,noexec shm /dev/shm
# chmod 1777 /dev/shm
# mount --rbind /run/shm /mnt/gentoo/run/shm

# cp -L /etc/resolv.conf /mnt/gentoo/etc/

enter the chroot

# chroot /mnt/gentoo /bin/bash
# source /etc/profile
# export PS1="(chroot) $PS1"

i prefer busybox vi
# ln -s /bin/busybox /usr/local/bin/vi

portage
http://wiki.gentoo.org/wiki/Handbook:X86/Working/Portage

# mirrorselect -i -o >>/etc/portage/make.conf

# vi /etc/portage/make.conf
ref: make.conf.example / gentoo wiki

CFLAGS
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="${CFLAGS}"

MAKEOPTS
MAKEOPTS="-j2"

install portage snapshot
# emerge-webrsync

/usr/portage is created on first run. ignore those errors.

sync is not necessary, as portage is not updated more than once a day.
# emerge --sync --quiet --verbose

--quiet is faster, and quieter ;)
--verbose tells you what is happening
in this case, use both together ;) as they mean different things in gentoo

always keep up with the news
$ man news.eselect
$ eselect news list
$ eselect news read [number]

profiles
# eselect profile list

Available profile symlink targets:
  [1]   default/linux/x86/13.0 *
  [2]   default/linux/x86/13.0/desktop
  [3]   default/linux/x86/13.0/desktop/gnome
  [4]   default/linux/x86/13.0/desktop/kde

do yourself a favour, and select [1] the default.

i thought i was smart, and chose [2] desktop, which changed subsequently on it's own, due to something i changed somewhere else. i ended up with quite a lot of bloatware, which in itself is not so much a problem, if i didn't have to wait around half the day for all that lot to be compiled all over again :/ and then i had another issue wondering how to get rid of all that extra bloat.

# eselect profile set 1

keep checking your profile occassionally!

USE
this is the bit which gave me the most headache.. even changing my profile without me knowing about it. choose wisely!

full description of available use flags
$ less /usr/portage/profiles/use.desc
http://gentoo.org/support/use-flags

currently active use flags are a combination of your profile and configured flags in make.conf

$ emerge --info | grep ^USE

$ grep USE /etc/portage/make.conf

keep it default or ignore, till you understand a bit more..
USE=""
USE="-debug -gnome -systemd "

once you understand it, ignore defaults and manage it specifically. but not yet!
USE="-* unicode"

systemd
http://wiki.gentoo.org/wiki/Gentoo_Without_systemd
"Masking udev will not result in a broken system; Portage is smart enough to automatically replace udev by sys-fs/eudev: the systemd-free fork of udev."

i don't want systemd. so i do both.

block:
vi /etc/portage/make.conf
USE="-systemd"

mask:
vi /etc/portage/package.mask/systemd
sys-apps/systemd
sys-fs/udev

timezone

$ ls /usr/share/zoneinfo
# echo "Europe/London" >/etc/timezone
# emerge --config sys-libs/timezone-data

i prefer
# ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime

locales

vi /etc/locale.gen
en_GB.UTF-8 UTF-8

you can have more than one locales. each on separate lines. ensure at least one is utf-8.

# locale-gen
# locale -a
# eselect locale list
# eselect locale set {number}

$ cat /etc/env.d/02locale

reload environment, after any changes
$ env-update && source /etc/profile

kernel

no kernel is installed by default. make and install your own kernel.
ref: gentoo kernel compile

fstab
# vi /etc/fstab

networking
we will use gentoo netifrc method

# emerge --search netifrc

identify network interface, and autostart after boot.
ip link
# ln -s /etc/init.d/net.{lo,eth0}
# rc-update add net.eth0 default

busybox/udhcpc will be used automatically.

# vi /etc/conf.d/hostname
hostname="{localhostname}"

# vi /etc/hosts
127.0.0.1 localhostname.local.domain.name localhost

root passwd
# passwd

init/boot conf
# vi /etc/rc.conf
# vi /etc/conf.d/keymaps

misc
# emerge --ask sys-fs/btrfs-progs
# rc-update add sshd default

bootloader
whew! final stage.. before you can reboot.. into your shiny new gentoo :)

lilo or syslinux or grub2.. ordered by bloatware factor exponentially!

lilo is the most efficient, but doesn't understand btrfs :(
# emerge --ask sys-boot/lilo
# vi /etc/lilo.conf
# /sbin/lilo

extlinux is my preferred choice, but doesn't understand btrfs subvolumes/compression :(
# emerge --ask sys-boot/syslinux
# mkdir /boot/extlinux
# extlinux --install /boot/extlinux
# ln -snf . /boot/boot

# cd /usr/share/syslinux
# cp menu.c32 memdisk libcom32.c32 libutil.c32 /boot/extlinux/
i prefer ln -s, as it keeps up with any system updates.
# ln-s /usr/share/syslinux/{menu.c32,memdisk,libcom32.c32,libutil.c32} /boot/extlinux/

# vi /boot/extlinux/extlinux.conf

note: extlinux expects /boot on the root subvolume.
# mount -o bind /@gentoo32/boot /boot

grub2 is the biggest & most complicated beast.. my last preference. if you ever need to troubleshoot, you'll cry.. :'(
# emerge --ask sys-boot/grub
# grub2-install /dev/{partition}
# grub2-mkconfig -o /boot/grub/grub.cfg

the end
you could just ctrl+alt+del. a stable system would sync to disk, umount all filesystems, before calling reboot.
or be safe..

exit chroot
# exit

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


update: i successfully managed to prune this install path quite significantly. see my latest post: gentoo second install x86 btrfs debian

No comments:

Post a Comment

most viewed