Manually installing Ubuntu

Submitted by olaf on 2016-06-11
Last modified at 2016-07-07

Installing Ubuntu while keeping an existing system, is still not working very smooth, especially when LVM or encryption is involved. After wasting a few hours with Ubuntu’s live CD installer, I decided to go the manual route. Many steps are taken from Ubuntu Installation/FromLinux

The first step is preparing the file systems for root, /boot, /usr and /var, which in my case involves

lvcreate --size 1G --name root vg0
mkfs -t ext2 /dev/mapper/vg0-root

and so on. /boot is usually located on a regular (primary) partition.

Mounting root and creating the necessary directories

mkdir /mnt/target
mount /dev/mapper/vg0-root /mnt/target
mkdir /mnt/target/boot /mnt/target/usr /mnt/target/var
mount /dev/sda1 /mnt/target/boot
mount /dev/mapper/vg0-usr /mnt/target/usr
mount /dev/mapper/vg0-var /mnt/target/var

Next comes the base system with

debootstrap xenial /mnt/target

If you’re tight on disk space or just want a smaller system, you can add --variant=minbase. You can also use a proxy server by setting the environment variable http_proxy. And if you want to use a local, e.g. the german, mirror, append it as the third argument

http_proxy= debootstrap xenial /mnt/target

Since we’re on an existing system, we want to keep a few things

cp /etc/crypttab /etc/fstab /mnt/target/etc

Edit /mnt/target/etc/fstab to adjust to the new circumstances. To complete the initial setup, install desktop packages and an operating system

chroot /mnt/target
mount -t proc none /proc
mount -t devtmpfs none /dev
mount -t devpts none /dev/pts
mount -t sysfs none /sys
apt-get install ubuntu-desktop
apt-get install linux-image-generic

This also installs the boot loader. You’re almost done now. But if you’re not located in the US or another English speaking region, you might want to adjust time zone and locale information.

rm -f /etc/localtime; ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime
echo Europe/Berlin >/etc/timezone
locale-gen de_DE.UTF-8
locale-gen en_US.UTF-8
update-locale LANG=de_DE.UTF-8 LANGUAGE=de_DE:en
apt-get install language-pack-de language-pack-en language-pack-gnome-de language-pack-gnome-en

You don’t need the en part of course, but I like to have it available, because some German translations are confusing at best, and if I want to figure out what’s going on, I still often resort to the English version.

To setup a German keyboard do

cat >>/etc/initramfs-tools/initramfs.conf <<EOF
# KEYMAP: [ y | n ]
# Load a keymap during the initramfs stage.


and in /etc/default/keyboard:

cat >/etc/default/keyboard <<EOF

As a last step, set a password for root, otherwise you won’t be able to login to your system.

passwd root

You might also create a regular user at this point

adduser --no-create-home olaf
adduser olaf sudo

If you reuse your existing home partition, use --no-create-home. The second adduser command allows to switch to root via sudo -i.

Finally update-initramfs -u and reboot into your new system. This is only a basic desktop system, and usually there’s a lot more until the system is working as desired. But from here on, you can do everything inside the new system.

Post a comment

All comments are held for moderation; Markdown and basic HTML formatting accepted. If you want to stay anonymous, leave name, e-mail and website empty.