Installing Hardened uClibc Gentoo LinuxBootstrap (Stage1 => Stage2)Partition Drive

Allocate 25MB boot partition; 4GB Swap; 40GB Linux; rest (~15GB) for Windows

fdisk /dev/hda# Device Boot Start End Blocks Id System# /dev/hda1 1 4 32098+ 83 Linux# /dev/hda2 5 491 3911827+ 82 Linux swap / Solaris# /dev/hda3 492 5355 39070080 83 Linux# /dev/hda4 5356 7296 15591082+ 7 HPFS/NTFSFormat Partitions

ext2 on /dev/hda1; swap on /dev/hda2; xfs on /dev/hda3

mkfs.ext2 /dev/hda1mkswap /dev/hda2swapon /dev/hda2mkfs.xfs /dev/hda3Start Networking

WiFi isn't working at this point - start ethernet (assumes DHCP)

/etc/init.d/net.eth1 startExtract Stage1 Tarball

Mount new partitions; locate tarball (hint: experimental/x86/embedded); extract it all over fresh partitions

mount /dev/hda3 /mnt/gentoocd /mnt/gentoomkdir bootmount /dev/hda1 bootwget -O- -q http://mirror.datapipe.net/gentoo/experimental/x86/embedded/stages/stage1-x86-uclibc-hardened-2005.0.tar.bz2 | tar xvjpMove into chrootcp /etc/resolv.conf etc/mount -o bind /proc procmount -o bind /dev devchroot .. /etc/profileenv-updateSync Portage Treeemerge --syncUpdate Profile

Use 2.6 profile instead of the default 2.4

cd /etcrm make.profileln -s ../usr/portage/profiles/uclibc/x86/hardened make.profileJack with make.conf

This is only for bootstrapping; with newer GCC this will be updated

## /etc/make.confUSE=""CFLAGS="-march=pentium3 -msse2 -Os -pipe -fomit-frame-pointer"CXXFLAGS="${CFLAGS}"CHOST="i686-gentoo-linux-uclibc"MAKEOPTS=-j1Use newer baselayout

Preference for newer init scripts

echo sys-apps/baselayout ~x86 >> /etc/portage/package.keywordsMask Portage-2.0.54-r1

Emerging empty system yields an endless loop. Problem is portage-2.0.54-r1; Mask package.

echo "=sys-apps/portage-2.0.54-r1" >> /etc/portage/package.maskStart Bootstrapcd /usr/portagescripts/bootstrap.shBase System (Stage2 => Stage3)Jack with make.conf

with newer GCC, update for further optimizations; start using USE

## /etc/make.confUSE="bzip2 truetype dri ssl userlocales uclibc-compat slang spell unicode pam X crypt gtk dlloader sse sse2 mmx xv opengl imlib gif jpeg mp3 png tiff"CFLAGS="-march=pentium-m -msse2 -Os -pipe -fomit-frame-pointer"CXXFLAGS="${CFLAGS}"CHOST="i686-gentoo-linux-uclibc"MAKEOPTS=-j1FEATURES="-sandbox"Drop dropbear in favor of full openSSH

I want my X forwarding... Just comment out virtual/ssh

## /usr/portage/profiles/uclibc/virtualsvirtual/libc sys-libs/uclibcvirtual/os-headers sys-kernel/linux-headersvirtual/linux-sources sys-kernel/vanilla-sources#virtual/ssh net-misc/dropbearvirtual/utempter sys-libs/libutempterBuild Stage3

Downloads uClibc locales file...

wget http://distfiles.gentoo.org/distfiles/uClibc-locale-030818.tgz -O /usr/portage/distfiles/uClibc-0.9.28-user-locale.tar.gzemerge -eav systemInstall Additional Packages

Use newer hardened kernel

echo sys-kernel/hardened-sources ~x86 >> /etc/portage/package.keywordsemerge -av grub metalog wireless-tools dhcpcd hardened-sources xfsprogsrc-update add metalog bootInstall Kernel

Download Fujitsu P7120 gentoo-2.6.16-hardened-r6 kernel config.

