代码: 全选
#
# Ubuntu 10.04 lucid 安装日志
#
# ==============================================================================
# 用 ubuntu-10.04.1-desktop-amd64.iso 启动
# 提取光盘 /casper/vmlinuz /casper/initrd.lz
# grub 引导参数
title ubuntu-10.04.1-desktop-amd64
kernel /vmlinuz boot=casper iso-scan/filename=/ubuntu-10.04.1-desktop-amd64.iso ro quiet splash vga=normal nomodeset
initrd /initrd.lz
# 更改 root 口令后打开其登录 shell
sudo passwd root
su -
# 分区
cfdisk /dev/sda
# 创建文件系统
mkfs.ext2 /dev/sda1
mkfs.ext4 /dev/sda2
mkfs.ext4 /dev/sda5
tune2fs -c 127 /dev/sda1
tune2fs -c 127 /dev/sda2
tune2fs -c 127 /dev/sda5
# 挂载
mkdir /mnt/ubuntu
mount /dev/sda2 /mnt/ubuntu
mkdir /mnt/ubuntu/boot /mnt/ubuntu/home
mount /dev/sda1 /mnt/ubuntu/boot
mount /dev/sda5 /mnt/ubuntu/home
# 我习惯把包缓存脱离根分区
mkdir -p /mnt/ubuntu/home/root/archives /mnt/ubuntu/var/cache/apt
ln -s ../../../home/root/archives /mnt/ubuntu/var/cache/apt/
# 随便
ln -s . /mnt/ubuntu/boot/boot
# ------------------------------------------------------------------------------
# 下载并安装 debootstrap
wget http://ftp.tw.debian.org/ubuntu/pool/main/d/debootstrap/debootstrap_1.0.20ubuntu1_all.deb
dpkg -i debootstrap_1.0.20ubuntu1_all.deb
# 运行 debootstrap 安装基本系统,版本代号 karmic
debootstrap --arch amd64 lucid /mnt/ubuntu http://ftp.tw.debian.org/ubuntu/
# ------------------------------------------------------------------------------
# 文件系统表
vi /mnt/ubuntu/etc/fstab {
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs size=512m 0 0
#/dev/sda? none swap sw 0 0
/dev/sda1 /boot ext2 noauto 0 2
/dev/sda2 / ext4 errors=remount-ro 0 1
/dev/sda5 /home ext4 relatime 0 2
#/dev/sda6 /vm ext4 relatime 0 2
#/dev/sda7 /data ext4 relatime 0 2
}
# ------------------------------------------------------------------------------
# 网卡
vi /mnt/ubuntu/etc/network/interfaces {
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
}
# 路由配置,用 ubuntu livecd 会自动正确配置,可检查一下,比如:
vi /mnt/ubuntu/etc/resolv.conf {
domain domain
search domain
nameserver 10.0.2.3
}
# 计算机名
echo $HOSTNAME > /mnt/ubuntu/etc/hostname
vi /mnt/ubuntu/etc/hosts {
127.0.0.1 localhost $HOSTNAME
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
}
# ------------------------------------------------------------------------------
# 其它配置,习惯问题
vi /mnt/ubuntu/etc/inputrc {
"\e[A": history-search-backward
"\e[B": history-search-forward
}
rm /mnt/ubuntu/root/.profile
vi /mnt/debian/root/.bash_profile {
if [ -z "$DISPLAY" ]; then
export LANG=en_US.UTF-8
fi
. ~/.bashrc
}
rm /mnt/ubuntu/root/.bashrc
vi /mnt/ubuntu/root/.bashrc {
export PS1='\[\e[32;1m\]>\[\e[31;1m\]$?\[\e[32;1m\]<\[\e[0m\] \W\[\e[32;1m\]\$\[\e[0m\] '
alias ls='ls -AF --color'
date
#df -Th | grep ^\/dev\/sd
}
# ------------------------------------------------------------------------------
# 挂载 /proc 、/sys 和 /dev
mount -t proc proc /mnt/ubuntu/proc
mount -t sysfs sysfs /mnt/ubuntu/sys
mount -o bind /dev /mnt/ubuntu/dev
# 换根
unset LS_COLORS
LANG=C chroot /mnt/ubuntu /bin/bash
# ==============================================================================
# 导入 medibuntu 源公钥
pushd /tmp
wget http://packages.medibuntu.org/pool/free/m/medibuntu-keyring/medibuntu-keyring_2008.04.20_all.deb
dpkg -i medibuntu-keyring_2008.04.20_all.deb
rm medibuntu-keyring_2008.04.20_all.deb
popd
# 设源
vi /etc/apt/sources.list {
deb http://ftp.tw.debian.org/ubuntu lucid main multiverse restricted universe
deb http://ftp.tw.debian.org/ubuntu lucid-security main multiverse restricted universe
deb http://ftp.tw.debian.org/ubuntu lucid-updates main multiverse restricted universe
deb http://packages.medibuntu.org/ lucid free non-free
}
# 刷表
aptitude update
# 更新
# debian 不必,但 ubuntu 必须
aptitude full-upgrade
# ------------------------------------------------------------------------------
# 若硬时钟非 UTC
vi /etc/default/rcS {
UTC=no
}
# 时区
dpkg-reconfigure tzdata {
Asia/Shanghai
}
# 本地化
# 必须安装 language-pack-en 否则就别想用 en_US.UTF-8 ,繁体用 hant 。
aptitude install -R language-pack-en language-pack-zh-hans
vi /etc/default/locale {
LANG=zh_CN.UTF-8
}
# 控制台及键盘
dpkg-reconfigure console-setup
# ------------------------------------------------------------------------------
# 引导器
# Ubuntu 照抄 Debian 文档。Debian 文档说先装内核再安装引导器,但尝试出错,只能先
# 安装引导器。
# 若有其它系统最好带上 os-prober
aptitude install -R grub
grep -v rootfs /proc/mounts > /etc/mtab
grub-install /dev/sda
update-grub
vi /boot/grub/menu.lst {
# kopt=root=/dev/sda2 ro nomodeset
# defoptions=iommu=noaperture
}
# 内核映象配置文件
vi /etc/kernel-img.conf {
# Kernel image management overrides
# See kernel-img.conf(5) for details
do_symlinks = yes
relative_links = yes
do_bootloader = no
do_bootfloppy = no
do_initrd = yes
link_in_boot = no
postinst_hook = update-grub
postrm_hook = update-grub
}
# 内核
aptitude search ^linux-image
aptitude install -R linux-image-generic
# ------------------------------------------------------------------------------
# 设置口令
passwd
# 退出 chroot 环境
exit
# 卸载
umount /mnt/ubuntu/dev /mnt/ubuntu/sys /mnt/ubuntu/proc
umount /mnt/ubuntu/boot /mnt/ubuntu/home /mnt/ubuntu
# 退出并重启
exit
# ==============================================================================
# 重启进入新系统