2012年10月13日 星期六

gentoo

用livedvd安裝:

按Esc回到boot:
/boot/gentoo root=/dev/ram0 init=/linuxrc initrd=/boot/gentoo.igz dokeymap aufs looptype=squashfs loop=/images.squashfs cdroot nomodeset
在命令後面加上 nox
/boot/gentoo root=/dev/ram0 init=/linuxrc initrd=/boot/gentoo.igz cdroot nomodeset nox



開機後:
第一步開啟sshd1:設網絡
    ifconfig eth0 xxx.xxx.xxx.xxx
    route add default gw xxx.xxx.xxx.xxx
2:設密碼
    passwd root
3:啟動 sshd 服務:
   /etc/init.d/sshd start
4:連putty
   echo nameserver 8.8.8.8 > /etc/resolv.conf
   echo nameserver 8.8.4.4 > /etc/resolv.conf
第二步格式化硬碟
1:利用cfdisk分區
   cfdisk /dev/sda
sda1做boot, sda2做swap, sda3做主要磁區,
--------------------------------------------------------------------
Name    Flags    Part Type    FS Type
---------------------------------------------------------------------
sda1      Boot      Primary       Linux            250MB
sda2                    Primary       Linux            700MB
sda3                    Primary       Linux
---------------------------------------------------------------------
2:格式化分區:
    mkfs.ext3 /dev/sda1
    mkswap /dev/sda2
    mkfs.ext4 /dev/sda3
3:啟動swap交換分區:
   swapon /dev/sda2