cd /usr/src/linuxwget http://jeremy.geeo.net/p7120/p7120-2.6.16-hardened-r6.config -O .configmake oldconfigmake && make modules_installcd arch/i386/bootcp bzImage /boot/bzImage-2.6.16-hardened-r6

Configure Grub

cd /bootln -s bzImage-2.6.16-hardened-r6 curr## /boot/grub/grub.conftimeout 3default 0fallback 1title Gentoo Linux root (hd0,0) kernel /boot/curr root=/dev/hda3title Windows XP Pro rootnoverify (hd0,3) makeactive chainloader +1Install WiFi Driversemerge -av ipw2200Configure Base System

Set root password; helps to be able to log in

passwd root

Autoload network modules at boot

echo ipw2200 >> /etc/modules.autoload.d/kernel-2.6echo 8139too >> /etc/modules.autoload.d/kernel-2.6

Update filesystem configuration

## /etc/fstab/dev/hda1 /boot ext2 noauto,noatime 1 1/dev/hda2 none swap sw 0 0/dev/hda3 / xfs noatime 0 0/dev/hda4 /mnt/ntfs ntfs noauto,noatime 0 0/dev/sr0 /mnt/cdrom iso9660 noauto,ro 0 0none /proc proc defaults 0 0none /dev/shm tmpfs defaults 0 0

Name it

## /etc/conf.d/hostnameHOSTNAME="fuji"Boot Shiny New Gentoo System (Stage3 => Stage4) [Expiremental From Here On]Install Modular X

Update portage package keywords - easier to just download

wget http://jeremy.geeo.net/p7120/p7120.package.keywords -O /etc/portage/package.keywords

Update portage first; apparently new xorg needs it. We even get to change compilers mid-stream.

emerge -av portageemerge -av xorg-x11gcc-config i686-gentoo-linux-uclibc-3.4.5-vanilla && . /etc/profileemerge -av xorg-x11gcc-config i686-gentoo-linux-uclibc-3.4.5 && . /etc/profileInstall Additional Packagesecho sys-apps/855resolution ~x86 >> /etc/portage/package.keywordsecho x11-wm/fluxbox ~x86 >> /etc/portage/package.keywordsemerge -av 855resolution hdparm fluxboxConfigure X

This isn't 100% working yet. X will start; but the resolution is still wrong.

Fixup video driver to allow 1280x768 resolution.

## /etc/conf.d/855resolutionreplace[0]="5c"with[0]="1280 768"rc-update add 855resolution default

Download xorg.conf.

cd /etc/X11wget http://jeremy.geeo.net/p7120/p7120.xorg.conf -O xorg.conf

Make fluxbox the default.

## /etc/rc.confUNICODE="yes"EDITOR="/bin/nano"XSESSION="fluxbox"Install Software [DON'T EXPECT THIS TO WORK!!]

Our basic system, doesn't do much; let's try for Firefox and Thunderbird. This requires mucking with the profile more.

Just comment out glib.

## /usr/portage/profiles/uclibc/packages...#<dev-libs/glib-2.5...

Change gettext to use virtual/libc

## /usr/portage/sys-devel/gettext/gettext-0.14.4.ebuild...DEPEND="|| ( virtual/libc dev-libs/libiconv )"...

Unmask iconv from USE

## /usr/portage/profiles/uclibc/use.mask...-iconv-nls...

Install latest Firefox and Thunderbird; after we update uclibc to use iconv.

echo www-client/mozilla-firefox ~x86 >> /etc/portage/package.keywordsecho mail-client/mozilla-thunderbird ~x86 >> /etc/portage/package.keywordsecho dev-libs/nss ~x86 >> /etc/portage/package.keywordsecho x11-plugins/enigmail ~x86 >> /etc/portage/package.keywordsecho sys-libs/uclibc iconv nls ipv6 >> /etc/portage/package.useecho www-client/mozilla-firefox ipv6 >> /etc/portage/package.useecho mail-client/mozilla-thunderbird ipv6 >> /etc/portage/package.useUSE=pregen FEATURES=-strict emerge -av dev-libs/libiconv uclibc gettextemerge -av mozilla-firefox mozilla-thunderbird