D.4. Installing Ubuntu from a Unix/Linux System

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, Red Hat, Mandriva, 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.

[Note] Note

As this is a mostly manual procedure, you should bear in mind that you will need to do a lot of basic configuration of the system yourself, which will also require more knowledge of Ubuntu and of Linux in general than performing a regular installation. You cannot expect this procedure to result in a system that is identical to a system from a regular installation. You should also keep in mind that this procedure only gives the basic steps to set up a system. Additional installation and/or configuration steps may be needed. In general, this method of installation is not recommended for casual or first time users.

D.4.1. Getting Started

With your current *nix partitioning tools, repartition the hard drive as needed, creating at least one filesystem plus swap. You need around 506MB of space available for a console only install.

Next, create file systems on the partitions. For example, to create an ext3 file system on partition /dev/sda6 (that's our example root partition):

# mke2fs -j /dev/sda6

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/sda5
# sync
# swapon /dev/sda5

[Note] Note

Instead of using a dedicated swap partition, you may omit the swap partition setup here and later just use a swap file instead.

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/sda6 /mnt/ubuntu

[Note] Note

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.

D.4.2. Install debootstrap

The utility used by the Ubuntu installer, and 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[20]. Install wget and ar if they aren't already on your current system, then download and install debootstrap. If these steps are executed under Ubuntu you can simply do this by apt install debootstrap.

If you have an RPM (Red Hat Package Manager) based system, you can use alien, which is available in the Debian repositories, to convert the .deb file to a useable .rpm file.

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

D.4.3. Run debootstrap

debootstrap can download the needed files directly from the archive when you run it. You can substitute any Ubuntu archive mirror for ports.ubuntu.com/ubuntu-ports 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 focal 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, arm64, armhf, i386, powerpc, ppc64el, or s390x.

# /usr/sbin/debootstrap --arch ARCH focal /mnt/ubuntu

D.4.4. Configure The Base System

Now you've got a real Ubuntu system, though rather lean, on disk. chroot into it:

# LANG=C.UTF-8 chroot /mnt/ubuntu /bin/bash

After chrooting you may need to set the terminal definition to be compatible with the Ubuntu base system, for example:

# export TERM=xterm-color

Depending on the value of TERM, you may have to install the ncurses-term package to get support for it.

[Note] Note

If warnings occur like:

bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

The required localization files need to be generated:

# sudo locale-gen en_US.UTF-8
Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.

D.4.4.1. Configure Apt

Debootstrap will have created a very basic /etc/apt/sources.list that will allow installing additional packages. However, it is suggested that you add some additional sources, for example for source packages and security updates:

deb-src http://archive.ubuntu.com/ubuntu focal main

deb http://security.ubuntu.com/ubuntu focal-security main
deb-src http://security.ubuntu.com/ubuntu focal-security main

Make sure to run apt update after you have made changes to the sources list.

D.4.4.2. Install additional packages

Now it's required to install some additionally required packages, like makedev (needed for the next section): apt install makedev

Or in case using the s390x architecture the mandatory s390-tools package: apt install s390-tools

D.4.4.3. Create device files

At this point /dev/ only contains very basic device files. For the next steps of the installation additional device files may be needed. There are different ways to go about this and which method you should use depends on the host system you are using for the installation, on whether you intend to use a modular kernel or not, and on whether you intend to use dynamic (e.g. using udev) or static device files for the new system.

A few of the available options are:

  • create a default set of static device files using (after chrooting)

    # mount none /proc -t proc
    # cd /dev
    # MAKEDEV generic
    or depending on your specific architecture:
    # MAKEDEV std
    # cd ..

  • manually create only specific device files using MAKEDEV

    On s390x the DASD devices need to be created this way:

    # cd /dev
    # MAKEDEV dasd
    # cd ..

  • bind mount /dev from your host system on top of /dev in the target system, like:

    mount --bind dev /dev

    Note that the postinst scripts of some packages may try to create device files, so this option should only be used with care.

  • mount proc and sysfs

    You can mount the proc and sysfs file systems multiple times and to arbitrary locations, though /proc and /sys respectively are customary.

    # 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

D.4.4.4. DASD Disks and Partitions

Even if lsdasd already lists DASD devices:

# lsdasd
Bus-ID     Status      Name      Device  Type  BlkSz  Size      Blocks
0.0.1601   active      dasda     94:0    ECKD  4096   7043MB    1803060
0.0.260a   active      dasdb     94:4    ECKD  4096   7043MB    1803060

...they - and other CCW devices like DASD, FCP oder QETH devices as well - cannot be fully and persistently used, yet.

# lszdev --online | head -n 1 && lszdev --online | grep dasd-eckd
TYPE       ID                                              ON   PERS  NAMES
dasd-eckd  0.0.0123                                        yes  no    dasda
dasd-eckd  0.0.1234                                        yes  no    dasdb

Here DASD 1234 is the one used for debootstrap. Now make this particular DASD persistently active with the help of the usual chzdev tool:

# chzdev -e 1234
ECKD DASD 0.0.1234 configured
# lszdev --online 1234            
TYPE       ID        ON   PERS  NAMES
dasd-eckd  0.0.1234  yes  yes   dasdb

Repeat similar steps for other CCW devices, like FCP, QETH devices or further DASD devices - if needed.

D.4.4.5. Mount Partitions

You need to create /etc/fstab.

# editor /etc/fstab

Here is a sample you can modify to suit:

# /etc/fstab: static file system information.
# hand-crafted
# file system    mount point   type    options                  dump pass
/dev/dasdb1      /             ext4    defaults                 0    1

/swapfile        none          swap    sw                       0    0

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

Current Ubuntu systems have mountpoints for removable media under /media, but keep compatibility symlinks in /. Create these as as needed, for example:

# cd /media
# mkdir cdrom0
# ln -s cdrom0 cdrom
# cd /
# ln -s media/cdrom

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

D.4.4.6. Setting Timezone

Setting the third line of the file /etc/adjtime to UTC or LOCAL determines whether the system will interpret the hardware clock as being set to UTC respective local time. The following command allows you to set that.

# editor /etc/adjtime

Here is a sample:

0.0 0 0.0

The following command allows you to choose your timezone.

# dpkg-reconfigure tzdata

D.4.4.7. Configure Networking

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
#     network
#     netmask
#     broadcast
#     gateway

Enter your nameserver(s) and search directives in /etc/resolv.conf:

# editor /etc/resolv.conf

A simple example /etc/resolv.conf:

search hqdom.local

Enter your system's host name (2 to 63 characters):

# echo UbuntuHostName > /etc/hostname

And a basic /etc/hosts with IPv6 support: localhost UbuntuHostName

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

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.

D.4.4.8. Configure Locales and Keyboard

To configure your locale settings to use a language other than English, install the appropriate language packs and configure them. Currently the use of UTF-8 locales is recommended.

# apt install language-pack-de language-pack-gnome-de

To configure your keyboard (if needed):

# apt install console-setup
# dpkg-reconfigure keyboard-configuration 

Note that the keyboard cannot be set while in the chroot, but will be configured for the next reboot.

D.4.5. Install a Kernel

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 the kernel package of your choice using its package name.

# apt install linux-image-arch-etc

(You may want install linux-image-generic, too.)

D.4.6. Set up the Boot Loader

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 inside your Ubuntu chroot to do so.

The zipl bootloader is part of the s390-tools package that was installed earlier. Check man zipl.conf for instructions on setting up the bootloader. Either create a zipl.conf configuration from scratch or copy over and modify the existing one.

Here is a basic /etc/zipl.conf as an example:

defaultmenu = menu

target = /boot
1 = ubuntu
default = 1

target = /boot
image = /boot/vmlinuz
ramdisk = /boot/initrd.img
parameters = root=/dev/dasdb1

Since the kernel and initrd filesnames in /boot are versioned, it's recommended to link them to non-versioned default names, like:

# ln -s /boot/vmlinuz-4.15.0-23-generic /boot/vmlinuz
# ln -s /boot/initrd.img-4.15.0-23-generic /boot/initrd.img

# ls -la /boot/vmlinuz* /boot/initrd.img*
lrwxrwxrwx 1 root root       28 Jun 20 07:31 /boot/initrd.img -> initrd.img-<version>-generic
-rw-r--r-- 1 root root 11245088 Jun 20 07:14 /boot/initrd.img-<version>-generic
lrwxrwxrwx 1 root root       25 Jun 20 07:31 /boot/vmlinuz -> vmlinuz-<version>-generic
-rw------- 1 root root  4390912 May 23 12:54 /boot/vmlinuz-<version>-generic

Finally don't forget to execute the zipl command for writing the configuration to disk:

# zipl 
Using config file '/etc/zipl.conf'
Building bootmap in '/boot'
Building menu 'menu'
Adding #1: IPL section 'ubuntu' (default)
Preparing boot device: dasdb (<your dasd device number>).

D.4.7. Remote access: Installing SSH and setting up access

In case you can login to the system via console, you can skip this section. If the system should be accessible via the network later on, you need to install SSH and set up access.

# apt install openssh-server 

Root login with password is disabled by default, so setting up access can be done by setting a password and re-enable root login with password:

# passwd
# editor /etc/ssh/sshd_config

This is the option to be enabled:

PermitRootLogin yes

Access can also be set up by adding an ssh key to the root account:

# mkdir /root/.ssh
# cat << EOF > /root/.ssh/authorized_keys
ssh-rsa ....

Lastly, access can be set up by adding a non-root user and setting a password:

# adduser joe
# passwd joe

D.4.8. Finishing touches

As mentioned earlier, the installed system will be very basic. If you would like to make the system a bit more mature, there is an easy method to install all packages with standard priority:

# apt install tasksel
# tasksel install standard

Of course, you can also just use apt to install packages individually.

After the installation there will be a lot of downloaded packages in /var/cache/apt/archives/. You can free up some diskspace by running:

# apt clean

D.4.9. Create a User

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

[20] These include the GNU core utilities and commands like sed, grep, tar and gzip.