2015年8月3日 星期一

[Linux][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


0. Start ssh Daemon
set password of root
passwd

Start ssh daemon
/etc/init.d/sshd start

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       63019008  79796223 16777216   8G 83 Linux
/dev/sda4       79796224 167772159 87975936  42G 83 Linux
set dev1 as boot sector

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

sda1 (/mnt/boot)
mkfs -t ext2 /dev/sda1

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

mkswap /dev/sda3
swapon /dev/sda3 

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

df -hT

Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs   10M  4.0K   10M   1% /dev
tmpfs          tmpfs     500M   61M  440M  13% /
/dev/loop0     squashfs  186M  186M     0 100% /mnt/livecd
/dev/sr0       iso9660   215M  215M     0 100% /mnt/cdrom
tmpfs          tmpfs     101M  432K  100M   1% /run
shm            tmpfs     500M     0  500M   0% /dev/shm
cgroup_root    tmpfs      10M     0   10M   0% /sys/fs/cgroup
tmpfs          tmpfs     500M     0  500M   0% /mnt/livecd/usr/portage
/dev/sda2      ext4       30G   44M   28G   1% /mnt/gentoo
/dev/sda1      vfat       50M     0   50M   0% /mnt/gentoo/boot
/dev/sda4      ext4       42G   48M   40G   1% /mnt/gentoo/data


Install gentoo flow :
Download stage3 & portage -->
Compile kernel & Install kernel -->
Install bootload & settings

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

update enviroment
source /etc/profile (Load environment settings)
env-update (Collect all so file location into one file was called /etc/ld.so.cache)
If env-update can't find or execute.
Please add execute file path into $PATH. (ex: PATH=/bin;/usr/sbin/:$PATH)

make sure in chroot enviroment
export PS1="(chroot) $PS1"

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

Kernel :
Method 1 by tools
Get kernel source 
# 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

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



# nano -w /etc/fstab
/dev/sda1               /boot           ext4            noauto,noatime  1 2
/dev/sda2               /                  ext4            defaults               0 1
/dev/sda3               none            swap            sw                     0 0


Support different language
# nano -w /etc/locale.gen
Add Following string into the file.
zh_TW.UTF-8 UTF-8
zh_TW BIG5
If don't know string
locale -a

Generate locales based language
# locale-gen

enviroment update
env-update && source /etc/profile && export PS1="(chroot) $PS1"

bootload
emerge sys-boot/grub:2

# grub-install --target=i386-pc --grub-setup=/bin/true --debug /dev/sda --debug [Ref:GRUB]
How do we know the platform.
ls /usr/lib/grub/

grub2-mkconfig -o /boot/grub/grub.cfg

Install dhcp client tool
emerge net-misc/dhcpcd

Add user
useradd -m xxxx
passwd xxxx

passwd root



Display manager (Login manager)
emerge lxde-base/lxdm

start LXDE display manager
Type "lxdm" then start it.

Reference:
Youtube

Note :


(chroot) livecd linux # eselect  profile list
(chroot) livecd linux # eselect  profile set 4
make sure again
(chroot) livecd linux # eselect  profile list

Update mirror site
mirrorselect -i -o >> /mnt/gentoo/etc/make.conf
Please choose the header is http
mirrorselect -i -r -o >> /mnt/gentoo/etc/make.conf 

Edit hostname
nano -w /etc/conf.d/hostname
nano -w /etc/hosts

keyboard type
nano -w /etc/conf.d/keymaps

System clock
nano -w /etc/conf.d/hwclock

0 意見:

張貼留言