debootstrap 精簡系統建立

2012/12/03

介紹

 

debootstrap 是用來建立最基本的 debian 系統的工具來. 它會自動下載及建立系統所需要的目錄及檔案架構.

它可用於 chroot 環境, 建立 VPS(虛擬機)及安裝新系統(要好有技術 !!)

 

debootstrap 是一個自動化的過程來

分別有以下步驟:

  • Retrieving
  • Validating
  • Extracting
  • Configuring
  • cleaning

指令:

debootstrap [OPTION...]  SUITE TARGET [MIRROR]

例子:

debootstrap lenny ./lenny

它會建立一個基本的 lenny 系統在 lenny 目錄內.

 

如果想建立另一版本, 可以用

debootstrap --verbose squeeze ./squeeze

 


 

實用參數:

 

[MIRROR]

指定由那麼下載檔案回來, default 是 /etc/apt/source 所指定的地方

 

Example:

debootstrap squeeze ./squeeze http://ftp.tw.debian.org/debian

--download-only

下載所需檔案而已, 並不將它們

--keep-debootstrap-dir

不清除下載回來的 *.deb 的意思


 

安裝新系統(難)

 

用仕何方式 Boot 起架機, 之後下載最新版的 debootstrap

wget http://ftp.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.26+...

# 解開 deb

ar -x <xxxx.deb>

# 內有以下檔案

control.tar.gz  data.tar.gz  debian-binary

# 建立相對應的目錄

mkdir debian

# 解開 file

tar -zxf data.tar.gz

建立系統:

debootstrap squeeze ./debian  http://cdn.debian.net/debian

Chroot 進去

# LANG=C chroot /mnt/harddisk /bin/bash
# export TERM=xterm-color

 

建立 /dev:

makedev - creates device files in /dev

 

安裝 Locales 及 Keyboard:

# aptitude install console-data

# aptitude install locales

 

安裝 Kernel:

# apt-get install linux-image-686

 

安裝 boot loader 到 HardDisk:

mount --bind  /dev /mnt/harddisk
# aptitude install grub
# grub-install /dev/hda
# update-grub

 

設定 mount point: /etc/fstab

UUID=fababf63-cb68-4699-8ffa-65c23e9f3805    /             ext3    defaults                 0    1
proc                                         /proc         proc    defaults                 0    0

 

設定網絡:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

 

安裝 sshd:

openssh-server

 

設定 root password:

passwd

 

 

 

 

Creative Commons license icon Creative Commons license icon