个人工具

UbuntuHelp:Installation/OverSSH/zh

来自Ubuntu中文

Yaoms讨论 | 贡献2008年1月9日 (三) 12:11的版本

跳转至: 导航, 搜索
!! 请注意,这是一个正在实验中的项目,它不是很成熟,并且有可能搞坏您的系统。

警告

正如你可能已经猜到的那样,这里介绍的方法有可能导致您的系统不能启动,并且你得依靠自己修复它。 apt-get install linux-image-686


这份指南向您介绍如何通过 ssh 在专用服务器上安装 Ubuntu 。我假设你的供应商为你提供了一个可以引导并准备你的正常作业系统的备用(或者称做恢复 or 急救)系统;这样的话,在线的“系统替换”就成为可能,但是这需要冒很大的风险并有作大量补救工作的准备,以防事情变得更糟糕(the basic idea is to temporarily disable your swap and install a transitional system on it)。

准备磁盘

创建分区

使用 fdisk 在磁盘上创建分区。

# fdisk /dev/hda

切记要把root分区设为活动分区(可以启动的)!在稍后的介绍中,我将假设你使用下面的分区布局,请根据你自己的情况改变。

/dev/hda1 (83 Linux) - for /, 
/dev/hda2 (82 Linux swap) - as swap

创建文件系统

下面我将使用流行的 ext3 格式格式化我的 / 分区

# mke2fs -j /dev/hda1
or
# mkfs.ext3 /dev/hda1

使用以下命令初始化并启用我们的 swap 分区

# mkswap /dev/hda2
# sync; sync; sync
# swapon /dev/hda2

基本系统

挂载根分区

# mkdir /mnt/ubuntu
# mount -t ext3 /dev/hda1 /mnt/ubuntu

获取 Debootstrap

Debootstrap 是一组在接下来的搭建“基本系统”的步骤中要用到的脚本。 我们需要从http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/ (就近的 mirror 也可以)取得一个合适版本的 debootstrap。首先确定你的备用系统中安装了 binutils (包含基本的命令行工具,如wget)工具。 在基于APT的系统上,我们可以使用 dpkg 安装它。

# wget http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/debootstrap_0.3.3.0ubuntu2_all.deb
# dpkg -i debootstrap_0.3.3.0ubuntu2_all.deb

如果你现在的系统是基于 RPM 的,使用 alien 工具安装它或者你可以在这个网站上找到它的rpm版本(如:http://azhrarn.underhanded.org/debootstrap-0.2.23-1.i386.rpm )。如果你的系统不属于任何上面的情况,下面的命令可能会有用:

# mkdir /work; cd /work
# wget http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/debootstrap_0.3.3.0ubuntu2_all.deb
# ar -xf debootstrap-udeb_0.3.3.0ubuntu7_i386.udeb
# cd /
# tar zxvf work/data.tar.gz

安装基本系统

# /usr/sbin/debootstrap --arch i386 dapper /mnt/ubuntu http://archive.ubuntu.com/ubuntu

(arch may be different for you, e.g. md64, hppa, ia64, powerpc, or sparc)

Basic Configuration

Set the Hostname

Change HOSTNAME to whatever suits your environment.

# echo HOSTNAME > /mnt/ubuntu/etc/hostname

fstab

# vim /mnt/ubuntu/etc/fstab

Put the following in fstab:

# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/hda1 / ext3 defaults,errors=remount-ro 0 1
/dev/hda2 none swap sw 0 0

Networking

Make sure to use your network details instead.

#Network Config:
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 10.0.0.10
network 10.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.1
netmask 255.255.255.0

Make sure to use your hostname and domain.

127.0.0.1 localhost
127.0.0.1 hostname.domain.tld hostname

You need a valid resolv.conf with at least one valid nameserver, e.g.:

nameserver 10.0.0.1

Enter the new environment

Before we chroot into the new environment we need to mount /proc and /dev

mount -t proc none /mnt/ubuntu/proc
mount -o bind /dev /mnt/ubuntu/dev
LANG= chroot /mnt/ubuntu /bin/bash

Change the root password

It is just bad if you forget this, so just ....

# passwd

Create a user and switch shadow password on

# dpkg-reconfigure --default-priority passwd

Installing Packages

# apt-get update

Installing OpenSSH Server

# apt-get install openssh-server

Install a Kernel

Choose the right kernel for your architecture. I go with:

# apt-get install linux-image-686

Installing GRUB

The boot loader is most important, so do:

apt-get install grub
mkdir /boot/grub
cp /usr/lib/grub/i386-pc/* /boot/grub
vim /boot/grub/grub.conf

# /boot/grub/grub.conf

default 0 timeout 3

















title=Ubuntu root (hd0,0) kernel /vmlinuz root=/dev/hda1 initrd /initrd.img
































ln -s /boot/grub/grub.conf /boot/grub/menu.lst
# grub
grub> root (hd0,0)

grub> setup (hd0) grub> quit
































Reboot

# exit
# cd /
# umount /mnt/ubuntu/proc
  1. umount /mnt/ubuntu/dev























  1. umount /mnt/ubuntu























  1. reboot
































Finishing

After the reboot ssh in again.

Generate locales

# locale-gen en_US.UTF-8
# echo 'LANG="en_US.UTF-8"' >> /etc/environment
# echo 'LANGUAGE="en_US:en"' >> /etc/environment

Istall some more packages

apt-get install ubuntu-standard

References