Questions about this topic? Sign up to ask in the talk tab.

Difference between revisions of "Gentoo Installation"

From NetSec
Jump to: navigation, search
(Kernel)
(Kernel)
Line 254: Line 254:
 
{{warning| <nowiki> DOUBLE CHECK THAT YOU ARE IN A CHROOT BEFORE
 
{{warning| <nowiki> DOUBLE CHECK THAT YOU ARE IN A CHROOT BEFORE
 
     DOING THIS! ls /mnt/gentoo should return FILE NOT
 
     DOING THIS! ls /mnt/gentoo should return FILE NOT
     FOUND, otherwise do the following. </nowiki>}}
+
     FOUND </nowiki>}}
 +
{{info| If ls /mnt/gentoo returns something other than file not found, do the following}}
 +
 
 +
    mount /dev/sda3 /mnt/gentoo
 +
 
 +
    mount /dev/sda1 /mnt/gentoo/boot
 +
 
 +
    swapon /dev/sda2
 +
 
 +
    mount -t proc none /mnt/gentoo/proc
 +
 
 +
    mount -o bind /dev /mnt/gentoo/dev
 +
 
 +
    chroot /mnt/gentoo /bin/bash --login
  
 
=Final Configurations=
 
=Final Configurations=

Revision as of 20:14, 25 November 2011

RPU0j.png You are viewing an article in progress. This entry is unfinished.
This article contains too little information, it should be expanded or updated.
Things you can do to help:
  • add more content.
  • update current content.
RPU0j.png You are viewing an article in progress. This entry is unfinished.



Gentoo is a source-based linux distribution.source-based means every application is compiled locally.

You can download a copy of gentoo Here

To install gentoo you will need to create a bootable LiveCD or LiveUSB.

There are many ways one could create a LiveCD or LiveUSB, but that is outside of the scope of Gentoo Installation


Virtual Machine Setup

If you want to set up Gentoo within a virtual machine you will need at least:

  • Around 512MB to 1GB of RAM
  • At least 10GB HDD
  • Networking features enabled

And preferably multiple cores on an x86_64 processor



Hard Drive Setup

  ls /dev | grep sd
  cfdisk /dev/sda


cfdisk will then bring you into an ncurses gui.

Use cfdisk to:

  1. Create 100MB Partition Bootable at the Beginning
  2. Create 2048MB Partition at the beginning
  3. Create remaining free space partition at the beginning


Choose to Write tables to disk, and then exit.



mkfs.ext2 /dev/sda1
mkswap /dev/sda2
mkfs.reiserfs /dev/sda3
mount -t reiserfs /dev/sda3 /mnt/gentoo ; cd /mnt/gentoo
wget http://gentoo.arcticnetwork.ca/releases/x86/current-stage3/stage3-i686-20110614.tar.bz2

for the below line, you can simply press the TAB button after stage3 and it will automatically complete the command, just press enter to confirm it

tar xvpjf stage3*
swapon /dev/sda2
cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf

Okay, now you've set up your hard drives, downloaded a copy of gentoo on your live environment, and copied resolv.conf over. Before continuing make sure you can access the internet.

you can test this by pinging google:

ping -c 2 google.com

if it isn't working, try the following:

c3el4.png you might need to do this each time you reboot
   
    ifconfig eth0 down && ifconfig eth0 up
    dhcpcd eth0



Base installation and Configuration

RPU0j.png Remember the number in the output of this command, you will need it later.
grep -ci "processor" /proc/cpuinfo

Download & Extract portage to /mnt/gentoo/usr/

   cd /mnt/gentoo/usr/
   wget http://gentoo.arcticnetwork.ca/releases/snapshots/current/portage-latest.tar.bz2
   tar xvjf portage-latest.tar.bz2

Open make.conf in nano.

   cd /mnt/gentoo/etc/
   nano make.conf


Modify make.conf as follows:

RPU0j.png Do not modify the CHOST, this will cause problems!
 CFLAGS="-fstack-protector-all -fforce-addr -Os -pipe -march=native"
    CXXFlags="${CFLAGS}"


    FEATURES="metadata-transfer sandbox candy parallel-fetch"

    USE="gtk truetype postgres freetype jpg jpeg png gif imap ttf winscp passwd scp X gnutls mysql v4l2 extras lisp threads ithreads acpi bash-completion bzip2 crypt cracklib css ctype apache2 curl curlwrappers dbus encode ftp gcj gd geoip udev ipv6 lua ncurses nsplugin python readline sockets socks5 sqlite sse sse2 ssl suid unicode vim-syntax xml php perlsuid"

    #Replace Y with the output of the grep command and X with the returned number +1. For one core, you'd have "--jobs=1" and "-j2".

    MAKEOPTS="-jX -s"
