2016年5月28日 星期六

[Gentoo] How to install Gentoo OS

Build bootable live USB driver

Using Archlinux iso to make live USB driver more quickly.
And use live USB driver to install gentoo OS.

Prepare :
1. Download image
Mirro 1: Arch Linux Downloads - ISO
Mirro 2: Arch Linux Downloads - ISO
Download archlinux-2015.02.01-dual.iso

2. dd into usb flash
dd bs=4M if=/path/to/archlinux-2015.02.01-dual.iso of=/dev/sdx && sync



1. Design the partition of disk
Type: gdisk /dev/sda
Type: o //This will create a new empty GUID partition table and destroy all your data and overwrite existing partitions

Set /dev/sda1 as "EFI" system[Ref]
Hex code or GUID (L to show codes, Enter = 8300): EF00

Device     Boot    Start       End  Sectors Size Id Type
/dev/sda1  *        2048    104447   102400  100M 83 Linux
/dev/sda2         104448  63019007 62914560  30G 83 Linux
/dev/sda3       79796224 167772159 87975936  42G 83 Linux
set /dev/sda1 as boot sector

Explain:
sda1 (/mnt/boot)
mkfs -t fat /dev/sda1

sda2 (/mnt/)
mkfs -t ext4 /dev/sda2

sda4 (/mnt/data)
mkfs -t ext3 /dev/sda4

mkdir /mnt/gentoo
mount /dev/sda2 /mnt/gentoo
mkdir /mnt/gentoo/boot
mkdir /mnt/gentoo/data
mount /dev/sda1 /mnt/gentoo/boot
mount /dev/sda3 /mnt/gentoo/data

Download package
Download stage & portage from https://www.gentoo.org/main/en/mirrors.xml
release :
releases/amd64/autobuilds/20151001/stage3-amd64-20151001.tar.bz2
portage :
snapshots/portage-latest.tar.bz2
Store hyperlink into file and execute following command will start to download file under command line.

cat /tmp/stage3-amd64 | xargs wget
After download file
tar mxvf stage3-amd64-20150730.tar.bz2 -C /mnt/gentoo 
tar mxvf portage-20150804.tar.xz       -C /mnt/gentoo/usr/  (portage include all linux package)

Mount environment equipment
# mount -t proc none /mnt/gentoo/proc/
# mount  --rbind /dev/ /mnt/gentoo/dev/    (must use --rbind)
# mount  --rbind /sys/ /mnt/gentoo/sys/

Copy DNS query list
# cp /etc/resolv.conf /mnt/gentoo/etc/

Switch to /mnt/gentoo
# chroot /mnt/gentoo /bin/bash

Set env path
# source /etc/profile

Install Terminal multiplexer
# emerge app-misc/tmux

Kernel :
Get kernel source.
Must have kernel source in the OS. Otherwise can't compile other software.
# emerge sys-kernel/gentoo-sources

genkernel is a tool created by Gentoo used to automate the build process of the kernel and initramfs
# emerge genkernel (Gentoo automatic kernel building scripts)

Compile kerner for system (must install sys-kernel/gentoo-sources, otherwise can't work)
# genkernel all (i5 around 51 min)

Using genkernel can create initramfs under /boot.
# genkernel --install initramfs


Copy DNS query list
cp /etc/resolv.conf /mnt/gentoo/etc/

Create fstab into /mnt/
genfstab -U -p /mnt/gentoo >> /mnt/gentoo/etc/fstab

Switch to /mnt/gentoo
# chroot /mnt/gentoo /bin/bash

update enviroment
source /etc/profile (Load environment settings)
env-update (Collect all so file location into one file was called /etc/ld.so.cache)

Update localtime - Choose TimeZone area
cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime
echo "Asia/Taipei" >> /etc/timezone

Support different language
# nano -w /etc/locale.gen
Add Following string into the file.
en_US.UTF-8 UTF-8
zh_TW.UTF-8 UTF-8
zh_TW BIG5

Generate locales based language
# locale-gen
Install bzip2 at the first which was need by other software.
This package will decompress.
emerge bzip2


Install and configure a bootloader

gummiboot install (Sometime can't booting, do this command again)
For the moment, sys-boot/gummiboot is still in ~arch so needs to be added to the /etc/portage/package.accept_keywords first:

# mkdir -p /etc/portage/package.accept_keywords
# echo "sys-boot/gummiboot" >> /etc/portage/package.accept_keywords/efi

Next, install the sys-boot/gummiboot package:
# emerge --ask sys-boot/gummiboot

Create bootload into the folder of boot
# gummiboot --path /boot install
gummiboot will create following file.

EFI  
initramfs-genkernel-x86_64-4.4.6-gentoo  
kernel-genkernel-x86_64-4.4.6-gentoo  
loader  
System.map-genkernel-x86_64-4.4.6-gentoo

No need to type so much word.
# ls -al > /boot/loader/entries/gentoo.conf

nano /boot/loader/entries/gentoo.conf
title Gentoo Linux  (Title name need the same)
initrd /initramfs-genkernel-x86_64-4.4.6-gentoo (Init image)
linux /kernel-genkernel-x86_64-4.4.6-gentoo  (Kernel image)
options root=/dev/sdaX rw  (X = root filesystem)

Please note options must have s, and X of sdaX must be changed.

Change root password
passwd root

Install Xorg-X11 (X server)

eselect profile list

Available profile symlink targets:
[1] default/linux/amd64/13.0 *
[2] default/linux/amd64/13.0/selinux
[3] default/linux/amd64/13.0/desktop
[4] default/linux/amd64/13.0/desktop/gnome
[5] default/linux/amd64/13.0/desktop/kde
[6] default/linux/amd64/13.0/developer
[7] default/linux/amd64/13.0/no-multilib
[8] default/linux/amd64/13.0/server
[9] hardened/linux/amd64
eselect profile set 3

Installing  X server

emerge -pv lightdm-gtk-greeter xorg-x11 (-pv simply display what would have been installed)
### if want install lxde
### emerge lxde-meta # emerge lightdm-gtk-greeter xorg-x11(Install)
After install above package, then execute startx need following package.
# emerge twm xclock xterm


Install x server (Xorg-X11) and x client (cinnamon) at the same time.
# USE="icu pulseaudio gnome-keyring" emerge lightdm-gtk-greeter xorg-x11 twm xclock xterm cinnamon
[Gentoo] How to install cinnamon

Using lightdm as the login manager

nano /etc/conf.d/xdm

DISPLAYMANAGER=”lightdm”

[Gentoo] Login function by using lightdm


emerge sudo
nano /etc/sudoers
add following string ALL=(ALL) ALL # This string can sudo to root privilige
[Gentoo] The package need by gentoo os which reinstall it


More work need to do :


Backup OS
tar czvvf gentoo.tgz / --exclude=/boot --exclude=/home --exclude=/tmp --exclude=/lost+found --exclude=/usr/portage
sudo tar czvvf gentoo_boot_portage_cinnamon.tgz / --exclude={"/home","/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"}

RefFull system backup with rsync
[Gentoo] How to backup gentoo os

Backup Package
[Gentoo] How to backup package

Reference:

Picture:

Other Note:

0 意見:

張貼留言