Outils pour utilisateurs

Outils du site


issue127:tutoriel1

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 disponibles. Dans cet article, je voudrais vous montrer comment Ubuntu Base peut être installé puis ajusté pour obtenir un système fonctionnel avec un minimum de logiciels.

Ubuntu Base est décrit sur la page appropriée du Wiki d'Ubuntu : https://wiki.ubuntu.com/Base. En substance, nous démarrons 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 d'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 tests 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 dû activer VT-x (technologie de virtualisation) dans les paramètres du BIOS de mon ordinateur. Si ce n'était 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 - ou d'autres moyens pour réaliser un système fonctionnel minimal - seraient nécessaires pour le premier démarrage du système. Le réseau serait également 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 les 6-7 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 pouvant être considérablement réduit pour le système fini). • Disque dur VDI dynamiquement alloué de 8.0 Go de taille (très exagéré aussi).

Ensuite, j'ai connecté le disque dur virtuel à une image ISO de Linux Mint 18 Cinammon (64-bit) que j'avais dans mon dossier Téléchargements, pour l'utiliser pour le démarrage initial du système cible.

J'ai ensuite démarré la machine virtuelle à partir de l'image CD de Linux Mint. Une fois lancée, j'ai utilisé gparted pour créer une table de partition ms-dos sur le disque dur virtuel, /dev/sda, et une partition unique formatée en ext4. Tout autre outil de gestion du partitionnement peut être utilisé pour cela, tels que fdisk, parted ou des équivalents graphiques.

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/

J'ai transféré le fichier compressé d'Ubuntu Base sur l'ordinateur hôte en utilisant SSH dans une fenêtre de terminal :

scp alan@10.0.2.2:/home/alan/Downloads/ubuntu-base

Une autre option facile à mettre en œuvre serait de re-télécharger directement le fichier d'Internet en utilisant Firefox.

C'était le moment de monter le disque dur virtuel, et de décompresser et transférer l'image d'Ubuntu Base.

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/

À ce stade, le disque dur virtuel contient le système Ubuntu de base. Maintenant, nous avons besoin d'ajouter un noyau, un ramdisk initial, un script d'initialisation et un chargeur de démarrage tel que GRUB. Toujours dans un 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

Notre prompt devrait s'être maintenant changé en « root@mint:/# ». Toutes les commandes que nous émettons dans la prison chroot ne concerneront que le disque dur virtuel sur lequel Ubuntu Base est en cours d'installation, pas le LiveCD Mint. Continuons :

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

Passons en revue ces commandes. La première active DNS dans le chroot, pointant la résolution de nom de domaine vers le serveur de Google à l'adresse 8.8.4.4. Ensuite, nous mettons le cache d'apt à jour des paquets disponibles. Puis, nous mettons à niveau tous les logiciels installés vers les versions les plus récentes. C'est simplement pour rester dans une démarche saine, car très peu de changements a dû avoir lieu dans une si petite image, qui nécessiterait une mise à jour. Ensuite, nous installons le script init. La commande finale installe la version actuelle du noyau Linux générique. Ceci nécessite environ 111 Mo de bande passante. L'outil apt crée aussi un ramdisk initial convenable. De plus, les « hooks » d'installation des logiciels dans la configuration des paquets sont assez intelligents pour détecter que GRUB n'a pas encore été installé sur le système cible ; aussi, ils proposent de le faire. Naturellement, nous acceptons ce choix et indiquons l'option 1 (celle de /dev/sda - remarquez l'absence d'une barre oblique finale) comme destination de notre GRUB.

Arrivé ici, je préfère installer les outils de base de gestion du réseau, pour pouvoir accéder aux commandes ifconfig et route :

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

Enfin, nous devons créer un mot de passe pour root et peut-être aussi un nouveau profil d'utilisateur qui peut être utilisé pour les tâches non-administratives. Toujours dans la prison chroot :

passwd

adduser alan

La première commande nous demande le nouveau mot de passe d'administration, alors que la seconde crée un utilisateur ordinaire nommé « alan ». Adaptez ceci à vos propres besoins. L'utilisateur normal n'aura pas de privilèges d'administration, contrairement au premier utilisateur ordinaire que crée l'application d'installation d'un Ubuntu standard ; c-à-d, pas de sudo. Ceci peut, bien sûr, être modifié si vous le souhaitez.

C'est essentiellement tout ce dont nous avons besoin pour avoir un système Ubuntu Base lançable. Nous quittons le chroot, démontons le disque dur virtuel d'Ubuntu Base, et lançons un redémarrage du système sur l'ordinateur virtuel :

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

VirtualBox devrait maintenant déconnecter l'image Live CD du lecteur de CD de l'ordinateur virtuel. Le redémarrage devrait s'effectuer sur le disque dur virtuel interne et notre nouveau système devrait s'ouvrir en mode texte. Identifiez-vous en utilisant, soit root, soit le nouveau profil utilisateur créé ci-dessus.

Pour une raison quelconque, le système de fichiers root est monté en lecture seule au redémarrage. Ceci peut facilement être résolu en le remontant à la main en lecture-écriture ; ensuite, le cache apt peut être nettoyé pour libérer de l'espace disque. Comme 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

Si nécessaire, nous pouvons aussi démarrer la gestion de réseau. Il y a plusieurs façons de le faire, mais une solution aussi rapide que grossière de prendre en compte les bizarreries dans la façon qu'a VirtualBox de gérer le réseau NAT serait :

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.

Une fois fait, notre nouveau système consomme juste 770 Mo d'espace disque et 30 Mo de RAM. En conséquence, il est le système le plus rapide et le plus réduit de sa génération basé sur Ubuntu qui puisse être. Cependant, comme aucun programme n'a encore été installé, il est aussi sans utilité pour un véritable utilisateur. Nous pouvons changer cela en installant précisément la quantité de logiciels dont nous avons réellement besoin pour une tâche particulière, ou un ensemble de tâches. Par exemple, si nous avons besoin d'un serveur de fichier, on peut installer sshd ou samba, et ce sera tout. Si nous avons besoin d'un serveur de base de données, installez un des nombreux serveurs sql disponibles, ou couchdb comme alternative plus exotique, et rien d'autre. Il peut aussi être transformé en Kiosk Internet minimaliste en installant un navigateur Web simple, bien que, dans ce cas, X11 ou Wayland, et un gestionnaire d'identification comme lightdm (ou même nodm), soient aussi nécessaires. Les possibilités sont infinies.

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.

Un tel système léger serait parfait pour un ordinateur ancien ou peu puissant. Cela étant dit, dans cette perspective précise, l'installation d'un environnement complet de bureau par-dessus cet Ubuntu Base minimaliste serait contradictoire. Nous serions, en fait, en train de recréer ce que nous offre une distribution normale d'Ubuntu. Pour cette raison, la meilleure description que l'on puisse faire d'Ubuntu Base est sans doute celle d'un moyen d'obtenir une plateforme sur laquelle créer des ordinateurs virtuels très spécialisés, des serveurs sur du vieux matériel ou même des dispositifs connectés (IoT). Dans ce contexte, s'appuyer sur un système de base plus léger que même Ubuntu Server peut être logique.

issue127/tutoriel1.txt · Dernière modification : 2017/12/06 09:11 de auntiee