Install Ubuntu with debootstrap

Octobre 2016

How to create a bootable fully functional Ubuntu from debootstrap ?

We are here to install a full functional (and bootable) Ubuntu from deboostrap. Two remarks :

Formating the partition and installing the base system


sudo mkfs.ext4 /dev/XXX
sudo mount /dev/XXX /ubuntu
sudo debootstrap --arch i386 xenial /ubuntu
Now you have a minimal system in /ubuntu, but this is not bootable.

source.list and fstab


sudo cp /etc/apt/sources.list /ubuntu/etc/apt/sources.list
sudo vim /ubuntu/etc/fstab
Here is what you need in your new fstab :

#
#                
pMqroc            /proc           proc    nodev,noexec,nosuid 0       0
UUID=SLASH_UUID   /               ext4    errors=remount-ro 0       1
UUID=SWAP_UUID   none            swap    sw              0       0
where you have to replace SLASH_UUID by the UUID of the partition that will be the root of your new system. This is the one which is now mounted in /ubuntu. Use
sudo blkid
in order to know the uuid.

chroot

In order to be able to make the requested manipulation in your new system by chroot, you need to mount some repertories. Here you are :

sudo mount --bind /dev /ubuntu/dev 
sudo mount --bind /proc /ubuntu/proc
sudo mount --bind /sys /ubuntu/sys
and you can chroot to you new system :

chroot /ubuntu
The first thing to do is an update :

# apt update
# apt full-upgrade

Some configuration

Here is the most tricky part, because there are some manipulations to be done before to make your new system bootable.

Packages installation

We first install the needed packages :

# apt install linux-image-generic  cryptsetup libpam-mount vim grub-pc grub2-common bash-completion
One remark : when you are asked where to install the boot-stuff, you only select the drive you want : sda, sdb, ... you don't select the specific partitions. You can now launch the installation of the packages you need. Here is a part of my list :
System
unity-greeter kubuntu-desktop linux-image-generic grub-pc grub2-common grub-splashimages grub2-splashimages cryptsetup libpam-mount
Utilities
bash-completion htop verbiste verbiste-gnome pdftk git git-core qgit debootstrap pavucontrol pavumeter konqueror tor torbrowser-launcher
Vim
vim-latexsuite vim-gnome vim-addon-manager

Notice that vim-gnome is requested even if you want to use plain Vim is the terminal because without vim-gnome, the options --remote-tab and --servername do not exist.

French use
ispell aspell-fr hunspell-fr wfrench ifrench aspell-it aspell-en myspell-en-gb myspell-it hyphen-fr hyphen-it mythes-fr mythes-it thunderbird-locale-fr firefox-locale-fr language-pack-gnome-fr language-pack-fr-base language-pack-kde-fr language-pack-fr kde-l10n-fr thunderbird-locale-fr libreoffice-help-fr
Compiz
compiz compizconfig-settings-manager compiz-plugins-extra marble plasma-wallpapers-addons
Multimedia
gstreamer1.0-plugins-bad libgstreamer-plugins-bad1.0-0 gstreamer1.0-libav gstreamer1.0-plugins-bad-videoparsers gstreamer1.0-plugins-bad-faad youtube-dl cdrdao libdvd-pkg
C++
libqt5qml-graphicaleffects libboost-all-dev libboost1.58-all-dev
Java
default-jre default-jdk jgit-cli libjgit-ant-java libjgit-java libjgit-java-doc maven pandoc
Terminology
terminology elementary-icon-theme libelementary-bin

Other configurations

While you are making your big apt install you can make some other configurations. Lines that begin with # are to be typed in the chroot.

In order to have the right time zone :


# dpkg-reconfigure tzdata

Users

Create the user. Here I create my users taking care of their UID.


# adduser  --uid 1002 --home /interniste interniste 
# adduser  --uid 1001 --home /home/moky moky 
# adduser  moky sudo 
# adduser  moky lp
# adduser  interniste sudo
Some remarks

If you understood correctly, it was a bad idea to make a reboot before to arrive at this point.

Grub

In your current OS (not the chroot to the new one), install grub :


sudo grub-install --root-directory=/ubuntu /dev/sdQUOI
sudo cp /etc/default/grub /ubuntu/etc/default/grub

Update grub; the following has to be done in the chroot :

# update-grub

Once again in the current OS :


sudo dpkg-reconfigure grub-pc

Encryption

If your home is encrypted and if the encryption's password is the same as your user'one, you can make the partition to be automatically mounted and decrypted (in the sense /dev/mapper/... to be created and that directory to be mounted as your home) at login. The file /ubuntu/etc/security/pam_mount.conf.xml has to contain the line

< volume user="moky" fstype="crypt" path="/dev/disk/by-uuid/HOME_UUID" mountpoint="/home/moky" options="fsck,relatime" /> 

Vim

I'm making this :

# apt install vim-gnome vim-latexsuite vim-addon-manager
# vim-addons -w install latex-suite matchit

DVD


# sudo dpkg-reconfigure libdvd-pkg

Reboot

Now you can reboot your computer and play with your new system. Everything should be fine on the first strike.