4:把sda3,sda1掛上
mount /dev/sda3 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot
5:開始複製LiveCD上的系統:
cp -apf  /mnt/static/* /mnt/gentoo/

cd /
cp -avx bin sbin lib lib32 lib64 boot usr opt emul etc root home var sys /mnt/gentoo/

mkdir /mnt/gentoo/proc /mnt/gentoo/dev
cd /mnt/gentoo/dev
mknod -m 660 console c 5 1
mknod -m 660 null c 1 3
mount -t proc none /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev

6:查uuid
 blkid 
會看到

/dev/sda1: UUID="2df87859-21a2-4412-a33a-1881f0dd5ece" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda2: UUID="8696720a-1c06-4940-b377-24167c5af002" TYPE="swap"
/dev/sda3: UUID="b92f275f-e0d0-4118-9ace-330c67e02f05" TYPE="ext4" 


改變uuid
tune2fs -U b92f275f-e0d0-4118-9ace-330c67e02f05 /dev/sda3


 7:把環境切換到硬盤
chroot /mnt/gentoo /bin/bash
env-update && source /etc/profile

8:修改硬盤 root 密碼
passwd root

9:從默認boot中移除啟動AutoConfig服務,否則您的root密碼是每次啟動時復位。
rc-update del autoconfig default

12:寫入下面的分區信息:
nano -w /etc/fstab
#/dev/sda1
UUID=41c22818-fbad-4da6-8196-c816df0b7aa8 /boot ext3 noauto,noatime 1 2
#/dev/sda2
UUID="8696720a-1c06-4940-b377-24167c5af002" none swap sw 0 0
#/dev/sda3
UUID="b92f275f-e0d0-4118-9ace-330c67e02f05" / ext4 defaults 0 1
/dev/cdrom /mnt/cdrom iso9660 noauto,ro 0 0
proc /proc proc defaults 0 0
shm /dev/shm tmpfs nodev,nosuid,noexec,size=128m 0 0


11:複製 kernel 到 /boot區
cp /usr/src/linux/System.map /boot/System.map
cp /usr/src/linux/arch/x86/boot/bzImage /boot/vmlinuz
genkernel ramdisk
 ln -s initramfs-genkernel-x86-3.3.0-gentoo initrd.img

11改開機選單nano -w  /boot/grub/grub.conf
//----------------------------------------
default 0
timeout 30
splashimahe=(hd0,0)/boot/grub/splash.xpm.gz
title neo-Gentoo-Linux
root (hd0,0)
search –no-floppy –fs-uuid –set b92f275f-e0d0-4118-9ace-330c67e02f05  #用sd3的uuid
kernel /boot/vmlinuz root=/dev/rm0 real_root=UUID=b92f275f-e0d0-4118-9ace-330c67e02f05 ramdisk_size=8192 vga=791 noxinitrd /boot/initrd.img
//----------------------------------------

10:安裝 grub 到 mbr
grub
root (hd0,0)
setup (hd0)
quit

13:設定時區,hostname
cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime
nano -w /etc/conf.d/hostnameHOSTNAME="GentooVM"

14:網路設定
nano -w /etc/conf.d/net
//----------------------------------
# DHCP config_eth0=( "dhcp" )  
# 使用CIDR形式表示的靜態IP 
config_eth0=( "192.168.0.7/24" ) 
routes_eth0=( "default via 192.168.0.1" ) 
# 使用netmask形式表示的靜態IP 
config_eth0=( "192.168.0.7 netmask 255.255.255.0" ) 
routes_eth0=( "default via 192.168.0.1" )
//---------------------------------- 
建立符號連接net.eth0指向net.lo 
# cd /etc/init.d 
# ln -s net.lo net.eth0
啟動和停止網絡腳本
# /etc/init.d/net.eth0 start
# /etc/init.d/net.eth0 stop
配置網絡接口以便在啟動的時候裝載它
# rc-update add net.eth0 default
 
15:加入sshd服務
rc-status確認有沒有開sshd
rc-update add sshd default

16:退出環境,重開機,退出光碟
exit
reboot

--------------------------------------------------------------------------------------------------------------------------------

minimal CD安裝:
 
可先檢查系統效能評估安裝時間 
# grep bogo /proc/cpuinfo
bogomips       : 3337.81
# hdparm -tT /dev/sda
/dev/sda:
 Timing cached reads:   1100 MB in  2.00 seconds = 549.97 MB/sec
 Timing buffered disk reads:  224 MB in  3.01 seconds =  74.36 MB/sec
# grep MemTotal /proc/meminfo
MemTotal:       509248 kB

開機後
boot: gentoo-nofb
 
檢查安裝模組
livecd root # lspci 
若有需要安裝的模組  
modprobe r8169
 
確認網卡模組
/usr/sbin/lspci | grep -i ethernet
底下是VM模組 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
USB controller: Intel Corporation 82371SB PIIX3 USB [Natoma/Triton II] (rev 01)
VGA compatible controller: Cirrus Logic GD 5446
Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 20)
Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01)
RAM memory: Red Hat, Inc Virtio memory balloon


 
 
第一步設定網路
撥接部份
pppoe-setup
pppoe-start
VPN部份
nano -w /etc/ppp/chap-secrets 
nano -w /etc/ppp/options.pptp 
# pptp <server ip> 
區網部份
net-setup eth0
 ifconfig eth0 xxx.xxx.xxx.xxx
 route add default gw xxx.xxx.xxx.xxx
 echo nameserver 8.8.8.8 > /etc/resolv.conf
 開啟sshd
passwd root
/etc/init.d/sshd start

第二步格式化硬碟
1:利用cfdisk分區
   cfdisk /dev/sda
sda1做boot, sda2做swap, sda3做主要磁區,
--------------------------------------------------------------------
Name    Flags    Part Type    FS Type
---------------------------------------------------------------------
sda1      Boot      Primary       Linux            250MB
sda2                    Primary       Linux            700MB
sda3                    Primary       Linux
---------------------------------------------------------------------
2:格式化分區:
    mkfs.ext3 /dev/sda1
    mkswap /dev/sda2
    mkfs.ext3 /dev/sda3
3:啟動swap交換分區:
   swapon /dev/sda2
4:把sda3,sda1掛上
mount /dev/sda3 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot

連上gentoo網站下載stage3

# links http://www.gentoo.org/main/en/mirrors.xml
cd /mnt/gentoo
wget ftp://gentoo.cs.nctu.edu.tw/gentoo/releases/x86/current-stage3/stage3-i686-*.tar.bz2
time tar xjpf stage3*
(解出bin dev etc home lib media mnt opt proc root run sbin sys tmp usr var)
cd /mnt/gentoo/usr
wget ftp://gentoo.cs.nctu.edu.tw/gentoo/snapshots/portage-latest.tar.bz2
time tar xjf portage-lat*
 (解出/mnt/gentoo/usr/portage)

掛上proc,dev跟切換磁碟
cd / 
mount -t proc proc /mnt/gentoo/proc
mount --rbind /dev /mnt/gentoo/dev
cp -L /etc/resolv.conf /mnt/gentoo/etc/
chroot /mnt/gentoo /bin/bash
env-update && source /etc/profile
 
設定hostname 
livecd / # cd /etc
livecd etc # echo "127.0.0.1 neo.at.neoplace neo localhost" > hosts
livecd etc # sed -i -e 's/hostname.*/hostname="neo"/' conf.d/hostname
(Use defined host name and check)
livecd etc # hostname neo
livecd etc # hostname -f
neo.at.neoplace
 

