Ceci est une ancienne révision du document !
Most users of Ubuntu and its derivative distributions are fairly happy with the LiveCD or USB approach to installing the distribution. However, other rather more exotic ways of creating a working operating system are also available. In this piece, I would like to show how Ubuntu Base can be installed, and then tweaked to get a working system with a minimum of software. Ubuntu Base is described in the appropriate entry in the Ubuntu Wiki: https://wiki.ubuntu.com/Base. We are, in essence, starting with a very minimal disk image of an Ubuntu System, with the bare minimum to handle the apt package manager. It is, in fact, so barebones that we do not even have a kernel or initial ramdisk image. Nor is GRUB installed by default, so we will have to download and install these pieces by hand during the setup process.
La plupart des utilisateurs d'Ubuntu et de ses distributions dérivées sont plutôt contents avec l'approche d'une installation de la distribution par Live CD ou par USB. Cependant, d'autres façons plus exotiques de créer un système d'exploitation opérationnel sont aussi disponibles. Dans cette article, je voudrais vous montrer comment Ubunru Base peut être installé puis ajusté pour obtenir un système fonctionnel avec un minimum de logiciels.
Ubuntu Base est décrit dans une page appropriée du Wiki d'Ubuntu : https://wiki.ubuntu.com/Base. Nous démarrons, en substance, avec une image disque vraiment minimale du système Ubuntu, avec le strict minimum pour gérer le gestionnaire de paquets apt. On est si près du squelette, en fait, que nous n'avons même pas de noyau ou une image ramdisk initiale. GRUB n'est pas non plus installé par défaut, ; aussi, nous devrons télécharger et installer ces éléments à la main pendant le processus de paramétrage.
Let us begin by downloading Ubuntu Base. I chose the 64-bit “amd64” of Ubuntu version 17.10 from the download page: http://cdimage.ubuntu.com/ubuntu-base/releases/17.10/release/. I will be performing tests in a virtual machine under VirtualBox 5.130, running on a host with Ubuntu Budgie 17.10. It may be interesting to note my processor, an Intel Core i7, has the vmx flag activated, which means I can run a 64-bit virtual machine inside VirtualBox. I also had to activate VT-x (virtualization technology) in my computer’s BIOS settings. If this is unavailable, VirtualBox client operating systems would be limited to 32-bit versions, and we would need to choose the corresponding 32-bit “i386” file to download. Both files are currently at about 36-37 MBytes in size, and so quite lightweight. Another approach would be to install the system directly on an actual computer. In this case, a standard LiveCD or USB would be required to boot the system initially - or some other means of achieving a minimal working system. Networking would also be useful on the target computer, to download the Ubuntu Base image. However, we would be able to install the 64-bit system directly, if our target hardware supports it (i.e. has a 64-bit CPU). This would be the case for most computers built over the last 6-7 years onward.
Commençons par télécharger Ubuntu Base. J'ai choisi la version 17.10 64-bit « amd64 » d'Ubuntu sur la page de téléchargement : http://cdimage.ubuntu.com/ubuntu-base/releases/17.10/release/. Je ferai les test sur une machine virtuelle sous VirtualBox 5.130, tournant sur un hôte avec Ubuntu Budgie 17.10. Il peut être intéressant de noter que mon processeur, un Intel Core i7, a le flag vmx activé, ce qui signifie que je peux faire tourner une machine virtuelle 64-bit dans VirtualBox. J'ai aussi activé VT-x (technologie de virtualisation) dans les paramètres du BIOS de mon ordinateur. Si ce n'est pas disponible, les systèmes d'exploitation clients dans VirtualBox seraient limités à des versions 32-bit et nous devrions choisir le fichier 32-bit « i386 » correspondant pour le télécharger. Les deux fichiers ont actuellement une taille de 36-37 Moctets et sont donc plutôt légers.
Une autre approche serait d'installer le système directement sur un vrai ordinateur. Dans ce cas, un LiveCD ou une clé USB ordinaires seraient nécessaires pour le premier démarrage du système. - d'autres moyens de réaliser un système fonctionnel minimal. Le réseau serait aussi utile sur l'ordinateur cible pour télécharger l'image d'Ubuntu Base. cependant, nous serions capable d'installer directement le système 64-bit, si notre matériel cible le supporte (c-à-d, a un CPU 64-bit). Ce serait le cas pour la plupart des ordinateurs fabriqués dans 6-è dernières années.
Once inside VirtualBox, I created a new virtual machine with the following specifications: • Type Linux / Ubuntu (64-bit). • 2048 MBytes of RAM (mostly for the LiveCD, this can be reduced significantly for the final system). • Dynamically allocated VDI hard drive, 8.0 GBytes in size (also very much overkill). I then connected the virtual CD drive to a Linux Mint 18 Cinnamon (64-bit) ISO image that was in my Downloads folder, to use for the initial booting of the target system. I then booted the virtual machine from the Linux Mint CD image. Once running, I used gparted to create a new ms-dos partition table on the virtual hard drive, /dev/sda, and a single partition formatted with ext4. Any other partition management tool would have served this purpose, such as fdisk, parted or graphical equivalents.
Une fois à l'intérieur de VirtualBox, j'ai créé une nouvelle machine virtuelle avec les spécifications suivantes : • Type Linux / Ubuntu (64-bit). • 2048 Moctets de RAM (principalement pour le LiveCD, ceci peut être réduit considérablement pour le système fini). • Disque dur VDI dynamiquement alloué de 8.0 Go de taille (aussi très surdimensionné).
I transferred the Ubuntu Base compressed file over from the host computer using SSH in a terminal window: scp alan@10.0.2.2:/home/alan/Downloads/ubuntu-base* . Another easy-to-use option would have been to re-download the file directly from the Internet, using Firefox. It was time to mount the virtual hard drive, decompress, and transfer the Ubuntu Base image. In a terminal: sudo bash mount /dev/sda1 /mnt tar xzf ubuntu-base-17.10-base-amd64.tar.gz -C /mnt/
At this point, the virtual hard drive contains the base Ubuntu system. Now, we need to add a kernel, an initial ramdisk, an init script, and a bootloader such as GRUB. Also in the terminal: mount -o bind /dev /mnt/dev mount -o bind /dev/pts /mnt/dev/pts mount -o bind /proc /mnt/proc mount -o bind /run /mnt/run mount -o bind /sys /mnt/sys chroot /mnt/
Our prompt should now change to “root@mint:/#”. All commands we issue within the chroot jail will affect only the virtual hard drive on which Ubuntu Base is to be installed, not the Mint LiveCD. Let us continue: echo “nameserver 8.8.4.4” > /etc/resolv.conf apt update apt upgrade apt install init apt install linux-image-generic
Let us review these commands. The first activates DNS within the chroot, pointing domain name resolution to Google’s server at IP address 8.8.4.4. We then update apt’s cache of available packages. Then, we upgrade all installed software to the latest versions; this is just to stay on the safe side, since very little should have changed and need to be updated in such a small system image. Then, we install the init script. The final command installs whatever version of the generic Linux kernel is current. This requires about 111 MBytes of bandwidth. The apt tool also creates a suitable initial ramdisk. Furthermore, the software installation hooks in the package configuration are smart enough to detect that GRUB has not yet been installed on the target system, and proposes to do so. Naturally, we accept this choice and indicate option 1 (for /dev/sda - notice no trailing “1”) as our destination for GRUB. At this point, I like to install basic networking tools, in order to access the ifconfig and route commands: apt install net-tools
Finally, we need to create a root password, and perhaps also create a new user profile that can be used for non-administrative tasks. Still within the chroot jail: passwd adduser alan The first command prompts us for a new administration password, while the second creates a normal user named “alan”. Adapt to your needs as appropriate. This normal user will not have administrative privileges, unlike the first normal user the standard Ubuntu installer application creates; i.e., the user will not have sudo. This can, naturally, be changed if we so wish. This is basically all we need to have a bootable Ubuntu Base system. We get out of the chroot, unmount the Ubuntu Base virtual hard drive, and perform a system reboot of the virtual computer: exit umount /mnt/*/* ; umount /mnt/* ; umount /mnt shutdown -r now
VirtualBox should now disconnect the Live CD image from the virtual computer’s CD drive. On reboot, the internal virtual hard drive should be booted from, and our new system should boot up in text mode. Log in using either root, or the new user profile created above. For some reason, the root filesystem is mounted read-only on reboot. This can easily be fixed by remounting in read-write mode by hand, and then apt caches may be cleaned releasing yet more disk space. As root: mount -o remount,rw / apt clean
If required, we can also start networking. There are several ways of doing this, but a quick-n-dirty fix taking into account the quirks of VirtualBox’s way of doing NAT networking would be: ifconfig enp0s3 10.0.2.15/24 route add default gw 10.0.2.2 echo “nameserver 8.8.4.4” > /etc/resolv.conf
Once done, our new system consumes just 770 MBytes of disk space, and 30 MBytes of RAM. As a consequence, it is at about the fastest and leanest an Ubuntu-based system of this generation could ever be. However, since no programs have yet been installed, it is also just about useless for a real user. We can change this by installing precisely the amount of software we actually need for a particular task, or set of tasks. For instance, if we needed a file server, one could install sshd or samba, and that would be all. If we needed a database server, install one of the various sql servers available, or couchdb as a more exotic alternative, and nothing more. This could even be turned into a minimalistic Internet Kiosk by installing a simple web browser, though in this case both X11 or Wayland, and a login manager such as lightdm (or even nodm) would also be needed. The possibilities are endless.
Such a lightweight system would be perfect for an older or less capable computer. That being said, in that particular perspective, installing a full desktop environment on top of the minimalistic Ubuntu Base would be something of a contradiction in terms. We would be, in essence, recreating what a normal Ubuntu distribution already offers us. For this reason, Ubuntu Base is perhaps best seen as a means to obtain a platform on which to create very specialized virtual computers, servers on older hardware, or even IoT devices. In that context, starting out from a base system lighter than even Ubuntu Server can make sense.