个人工具

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

来自Ubuntu中文

跳转至: 导航, 搜索
(New page: {{From|https://help.ubuntu.com/community/Installation/OverSSH}} {{Languages|php5}} /!\ This is a work in progress, it is not mature yet and it may break your system! === Caveat === As you...)
 
 
(未显示2个用户的11个中间版本)
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/Installation/OverSSH}}
 
{{From|https://help.ubuntu.com/community/Installation/OverSSH}}
{{Languages|php5}}
+
{{Languages|UbuntuHelp:Installation/OverSSH}}
 
/!\ This is a work in progress, it is not mature yet and it may break your system!
 
/!\ This is a work in progress, it is not mature yet and it may break your system!
 
 
=== Caveat ===
 
=== Caveat ===
 
As you may already have guessed following this instruction may break your system and you are on your own to fix it again.
 
As you may already have guessed following this instruction may break your system and you are on your own to fix it again.
 
+
apt-get install linux-image-686
 
=== Scenario ===
 
=== Scenario ===
 
This instruction describes how to install Ubuntu on a dedicated server over ssh. I assume that your provider provides you with a rescue system from which you can boot and prepare your system. An Online replacement is possible, but it is some more work and a lot more risky if things go bad (the basic idea is to temporarily disable your swap and install a transitional system on it).
 
This instruction describes how to install Ubuntu on a dedicated server over ssh. I assume that your provider provides you with a rescue system from which you can boot and prepare your system. An Online replacement is possible, but it is some more work and a lot more risky if things go bad (the basic idea is to temporarily disable your swap and install a transitional system on it).
 
 
=== Preparing the Hard Disk ===
 
=== Preparing the Hard Disk ===
 
==== Partitioning ====
 
==== Partitioning ====
第14行: 第12行:
 
<pre><nowiki>
 
<pre><nowiki>
 
# fdisk /dev/hda
 
# fdisk /dev/hda
</nowiki></code>
+
</nowiki></pre>
 
+
 
Remember to set the root partition bootable!
 
Remember to set the root partition bootable!
 
 
For the rest of this instruction we assume the following partition layout.
 
For the rest of this instruction we assume the following partition layout.
 
<pre><nowiki>
 
<pre><nowiki>
 
/dev/hda1 (83  Linux)        - for /,  
 
/dev/hda1 (83  Linux)        - for /,  
 
/dev/hda2 (82  Linux swap)  - as swap
 
/dev/hda2 (82  Linux swap)  - as swap
</nowiki></code>
+
</nowiki></pre>
 
+
 
==== Creating File Systems ====
 
==== Creating File Systems ====
 
Below is how we get our / populated with ext3.
 
Below is how we get our / populated with ext3.
 
<pre><nowiki>
 
<pre><nowiki>
 
# mke2fs -j /dev/hda1
 
# mke2fs -j /dev/hda1
</nowiki></code>
+
</nowiki></pre>
 
+
 
And the same for our swap partition.
 
And the same for our swap partition.
 
<pre><nowiki>
 
<pre><nowiki>
第35行: 第29行:
 
# sync; sync; sync
 
# sync; sync; sync
 
# swapon /dev/hda2
 
# swapon /dev/hda2
</nowiki></code>
+
</nowiki></pre>
 
+
 
+
 
+
 
=== The Base System ===
 
=== The Base System ===
 
 
==== Mounting Root ====
 
==== Mounting Root ====
 
<pre><nowiki>
 
<pre><nowiki>
 
# mkdir /mnt/ubuntu
 
# mkdir /mnt/ubuntu
 
# mount -t ext3 /dev/hda1 /mnt/ubuntu
 
# mount -t ext3 /dev/hda1 /mnt/ubuntu
</nowiki></code>
+
</nowiki></pre>
 
+
 
==== Getting Debootstrap ====
 
==== Getting Debootstrap ====
 
Debootstrap is a collection of scripts that we will use in the next step to set up a base system. We need an appropriate version of <code><nowiki>debootstrap</nowiki></code> from http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/ to make this work.
 
Debootstrap is a collection of scripts that we will use in the next step to set up a base system. We need an appropriate version of <code><nowiki>debootstrap</nowiki></code> from http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/ to make this work.
 
 
Make sure that <code><nowiki>binutils</nowiki></code> is installed on your system.
 
Make sure that <code><nowiki>binutils</nowiki></code> is installed on your system.
 
 
On an apt based system we can use <code><nowiki>dpkg</nowiki></code> to install it.
 
On an apt based system we can use <code><nowiki>dpkg</nowiki></code> to install it.
 
<pre><nowiki>
 
<pre><nowiki>
 
# wget http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/debootstrap_0.3.3.0ubuntu2_all.deb
 
# 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
 
# dpkg -i debootstrap_0.3.3.0ubuntu2_all.deb
</nowiki></code>
+
</nowiki></pre>
 
+
 
If your current system is rpm based, use alien to install it or find a rpm on the web (http://azhrarn.underhanded.org/debootstrap-0.2.23-1.i386.rpm).
 
If your current system is rpm based, use alien to install it or find a rpm on the web (http://azhrarn.underhanded.org/debootstrap-0.2.23-1.i386.rpm).
 
 
If your system is neither, this might work.
 
If your system is neither, this might work.
 
<pre><nowiki>
 
<pre><nowiki>
第67行: 第52行:
 
# cd /
 
# cd /
 
# tar zxvf work/data.tar.gz
 
# tar zxvf work/data.tar.gz
</nowiki></code>
+
</nowiki></pre>
 
+
 
+
 
+
 
+
 
==== Installing the Base System ====
 
==== Installing the Base System ====
 
<pre><nowiki>
 
<pre><nowiki>
 
# /usr/sbin/debootstrap --arch i386 dapper /mnt/ubuntu http://archive.ubuntu.com/ubuntu
 
# /usr/sbin/debootstrap --arch i386 dapper /mnt/ubuntu http://archive.ubuntu.com/ubuntu
</nowiki></code>
+
</nowiki></pre>
 
+
(arch may be different for you, e.g. amd64, hppa, ia64, powerpc, or sparc)
(arch may be different for you, e.g. md64, hppa, ia64, powerpc, or sparc)
+
 
+
 
=== Basic Configuration ===
 
=== Basic Configuration ===
 
==== Set the Hostname ====
 
==== Set the Hostname ====
第84行: 第63行:
 
<pre><nowiki>
 
<pre><nowiki>
 
# echo HOSTNAME > /mnt/ubuntu/etc/hostname
 
# echo HOSTNAME > /mnt/ubuntu/etc/hostname
</nowiki></code>
+
</nowiki></pre>
 
+
 
==== fstab ====
 
==== fstab ====
 
<pre><nowiki>
 
<pre><nowiki>
 
# vim /mnt/ubuntu/etc/fstab
 
# vim /mnt/ubuntu/etc/fstab
</nowiki></code>
+
</nowiki></pre>
 
+
 
Put the following in fstab:
 
Put the following in fstab:
 
<pre><nowiki>
 
<pre><nowiki>
第99行: 第76行:
 
/dev/hda1      /              ext3    defaults,errors=remount-ro 0      1
 
/dev/hda1      /              ext3    defaults,errors=remount-ro 0      1
 
/dev/hda2      none            swap    sw              0      0
 
/dev/hda2      none            swap    sw              0      0
</nowiki></code>
+
</nowiki></pre>
 
+
 
==== Networking ====
 
==== Networking ====
 
Make sure to use your network details instead.
 
Make sure to use your network details instead.
第115行: 第91行:
 
         address 10.0.0.10
 
         address 10.0.0.10
 
         network 10.0.0.0
 
         network 10.0.0.0
         braodcast 10.0.0.255
+
         broadcast 10.0.0.255
 
         gateway 10.0.0.1
 
         gateway 10.0.0.1
 
         netmask 255.255.255.0
 
         netmask 255.255.255.0
</nowiki></code>
+
</nowiki></pre>
 
+
 
Make sure to use your hostname and domain.
 
Make sure to use your hostname and domain.
 
<pre><nowiki>
 
<pre><nowiki>
 
127.0.0.1  localhost
 
127.0.0.1  localhost
 
127.0.0.1  hostname.domain.tld hostname
 
127.0.0.1  hostname.domain.tld hostname
</nowiki></code>
+
</nowiki></pre>
 
+
 
You need a valid resolv.conf with at least one valid nameserver, e.g.:
 
You need a valid resolv.conf with at least one valid nameserver, e.g.:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
nameserver 10.0.0.1
 
nameserver 10.0.0.1
</nowiki></code>
+
</nowiki></pre>
 
+
 
+
 
=== Enter the new environment ===
 
=== Enter the new environment ===
 
Before we chroot into the new environment we need to mount /proc and /dev
 
Before we chroot into the new environment we need to mount /proc and /dev
第139行: 第110行:
 
mount -o bind /dev /mnt/ubuntu/dev
 
mount -o bind /dev /mnt/ubuntu/dev
 
LANG= chroot /mnt/ubuntu /bin/bash
 
LANG= chroot /mnt/ubuntu /bin/bash
</nowiki></code>
+
</nowiki></pre>
 
+
 
==== Change the root password ====
 
==== Change the root password ====
 
It is just bad if you forget this, so just ....
 
It is just bad if you forget this, so just ....
 
<pre><nowiki>
 
<pre><nowiki>
 
# passwd
 
# passwd
</nowiki></code>
+
</nowiki></pre>
 
+
 
==== Create a user and switch shadow password on ====
 
==== Create a user and switch shadow password on ====
 
<pre><nowiki>
 
<pre><nowiki>
 
# dpkg-reconfigure --default-priority passwd
 
# dpkg-reconfigure --default-priority passwd
</nowiki></code>
+
</nowiki></pre>
 
+
 
=== Installing Packages ===
 
=== Installing Packages ===
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# apt-get update
 
# apt-get update
</nowiki></code>
+
</nowiki></pre>
 
+
 
==== Installing OpenSSH Server ====
 
==== Installing OpenSSH Server ====
 
<pre><nowiki>
 
<pre><nowiki>
 
# apt-get install openssh-server
 
# apt-get install openssh-server
</nowiki></code>
+
</nowiki></pre>
 
+
 
==== Install a Kernel ====
 
==== Install a Kernel ====
 
Choose the right kernel for your architecture. I go with:
 
Choose the right kernel for your architecture. I go with:
 
<pre><nowiki>
 
<pre><nowiki>
 
# apt-get install linux-image-686
 
# apt-get install linux-image-686
</nowiki></code>
+
</nowiki></pre>
 
+
 
+
 
==== Installing GRUB ====
 
==== Installing GRUB ====
 
The boot loader is most important, so do:
 
The boot loader is most important, so do:
第175行: 第138行:
 
apt-get install grub
 
apt-get install grub
 
mkdir /boot/grub
 
mkdir /boot/grub
cp /lib/grub/i386-pc/* /boot/grub
+
cp /usr/lib/grub/i386-pc/* /boot/grub
 
vim /boot/grub/grub.conf
 
vim /boot/grub/grub.conf
  
</nowiki></code>
+
</nowiki></pre>
 
+
 
<pre><nowiki>
 
<pre><nowiki>
 
# /boot/grub/grub.conf
 
# /boot/grub/grub.conf
第189行: 第151行:
 
   kernel /vmlinuz root=/dev/hda1
 
   kernel /vmlinuz root=/dev/hda1
 
   initrd /initrd.img
 
   initrd /initrd.img
</nowiki></code>
+
</nowiki></pre>
 
+
 
<pre><nowiki>
 
<pre><nowiki>
 
ln -s /boot/grub/grub.conf /boot/grub/menu.lst
 
ln -s /boot/grub/grub.conf /boot/grub/menu.lst
</nowiki></code>
+
</nowiki></pre>
 
+
 
+
 
<pre><nowiki>
 
<pre><nowiki>
 
# grub
 
# grub
</nowiki></code>
+
</nowiki></pre>
 
+
 
<pre><nowiki>
 
<pre><nowiki>
 
grub> root (hd0,0)
 
grub> root (hd0,0)
 
grub> setup (hd0)
 
grub> setup (hd0)
 
grub> quit
 
grub> quit
</nowiki></code>
+
</nowiki></pre>
 
+
==== RAID ====
 
+
<pre><nowiki>
 
+
apt-get install mdadm
 +
</nowiki></pre>
 
==== Reboot ====
 
==== Reboot ====
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# exit
 
# exit
 
# cd /
 
# cd /
</nowiki></code>
+
</nowiki></pre>
 
+
 
<pre><nowiki>
 
<pre><nowiki>
 
# umount /mnt/ubuntu/proc
 
# umount /mnt/ubuntu/proc
第220行: 第177行:
 
# umount /mnt/ubuntu
 
# umount /mnt/ubuntu
 
# reboot
 
# reboot
</nowiki></code>
+
</nowiki></pre>
 
+
 
+
 
=== Finishing ===
 
=== Finishing ===
 
After the reboot ssh in again.
 
After the reboot ssh in again.
 
 
==== Generate locales ====
 
==== Generate locales ====
 
<pre><nowiki>
 
<pre><nowiki>
第231行: 第185行:
 
# echo 'LANG="en_US.UTF-8"' >> /etc/environment
 
# echo 'LANG="en_US.UTF-8"' >> /etc/environment
 
# echo 'LANGUAGE="en_US:en"' >> /etc/environment
 
# echo 'LANGUAGE="en_US:en"' >> /etc/environment
</nowiki></code>
+
</nowiki></pre>
 
+
==== Install some more packages ====
==== Istall some more packages ====
+
 
<pre><nowiki>
 
<pre><nowiki>
 
apt-get install ubuntu-standard
 
apt-get install ubuntu-standard
</nowiki></code>
+
</nowiki></pre>
 
+
 
=== References ===
 
=== References ===
* [[UbuntuHelp:Installation/FromKnoppix]]
+
* [[UbuntuHelp:Installation/FromKnoppix|Installation/FromKnoppix]]
 
+
 
* [http://www.gentoo.org/doc/en/handbook/handbook-x86.xml The Gentoo Handbook] contains a very good (Gentoo specific) [http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1 instruction on chrooted installation procedures].
 
* [http://www.gentoo.org/doc/en/handbook/handbook-x86.xml The Gentoo Handbook] contains a very good (Gentoo specific) [http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1 instruction on chrooted installation procedures].
 
 
* [http://doc.ubuntu.com/ubuntu/install/i386/apds03.html An other instruction] from the [http://doc.ubuntu.com/ubuntu/install/i386/index.html Ubuntu Installation Guide] is somewhat outdated and has shortcomings related to the bootloader installation.
 
* [http://doc.ubuntu.com/ubuntu/install/i386/apds03.html An other instruction] from the [http://doc.ubuntu.com/ubuntu/install/i386/index.html Ubuntu Installation Guide] is somewhat outdated and has shortcomings related to the bootloader installation.
+
* [http://www.underhanded.org/papers/debian-conversion/remotedeb.html HOWTO - Install Debian Onto a Remote Linux System] - A Debian specific HOWTO.
* [http://www.underhanded.org/papers/debian-conversion/remotedeb.html HOWTO - Install Debian Onto a Remote Linux System] - A Debian specific HOWTO.
+
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2010年5月19日 (三) 22:51的最新版本


/!\ This is a work in progress, it is not mature yet and it may break your system!

Caveat

As you may already have guessed following this instruction may break your system and you are on your own to fix it again. apt-get install linux-image-686

Scenario

This instruction describes how to install Ubuntu on a dedicated server over ssh. I assume that your provider provides you with a rescue system from which you can boot and prepare your system. An Online replacement is possible, but it is some more work and a lot more risky if things go bad (the basic idea is to temporarily disable your swap and install a transitional system on it).

Preparing the Hard Disk

Partitioning

Use fdisk to partition your hard disk.

# fdisk /dev/hda

Remember to set the root partition bootable! For the rest of this instruction we assume the following partition layout.

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

Creating File Systems

Below is how we get our / populated with ext3.

# mke2fs -j /dev/hda1

And the same for our swap partition.

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

The Base System

Mounting Root

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

Getting Debootstrap

Debootstrap is a collection of scripts that we will use in the next step to set up a base system. We need an appropriate version of debootstrap from http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/ to make this work. Make sure that binutils is installed on your system. On an apt based system we can use dpkg to install it.

# 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

If your current system is rpm based, use alien to install it or find a rpm on the web (http://azhrarn.underhanded.org/debootstrap-0.2.23-1.i386.rpm). If your system is neither, this might work.

# 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

Installing the Base System

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

(arch may be different for you, e.g. amd64, 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

RAID

apt-get install mdadm

Reboot

# exit
# cd /
# umount /mnt/ubuntu/proc
# umount /mnt/ubuntu/dev
# umount /mnt/ubuntu
# 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

Install some more packages

apt-get install ubuntu-standard

References