編譯內核安裝:
nano -w /etc/make.globals
GENTOO_MIRRORS="http://distfiles.gentoo.org/"改成 ftp://ftp.isu.edu.tw/pub/Linux/Gentoo/

for EPC
CFLAGS = "-0s -march=pentium-m -pipe -fno-ident -fomit-frame-pointer"  
其他
CFLAGS="-O2 -march=i686 -pipe"
# Use the same settings for both variables
CXXFLAGS="${CFLAGS}"
 

emerge --sync
emerge -av app-misc/screen
screen

emerge axel
nano -w /etc/make.globals
最後加上 
FETCHCOMMAND='/usr/bin/axel -a -S4 -o "\${DISTDIR}/\${FILE}" "\${URI}"'
RESUMECOMMAND="${FETCHCOMMAND}"

time emerge gentoo-sources 
(在/usr/src/linux裝source) 
cd /usr/src/linux
make menuconfig
time make -j2
make modules_install
cp /usr/src/linux/arch/x86/boot/bzImage /boot/kernel
cp arch/i386/boot/bzImage /boot/kernel 
建立initramfs檔   
emerge genkernel
genkernel --install --no-ramdisk-modules initramfs    

寫入下面的分區信息:
nano -w /etc/fstab
/dev/sda1 /boot ext3 noauto,noatime 1 2
/dev/sda2 none swap sw 0 0
/dev/sda3 / ext3 noatime 0 1
/dev/cdrom /mnt/cdrom iso9660 noauto,ro 0 0
proc /proc proc defaults 0 0
shm /dev/shm tmpfs nodev,nosuid,noexec,size=128m 0 0


安裝grub
time emerge grub
nano -w /boot/grub/grub.conf
//------------------------------------- 
default 0
timeout 10
splashimahe=(hd0,0)/boot/grub/splash.xpm.gz
 
title Gentoo
root (hd0,0) 
kernel /boot/kernel root=/dev/rm0 real_root=/dev/sda3 ramdisk_size=8192 vga=791 nox 
initrd /boot/initramfs
//-----------------------------------------------------
grub
grub> root (hd0,0)
grub> setup (hd0)
grub> quit
 
passwd
 
cd /etc/init.d
ln -s net.lo net.eth0
cd ../conf.d
echo 'config_eth0="xxx.xxx.xxx.xxx netmask 255.255.255.0"' >> net
echo 'routes_eth0="default via xxx.xxx.xxx.xxx"' >> net     
echo 'hostname="myhostname"' > hostname
rc-update add net.eth0 default
rc-update add sshd default
 
 
 
echo 'modules="r8139cp"' >> /etc/conf.d/modules
 
 
reboot     

沒有留言:

張貼留言