Installing Ubuntu using debootstrap (2019)
This is an updated version of my 2017 post
In some scenarios you may wish to install vanilla Ubuntu without the ability to use an iso.
In my case this was an OVH dedicated server which the default Ubuntu install they provide comes loaded with stuff I don't want.
First reboot into a rescue medium or separate install which is debian based and doesn't use the parition you want to install ubuntu on.
If the install OS is old you may need to run:
apt-get update && apt-get -y upgrade
To update debootstrap
If the install OS isn't ubuntu you may need to run: apt-get install ubuntu-archive-keyring
This guide assumes /dev/md0
will be the root device, /dev/sda1
will be the EFI partition and you will be installing a 64 bit arch.
First format your install disk using fdisk/cfdisk/parted/whatever your tool of choice is.
If configuring software raid do so now using mdadm
Next mount the install root:
mkdir /debootstrap
mount /dev/md0 /debootstrap
If using EFI then run:
mkdir /debootstrap/boot/efi
mount /dev/sda1 /debootstrap/boot/efi
Now install the base OS
debootstrap --arch=amd64 bionic /debootstrap
If the above returns an error about a missing script run
ln -s /usr/share/debootstrap/scripts/gutsy /usr/share/debootstrap/scripts/bionic
And try again.
Replace bionic
with whatever the codename of the distro to install is.
Now edit /debootstrap/etc/apt/soruces.list
to include the following (again replacing bionic
with the codename)
#main repo
deb http://gb.archive.ubuntu.com/ubuntu/ bionic main
deb http://gb.archive.ubuntu.com/ubuntu/ bionic-updates main
#restricted repo
deb http://gb.archive.ubuntu.com/ubuntu/ bionic restricted
deb http://gb.archive.ubuntu.com/ubuntu/ bionic-updates restricted
#universe repo
deb http://gb.archive.ubuntu.com/ubuntu/ bionic universe
deb http://gb.archive.ubuntu.com/ubuntu/ bionic-updates universe
#multiverse repo
deb http://gb.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://gb.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
#security repo
deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
Now set up device mounts etc and chroot to the new install
mkdir -p /debootstrap/dev /debootstrap/proc /debootstrap/sys
mount --bind /dev /debootstrap/dev
mount -t proc proc /debootstrap/proc
mount -t sysfs sys /debootstrap/sys
chroot /debootstrap
Set up the locale and timezone
cp /usr/share/zoneinfo/UTC /etc/localetime
echo 'LANG="en_US.UTF-8"' > /etc/default/locale
echo 'Etc/UTC' > /etc/timezone
locale-gen en_US.UTF-8
dpkg-reconfigure -f non-interactive tzdata
apt update
apt install language-pack-en-base
If you are using software raid, LVM or cryptsetup run
apt install lvm2 mdadm cryptsetup
If using legacy BIOS then install the kernel and grub
apt install linux-image-generic grub2
If using EFI
apt install linux-image-generic grub-efi
Configure /etc/crypttab
and /etc/mdadm/mdadm.conf
then run:
If using legacy BIOS
update-grub
If using EFI
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck --debug
update-grub
Install openssh
apt install openssh-server
Important You must add your ssh key to /root/.ssh/authorized_keys
by default ubuntu only allows key access for root
Add an fstab entry
echo '/dev/sda1 / ext4 errors=remount-ro 0 1' > /etc/fstab
Now reboot and enjoy!