젠투(Gentoo) 리눅스는 직접 소스 컴파일 하여 하드웨어에 가장 알맞게 최적화를 시키기에 좋은 배포판입니다.
(그만큼 삽질을 많이 한다는.. 사실.. 컴파일 시간에 질리는 거죠..)
이 글은 젠투(Gentoo) 리눅스의 Stage3 설치 방식으로 진행합니다.

국내 미러 사이트에서 Gentoo Livecd를 다운로드하고 시디 버닝을 합니다.

ftp://ftp.daum.net/gentoo/releases/x86/current-iso/

– 원격 설치 설정
Gentoo Livecd 로 부팅이 된 화면입니다.

원격 설치를 위해 네트워크 설정을 합니다.

livecd ~ # net-setup eth0

인터페이스 정보 화면이며 Yes를 눌러 넘어갑니다.

네트워크 설정 화면에서 자신의 환경이 무선, 유선임에 따라 적절히 선택하고 넘어갑니다.

유선 네트워크로 설정시 TCP/IP 설정 화면이 나옵니다. 2번을 눌러 고정 아이피로 설정 해줍니다.

고정 아이피를 적어줍니다.

브로드 케스트 주소를 적어줍니다.

넷마스크를 적어줍니다.

기본 게이트웨이를 적어줍니다.

DNS 서버 아이피를 적어줍니다.

DNS 쿼리시 찾을 도메인을 적어줍니다.

 

원격으로 설치하기 위해 ssh 데몬을 시작합니다.

livecd ~ # /etc/init.d/sshd start

원격 접속에 필요한 루트 비밀번호를 설정 해줍니다.

livecd ~ # passwd root
New password:
Retype new password:
passwd: password updated successfully

PuTTY, SecureCRT 와 같은 프로그램으로 젠투 서버에 원격으로 로그인 합니다.

– 파티션 설정
현재의 디스크를 살펴봅니다. 200기가 정도 있군요..

livecd ~ # fdisk -l

Disk /dev/sda: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/sda doesn’t contain a valid partition table

루트 파티션과 스왑 파티션을 적절히 나눠 줍니다.

livecd ~ # fdisk /dev/sda

The number of cylinders for this disk is set to 26108.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-26108, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-26108, default 26108): 25084

스왑 파티션을 만들어 줍니다.

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (25085-26108, default 25085):
Using default value 25085
Last cylinder, +cylinders or +size{K,M,G} (25085-26108, default 26108):
Using default value 26108

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 82
Changed system type of partition 2 to 82 (Linux swap / Solaris)

스왑 파티션은 82번 입니다.

만든 파티션을 확인 합니다.

Command (m for help): p

Disk /dev/sda: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x20a0619f

Device Boot Start End Blocks Id System
/dev/sda1 1 25084 201487198+ 83 Linux
/dev/sda2 25085 26108 8225280 82 Linux swap / Solaris

위에 설정들을 저장하고 빠져 나옵니다.

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

생성된 루트 파티션(/dev/sda1)을 ext3 파일 시스템으로 포멧합니다.

livecd ~ # mkfs -t ext3 /dev/sda1
mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
12599296 inodes, 50371799 blocks
2518589 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
1538 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

스왑 파티션(/dev/sda2)을 사용할수 있도록 생성 해줍니다.

livecd ~ # mkswap /dev/sda2
Setting up swapspace version 1, size = 8225276 KiB
no label, UUID=454fa1b3-76aa-40da-9e15-01bf0b7181df

스왑을 활성화 합니다.

livecd ~ # swapon /dev/sda2
livecd ~ # cat /proc/swaps
Filename Type Size Used Priority
/dev/sda2 partition 8225272 0 -1

– Stage3 설치
/mnt/gentoo 를 마운트 합니다.

livecd ~ # mount /dev/sda1 /mnt/gentoo
livecd ~ # mkdir /mnt/gentoo/boot
livecd ~ # mount /dev/sda1 /mnt/gentoo/boot
livecd ~ # cd /mnt/gentoo

국내 미러 사이트에서 Stage3 을 다운로드 합니다.

livecd gentoo # wget \
ftp://ftp.daum.net/gentoo/releases/x86/current-stage3/stage3-i686-20091229.tar.bz2

Stage3 을 압축을 풀어줍니다.

livecd gentoo # tar xjvf stage3-i686-20091229.tar.bz2

proc를 사용할수 있도록 마운트 해줍니다.

livecd gentoo # mount -t proc proc /mnt/gentoo/proc
livecd gentoo # mount | grep /mnt/gentoo/proc
proc on /mnt/gentoo/proc type proc (rw)

– 미러 설정
Gentoo 리눅스는 미러서버를 통하여 패키지들을 받아오기 때문에 적당한 미러 서버를 선택 합니다.

livecd ~ # mirrorselect -i -o >> /mnt/gentoo/etc/make.conf


– chroot 진입
설치될 파티션을 “/” 최상위 디렉토리로 변경하여 설치를 하도록 설정 해줍니다.

livecd ~ # cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
livecd ~ # chroot /mnt/gentoo /bin/bash
livecd / # env-update
>>> Regenerating /etc/ld.so.cache…
livecd / # source /etc/profile

– Portage 받기
Portage 스냅샷을 다운로드 받습니다.