#   Only use the below line if you have a multicore CPU or multiple processors
#   EMERGE_DEFAULT_OPTS="--jobs=Y --load-average=1.5"
    PORTAGE_NICENESS="12"

    





CHROOT

c3el4.png You will have to return to this part each time you reboot until the installation is finished.


   mount /dev/sda3 /mnt/gentoo
   swapon /dev/sda2
   mount /dev/sda1 /mnt/gentoo/boot
   mount -o bind /dev /mnt/gentoo/dev
   mount -t proc none /mnt/gentoo/proc
   chroot /mnt/gentoo /bin/bash --login

You only need to run gcc-config the first time around.

   gcc-config 1 
   env-update

The following line helps remember where you are.

   export PS1="chroot) $PS1"

Installing Software

This requires a working internet connection, test your connection with ping:

 ping -c 2 google.com

If you cannot ping, try issuing the following:

echo nameserver 4.2.2.1 > /etc/resolv.conf
echo nameserver 4.2.2.2 >> /etc/resolv.conf

Sync your repos:

 emerge -q --sync

if it tells you that an update to portage is availible then do the following

 emerge -q portage

otherwise, continue from here:

   emerge -q axel

Let's edit make.conf again:


   nano -w /etc/make.conf
   # put this at the bottom of make.conf
   FETCHCOMMAND="/usr/bin/axel -n 8 -o /\${DISTDIR}/\${FILE} -a \${URI}"
   RESUMECOMMAND="/usr/bin/axel -n 8 -o /\${DISTDIR}/\${FILE} -a \${URI}"
   # ^x Y Enterto save and quit


Now that you're package manager is set up, execute the following command:

   emerge -qN pciutils coreutils baselayout hardened-sources world

Encrypted Home Dir

create /crypt/ directory to store home.dm

   mkdir /crypt
   touch /crypt/home.dm

Install cryptsetup

   echo "sys-fs/cryptsetup static-libs" >> /etc/portage/package.use
   emerge -q cryptsetup


replace XXX in the command below with the size in GB (Gigabytes) you want your home to be. if you are not sure, run 'df -h' and use perhaps a quarter of the size of sda3

   dd if=/dev/zero of=/crypt/home.dm bs=1024 count=$(head -1 /etc/make.conf|awk '{print XXX * 1024^2}')


   losetup /dev/loop1 /crypt/home.dm
   cryptsetup luksFormat -h whirlpool -c blowfish /dev/loop1
   cryptsetup luksOpen /dev/loop1 home
   emerge -q reiserfsprogs
   mkfs.reiserfs /dev/mapper/home
   mount -o loop /dev/mapper/home /home

open /etc/init.d/home in nano: nano /etc/init.d/home


make the file look like this:


   #########
   #!/sbin/runscript
   # Copyright 1999-2011 Gentoo Foundation
   # Distributed under the terms of the GNU General Public License v2
   # $Header: $
   depend() {
   true
   }
   start() {
   losetup /dev/loop1 /crypt/home.dm
   cryptsetup luksOpen /dev/loop1 home
   mount -o loop /dev/mapper/home /home
   }
   stop() {
   umount /home
   cryptsetup luksClose home
   losetup -d /dev/loop1
   }
   restart() {
   stop
   start
   }
   ##########


Once you're done with that:

   chmod +x /etc/init.d/home
   rc-update add home default

Kernel

RPU0j.png DOUBLE CHECK THAT YOU ARE IN A CHROOT BEFORE DOING THIS! ls /mnt/gentoo should return FILE NOT FOUND
c3el4.png If ls /mnt/gentoo returns something other than file not found, do the following
   mount /dev/sda3 /mnt/gentoo
   mount /dev/sda1 /mnt/gentoo/boot
   swapon /dev/sda2
   mount -t proc none /mnt/gentoo/proc
   mount -o bind /dev /mnt/gentoo/dev
   chroot /mnt/gentoo /bin/bash --login

Final Configurations

Bootloader

xserver

BASH

Screen

Services

Network Services

Debugging Services

Permissions and Security Basics

Getting Help

Troubleshooting