This section explains how to install Ubuntu from an existing
Unix or Linux system, without using the menu-driven installer as
explained in the rest of the manual. This “cross-install”
HOWTO has been requested by users switching to Ubuntu from
Debian GNU/Linux, Red Hat, Mandrake, and SUSE. In this section some familiarity with
entering *nix commands and navigating the file system is assumed. In
this section, $
symbolizes a command to be entered in
the user's current system, while #
refers to a
command entered in the Ubuntu chroot.
Once you've got the new Ubuntu system configured to your preference, you can migrate your existing user data (if any) to it, and keep on rolling. This is therefore a “zero downtime” Ubuntu install. It's also a clever way for dealing with hardware that otherwise doesn't play friendly with various boot or installation media.
With your current *nix partitioning tools, repartition the hard drive as needed, creating at least one filesystem plus swap. You need at least 400MB of space available for a minimal server install, or at least 2GB if you plan to install the Ubuntu desktop.
To create file systems on your partitions. For example, to create an
ext3 file system on partition /dev/hda6
(that's
our example root partition):
# mke2fs -j /dev/hda6
To create an ext2 file system instead, omit -j
.
Initialize and activate swap (substitute the partition number for your intended Ubuntu swap partition):
# mkswap /dev/hda5 # sync; sync; sync # swapon /dev/hda5
Mount one partition as /mnt/ubuntu
(the
installation point, to be the root (/
) filesystem
on your new system). The mount point name is strictly arbitrary, it is
referenced later below.
# mkdir /mnt/ubuntu # mount /dev/hda6 /mnt/ubuntu
If you want to have parts of the filesystem (e.g. /usr) mounted on separate partitions, you will need to create and mount these directories manually before proceding with the next stage.
The tool that the Ubuntu installer uses, which is recognized as the
official way to install an Ubuntu base system, is
debootstrap. It uses wget and
ar, but otherwise depends only on
/bin/sh
and basic Unix/Linux tools[13]. Install wget and
ar if they aren't already on your current system,
then download and install debootstrap.
Or, you can use the following procedure to install it manually. Make a work folder for extracting the .deb into:
# mkdir work # cd work
The debootstrap binary is located in the Ubuntu archive (be sure to select the proper file for your architecture). Download the debootstrap .deb from the pool, copy the package to the work folder, and extract the files from it. You will need to have root privileges to install the files.
# ar -x debootstrap_0.X.X_all.deb # cd / # zcat /full-path-to-work/work/data.tar.gz | tar xv
debootstrap can download the needed files directly
from the archive when you run it. You can substitute any Ubuntu
archive mirror for archive.ubuntu.com/ubuntu
in
the command example below, preferably a mirror close to you
network-wise. Mirrors are listed at
http://wiki.ubuntu.com/Archive.
If you have an Ubuntu feisty CD mounted at
/cdrom
, you could substitute a file URL instead
of the http URL: file:/cdrom/ubuntu/
Substitute one of the following for ARCH
in the debootstrap command:
amd64
,
hppa
,
i386
,
ia64
,
powerpc
, or
sparc
.
# /usr/sbin/debootstrap --arch ARCH feisty \ /mnt/ubuntu http://archive.ubuntu.com/ubuntu
Now you've got a real Ubuntu system, though rather lean, on disk. Chroot into it:
# LANG= chroot /mnt/ubuntu /bin/bash
You need to create /etc/fstab
.
# editor /etc/fstab
Here is a sample you can modify to suit:
# /etc/fstab: static file system information. # # file system mount point type options dump pass /dev/XXX / ext3 defaults 0 1 /dev/XXX /boot ext3 ro,nosuid,nodev 0 2 /dev/XXX none swap sw 0 0 proc /proc proc defaults 0 0 sys /sys sysfs defaults 0 0 /dev/fd0 /mnt/floppy auto noauto,rw,sync,user,exec 0 0 /dev/cdrom /mnt/cdrom iso9660 noauto,ro,user,exec 0 0 /dev/XXX /tmp ext3 rw,nosuid,nodev 0 2 /dev/XXX /var ext3 rw,nosuid,nodev 0 2 /dev/XXX /usr ext3 rw,nodev 0 2 /dev/XXX /home ext3 rw,nosuid,nodev 0 2
Use mount -a
to mount all the file systems you
have specified in your /etc/fstab
, or to mount
file systems individually use:
# mount /path # e.g.: mount /usr
You can mount the proc and sysfs file systems multiple times and to arbitrary
locations, though /proc
and /sys
respectively are customary. If you didn't use
mount -a
, be sure to mount proc and sysfs before continuing:
# mount -t proc proc /proc # mount -t sysfs sysfs /sys
The command ls /proc
should now show a non-empty
directory. Should this fail, you may be able to mount proc from outside
the chroot:
# mount -t proc proc /mnt/ubuntu/proc
To configure your keyboard:
# dpkg-reconfigure console-setup
Note that the keyboard cannot be set while in the chroot, but will be configured for the next reboot.
To configure networking, edit
/etc/network/interfaces
,
/etc/resolv.conf
,
/etc/hostname
and
/etc/hosts
.
# editor /etc/network/interfaces
Here are some simple examples from
/usr/share/doc/ifupdown/examples
:
###################################################################### # /etc/network/interfaces -- configuration file for ifup(8), ifdown(8) # See the interfaces(5) manpage for information on what options are # available. ###################################################################### # We always want the loopback interface. # auto lo iface lo inet loopback # To use dhcp: # # auto eth0 # iface eth0 inet dhcp # An example static IP setup: (broadcast and gateway are optional) # # auto eth0 # iface eth0 inet static # address 192.168.0.42 # network 192.168.0.0 # netmask 255.255.255.0 # broadcast 192.168.0.255 # gateway 192.168.0.1
Enter your nameserver(s) and search directives in
/etc/resolv.conf
:
# editor /etc/resolv.conf
A simple /etc/resolv.conf
:
search hqdom.local\000 nameserver 10.1.1.36 nameserver 192.168.9.100
Enter your system's host name (2 to 63 characters):
# echo UbuntuHostName > /etc/hostname
If you have multiple network cards, you should arrange the names of
driver modules in the /etc/modules
file into the
desired order. Then during boot, each card will be associated with the
interface name (eth0, eth1, etc.) that you expect.
To configure your locale settings to use a language other than English, install the appropriate language packs:
# apt-get install language-pack-de language-pack-gnome-de
NOTE: Apt must be configured beforehand by creating a sources.list and running apt-get update. Before using locales with character sets other than ASCII or latin1, please consult the appropriate localization HOWTO.
If you intend to boot this system, you probably want a Linux kernel and a boot loader. Identify available pre-packaged kernels with
# apt-cache search linux-image
Then install your choice using its package name.
# apt-get install linux-image-2.6.20-arch-etc
To make your Ubuntu system bootable, set up your boot loader to load the installed kernel with your new root partition. Note that debootstrap does not install a boot loader, though you can use apt-get inside your Ubuntu chroot to do so.
Check info grub
or man
lilo.conf
for instructions on setting up the
bootloader.
For an initial install of grub, you should normally run
grub-install
to install a grub image on your hard
disk, and update-grub
to generate a
menu.lst
configuration file.
If you are keeping the system you used to install Ubuntu, just
add an entry for the Ubuntu install to your existing grub
menu.lst
or lilo.conf
. For
lilo.conf
, you could also copy it to the new system and
edit it there. After you are done editing, call lilo (remember it will use
lilo.conf
relative to the system you call it from).
Here is a basic /etc/lilo.conf
as an example:
boot=/dev/hda6 root=/dev/hda6 install=menu delay=20 lba32 image=/vmlinuz label=Ubuntu
Use the adduser command to create a new user account:
# adduser myusername
You will be prompted for a full name and a password.
The normal Ubuntu configuration is to allow this new user to administer the
system using sudo. To set this up, first create an
admin
group and add your new user to it:
# addgroup --system admin # adduser myusername admin
You can now use the visudo command to add these lines to
the end of /etc/sudoers
, so that any user in the
admin
group can administer the system:
# Members of the admin group may gain root privileges %admin ALL=(ALL) ALL
If you don't want to follow this configuration, then remember to set a root password:
# passwd root
At this point, you probably want to reboot into your new Ubuntu system to make sure it all works. Once you've done that, log in as the user you just created, and run:
$ sudo tasksel install ubuntu-standard $ sudo tasksel install ubuntu-desktop
You will need to enter your password to authorise sudo to run as root.
tasksel will now get on with installing the packages that make up the Ubuntu desktop, which will take a while. When it's finished, you should be presented with a graphical login prompt. The installation is now complete, so go ahead and log in.