#!/bin/bash
#
#boot: gentoo dopcmcia
#加载内核模块
modprobe 8139too
#修改root用户密码
echo "gentoo
gentoo" |passwd root
echo -e "\033[31mCreate root's password successfully...\033[0m"
#创建一个新用户
useradd -m -G users john
echo "123456
123456" |passwd john
echo -e "\033[31mCreate john's password successfully...\033[0m"
#启动SSH服务
/etc/init.d/sshd start
#配置网络,加载一个内核模块
modprobe pcnet32
#动态获得IP地址
dhcpcd eth0
#测试网络连同性
if ping -c 3 >>/dev/null ; then
echo -e "\033[31mThe network is through...\033[0m"
else
echo -e "\033[31mThe network dosen't through...\033[0m"
fi
#用fdisk来为你的磁盘分区
echo "n
p
1
1
14
n
p
2
15
80
t
2
82
n
p
3
81
13000
w" |fdisk /dev/sda
#在分区上应用文件系统
mke2fs /dev/sda1
mkfs -t ext4 /dev/sda3
mkswap /dev/sda2
#激活交换分区
swapon /dev/sda2
#挂载
mount /dev/sda3 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot
#进入Gentoo的挂载点
cd /mnt/gentoo
#解开stage
tar xvjpf stage3-i686-20110405.tar.bz2
#从网上下载安装Portage快照
cd /mnt/gentoo
wget
tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr
#单CPU系统的MAKEOPTS
echo "MAKEOPTS=\"-j2\"" >> /mnt/gentoo/etc/make.conf
#安装Gentoo基本系统
#使用mirrorselect更新GENTOO_MIRRORS变量
echo "GENTOO_MIRRORS=\""" >> /mnt/gentoo/etc/make.conf
echo "SYNC=\"rsync://rsync.cn.gentoo.org/gentoo-portage\"" >> /mnt/gentoo/etc/make.conf
#copy DNS info
cp -L /etc/resolv.conf /mnt/gentoo/etc/
#mount /proc and /dev
mount -t proc none /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev
#entry new environment
chroot /mnt/gentoo /bin/bash
env-update
source /etc/profile
export PS1="(chroot) $PS1" #此处有点错误,在脚本中不能执行
#make Portage
emerge --sync
#make correct choice profile,list...
eselect profile list
#make date
if ls /usr/share/zoneinfo |grep 'GMT' ; then
cp /usr/share/zoneinfo/GMT /etc/localtime
else
exit 1
fi
#install kernel source
emerge gentoo-sources
ls -l /usr/src/linux
#install genkernel
emerge genkernel
zcat /proc/config.gz > /usr/share/genkernel/arch/x86/kernel-config
#running genkernel
genkernel all
#ls kernel and initrd
ls /boot/kernel* /boot/initramfs*
#add kernel mode
echo "3c59x" >> /etc/modules.autoload.d/kernel-2.6
#
rm -f /etc/fstab
touch /etc/fstab
cat >> /etc/fstab << EOF
/dev/sda1 /boot ext2 defaults,noatime 1 2
/dev/sda2 none swap sw 0 0
/dev/sda3 / ext4 noatime 0 1
EOF
#deploy your network
echo "config_eth0=( \"dhcp\" )" >> /etc/conf.d/net
rc-update add net.eth0 default
# cd /etc/init.d
# ln -s net.lo net.eth1
# rc-update add net.eth1 default
#install pcmciautile
emerge pcmciautils
#make passwd for root
echo "gentoo
gentoo" |passwd root
#install sys log
emerge syslog-ng
rc-update add syslog-ng default
#install cron
emerge vixie-cron
rc-update add vixie-cron default
#install slocate
emerge slocate
#install
emerge vim
emerge xfsprogs
emerge reiserfsprogs
emerge jfsutils
emerge ifup
emerge ifdown
emerge dhcpcd
emerge ppp
emerge ll
#install grub
emerge grub
cat >> /boot/grub/grub.conf << EOF
title Gentoo Linux 2.6.36-r8
root (hd0,0)
kernel /boot/kernel-genkernel-x86-2.6.36-gentoo-r8 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/sda3
initrd /boot/initramfs-genkernel-x86-2.6.36-gentoo-r8
EOF
#create mtab
grep -v rootfs /proc/mounts > /etc/mtab
#install grub
grub-install --no-floppy /dev/sda
cd /usr/src/linux
make menuconfig #编译内核
make && make modules_install
#reboot your system
exit
cd /
umount /mnt/gentoo/boot /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo
reboot
阅读(1735) | 评论(0) | 转发(0) |