个人工具

“UbuntuHelp:Installation/OverSSH/zh”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第1行: 第1行:
{{Copyedit translation|from=https://help.ubuntu.com/community/Installation/OverSSH}} {{From|https://help.ubuntu.com/community/Installation/OverSSH}} {{Translator|Yaoms}} {{Languages|UbuntuHelp:Installation/OverSSH}} !! 请注意,这是一个正在实验中的项目,它不是很成熟,并且有可能搞坏您的系统。
+
{{Copyedit translation|from=https://help.ubuntu.com/community/Installation/OverSSH}} {{From|https://help.ubuntu.com/community/Installation/OverSSH}} {{Translator|Yaoms}} {{Languages|UbuntuHelp:Installation/OverSSH}} /!\ 请注意,这是一个正在实验中的项目,它不是很成熟,并且有可能搞坏您的系统。
  
 
=== 警告 ===
 
=== 警告 ===
第16行: 第16行:
 
<pre># fdisk /dev/hda
 
<pre># fdisk /dev/hda
 
</pre>  
 
</pre>  
切记要把root分区设为活动分区(可以启动的)!在稍后的介绍中,我将假设你使用下面的分区布局,请根据你自己的情况改变。
+
切记要把root分区设为活动分区(可以启动的)!在稍後的介绍中,我将假设你使用下面的分区布局,请根据你自己的情况改变。
 
<pre>/dev/hda1 (83 Linux) - for /,  
 
<pre>/dev/hda1 (83 Linux) - for /,  
 
/dev/hda2 (82 Linux swap) - as swap
 
/dev/hda2 (82 Linux swap) - as swap
第97行: 第97行:
 
你还需要一个有效的 resolv.conf,包含至少一个有效的 nameserver, 例如:
 
你还需要一个有效的 resolv.conf,包含至少一个有效的 nameserver, 例如:
 
<pre>nameserver 10.0.0.1
 
<pre>nameserver 10.0.0.1
</pre>
+
</pre>  
 
+
 
=== 进入新的环境 ===
 
=== 进入新的环境 ===
  
第129行: 第128行:
 
<pre># apt-cache search linux-image
 
<pre># apt-cache search linux-image
 
</pre>  
 
</pre>  
然后安装
+
然後安装
 
<pre># apt-get install linux-image-686
 
<pre># apt-get install linux-image-686
 
</pre>  
 
</pre>  
第144行: 第143行:
 
default 0
 
default 0
 
timeout 3
 
timeout 3
 +
 +
  
  
第150行: 第151行:
 
kernel /vmlinuz root=/dev/hda1
 
kernel /vmlinuz root=/dev/hda1
 
initrd /initrd.img
 
initrd /initrd.img
 +
 +
 
</pre> <pre>ln -s /boot/grub/grub.conf /boot/grub/menu.lst
 
</pre> <pre>ln -s /boot/grub/grub.conf /boot/grub/menu.lst
 
</pre> <pre># grub
 
</pre> <pre># grub
第156行: 第159行:
 
grub&gt; setup (hd0)
 
grub&gt; setup (hd0)
 
grub&gt; quit
 
grub&gt; quit
</pre>
 
  
 +
 +
</pre>
 
==== 重启电脑 ====
 
==== 重启电脑 ====
 
<pre># exit
 
<pre># exit
 
# cd /
 
# cd /
</pre>  
+
</pre> <pre># umount /mnt/ubuntu/proc
<pre>
+
# umount /mnt/ubuntu/proc
+
 
# umount /mnt/ubuntu/dev
 
# umount /mnt/ubuntu/dev
 
# umount /mnt/ubuntu
 
# umount /mnt/ubuntu
 
# reboot
 
# reboot
</pre>
+
</pre>  
 
+
 
=== 结束安装 ===
 
=== 结束安装 ===
  
重启后,再用 ssh 登录上去。
+
重启後,再用 ssh 登录上去。
  
 
==== 创建 locales ====
 
==== 创建 locales ====

2008年3月13日 (四) 11:02的版本

/!\ 请注意,这是一个正在实验中的项目,它不是很成熟,并且有可能搞坏您的系统。

警告

正如你可能已经猜到的那样,这里介绍的方法有可能导致您的系统不能启动,并且你得依靠自己修复它。 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 可能有所不同,比如:md64、hppa、ia64、powerpc、或者 sparc)

基本设置

设置 Hostname

把 HOSTNAME 改成适合你的主机名。

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

创建 fstab 文件

# vim /mnt/ubuntu/etc/fstab

把下面的内容添加进 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

设置网络

使用你的网络参数完成以下实例的 /mnt/ubuntu/etc/network/interfaces

#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

使用你的网络参数完成这个实例的 /mnt/ubuntu/ets/hosts

127.0.0.1 localhost
127.0.0.1 hostname.domain.tld hostname

你还需要一个有效的 resolv.conf,包含至少一个有效的 nameserver, 例如:

nameserver 10.0.0.1

进入新的环境

在使用 chroot 进入新的系统环境之前,要先挂载 /proc 和 /dev 到新的环境中。

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

修改 root 密码

如果忘记密码就麻烦了。所以。。。

# passwd

创建一个新用户并使 passwd shadow 起效。

# dpkg-reconfigure --default-priority passwd

安装软件包

在这之前别忘了更新你的包索引。

# apt-get update

安装 OpenSSH Server

# apt-get install openssh-server

安装内核

选择一个适合你的系统架构的内核,我使用 linux-image-686。。

可以使用这个命令查找所有的内核:

# apt-cache search linux-image

然後安装

# apt-get install linux-image-686

安装 GRUB

引导装载程序非常重要,所以。。

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


重启电脑

# exit
# cd /
# umount /mnt/ubuntu/proc
  1. umount /mnt/ubuntu/dev
  2. umount /mnt/ubuntu
  3. reboot

结束安装

重启後,再用 ssh 登录上去。

创建 locales

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

添加额外的软件包,你需要的。

apt-get install ubuntu-standard

其他参考资料