livecd / # cd /usr
livecd usr # wget ftp://ftp.daum.net/gentoo/snapshots/portage-latest.tar.bz2
livecd usr # tar xjvf portage-latest.tar.bz2

– 최적화 설치 작업
사용자의 취향에 맞는 최적화 기능을 위해서 /etc/make.conf 파일을 아래와 같이 nano 에디터로 수정합니다.
(필요없는 분들은 안하셔도..)

livecd / # nano /etc/make.conf
CFLAGS=”-O2 -march=i686 -pipe”
CXXFLAGS=”-O2 -march=i686 -pipe”
CHOST=”i686-pc-linux-gnu”
LINGUAS=”en ko”
PORTDIR_OVERLAY=”/usr/portage”

GENTOO_MIRRORS=”ftp://ftp.daum.net/gentoo/ “

– 지역별 시간대 설정
기본 시간대는 GMT 기준으로 되어있으므로 아래와 같이 설정 해줍니다.

livecd / # echo ‘ko_KR UTF-8’ >> /etc/locale.gen
livecd / # echo ‘ko_KR.UTF-8 UTF-8’ >> /etc/locale.gen
livecd / # echo ‘ko_KR.EUC-KR EUC-KR’ >> /etc/locale.gen
livecd / # locale-gen
livecd / # cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime

livecd / # nano /etc/conf.d/clock
CLOCK=”UTC”
TIMEZONE=”Asia/Seoul”

– fstab 설정

livecd / # nano /etc/fstab

# <fs> <mountpoint> <type> <opts> <dump/pass>
/dev/sda1 / ext3 noatime 0 1
/dev/sda2 none swap sw 0 0
shm /dev/shm tmpfs nodev,nosuid,noexec 0 0


– 커널(Kernel) 설치
커널 설치는 genkernel 을 사용하여 컴파일 하는 방법과 소스를 다운받아 설치하는 방법이 있습니다.
처음 설치하시는 분들은 genkernel 을 사용하는 것이 더 맘편합니다.

– genkernel을 이용한 커널 설치

livecd / # emerge gentoo-sources
livecd / # emerge genkernel
livecd / # genkernel –menuconfig all

– 필요한 패키지 설치
필요한 패키지들을 설치 해줍니다.

– System 로그 데몬

livecd / # emerge syslog-ng
livecd / # rc-update add syslog-ng default

– cron 데몬 설치

livecd / # emerge vixie-cron
livecd / # rc-update add vixie-cron default

– reiserfsprogs 설치

livecd / #emerge reiserfsprogs

– Hotplug 설치

livecd / # emerge hotplug
livecd / # rc-update add hotplug default

– vim 에디터

livecd / # emerge vim

– cvs

livecd / # emerge cvs

– dhcpd

livecd / # emerge dhcpcd

부팅시 SSH 데몬이 자동 실행되도록 등록해줍니다.

livecd / # rc-update add sshd default

– 루트 비밀번호 설정
처음에 livecd 에서 설정한 루트 비밀번호와 다르므로 꼭 설정 해주셔야 합니다.

livecd / # passwd
New password:
Retype new password:
passwd: password updated successfully

– 호스트네임 설정

livecd / # echo ‘HOSTNAME=”ruo91″‘ > /etc/conf.d/hostname

– 네트워크 설정

livecd / # echo ‘dns_servers_eth0=”168.126.63.1 168.126.63.2″‘ >> /etc/conf.d/net
livecd / # echo ‘routes_eth0=”default via 192.168.0.1″‘ >> /etc/conf.d/net
livecd / # echo ‘config_eth0=”192.168.0.100 netmask 255.255.255.0″‘ >> /etc/conf.d/net
livecd / # cat /etc/conf.d/net
# This blank configuration will automatically use DHCP for any net.*
# scripts in /etc/init.d. To create a more complete configuration,
# please review /etc/conf.d/net.example and save your configuration
# in /etc/conf.d/net (this file :]!).
dns_servers_eth0=”168.126.63.1 168.126.63.2″
routes_eth0=”default via 192.168.0.1″
config_eth0=”192.168.0.100 netmask 255.255.255.0″

– 부트로더 설치

grub 설치

livecd / # emerge grub

livecd / # grub
grub> root (hd0,0)
grub> setup (hd0)
grub> quit


genkernel 로 커널 컴파일시 아래 예제 처럼 설정 해줍니다.

livecd / # vim /boot/grub/grub.conf
default 0
timeout 3
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
title Gentoo Linux 2.6.31-gentoo-r6
root (hd0,0)
kernel /kernel-genkernel-x86-2.6.31-gentoo-r6 root=/dev/sda1
initrd /initramfs-genkernel-x86-2.6.31-gentoo-r6

– 설치 마무리
모든 설정을 적용하고 마운트한 것들을 umount 과 재부팅을 해줍니다.

livecd / # etc-update
livecd / # exit
livecd / # cd /
livecd / # umount /mnt/gentoo/boot
livecd / # umount /mnt/gentoo/proc
livecd / # umount /mnt/gentoo
livecd / # reboot

참고
http://wiki.kldp.org/wiki.php/GentooInstall
http://www.gentoo.org/doc/en/gentoo-x86-quickinstall.xml