Read The Fancy Docs https://rtfd.rwx.work
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

327 lines
5.7 KiB

3 years ago
******************
Image from scratch
******************
5 years ago
5 years ago
.. todo::
5 years ago
4 years ago
* /etc/motd
5 years ago
5 years ago
Choices
=======
5 years ago
5 years ago
have up-to-date mirrors available
---------------------------------
5 years ago
3 years ago
.. todo:: sync mirrors
.. todo:: check mirrors
5 years ago
3 years ago
critical base packages
----------------------
5 years ago
3 years ago
+-----------+--------------------------------------------------+
| locales | to get localization binaries for system messages |
+-----------+--------------------------------------------------+
| apt-utils | otherwise packages configuration gets delayed |
+-----------+--------------------------------------------------+
| dialog | to have user interaction possible with APT |
+-----------+--------------------------------------------------+
5 years ago
5 years ago
decide the desired type of system
---------------------------------
5 years ago
3 years ago
* will the system run
* 64 bits?
* 32 bits?
* both?
* will the system be run by
* a physical machine?
* a virtual machine?
* a container?
* a container inside a virtual machine?
* will the system be stored
* read-write, as a file system on a dedicated partition?
* read-only, as a single file loaded in RAM at boot time?
5 years ago
5 years ago
Install required tools
======================
5 years ago
3 years ago
============== ========================================
debootstrap generate a minimal base file system
squashfs-tools archive or unarchive a file system image
============== ========================================
5 years ago
3 years ago
.. code:: shell
4 years ago
3 years ago
apt install debootstrap squashfs-tools
5 years ago
5 years ago
Create a base file hierarchy
============================
5 years ago
5 years ago
prepare the system's directory
------------------------------
5 years ago
3 years ago
* become root
* make a directory and step into it
5 years ago
4 years ago
.. code:: shell
su
.. code:: shell
3 years ago
mkdir -p "path"
cd "path"
5 years ago
5 years ago
generate the minimal base
-------------------------
5 years ago
4 years ago
.. code:: shell
debootstrap \
--arch="amd64" \
--include="locales,apt-utils,dialog" \
--variant="minbase" \
"stretch" \
. \
"miroir"
5 years ago
5 years ago
Configure preinstalled packages
===============================
5 years ago
5 years ago
define default keyboard layouts
-------------------------------
5 years ago
* /etc/default/keyboard
4 years ago
::
XKBMODEL="pc105"
XKBLAYOUT="fr,fr"
XKBVARIANT="oss,bepo"
XKBOPTIONS=""
BACKSPACE="guess"
5 years ago
5 years ago
define default locales to generate
----------------------------------
5 years ago
* etc/default/locale
4 years ago
::
LANG=en_US.UTF-8
4 years ago
LANGUAGE=en_US:en
4 years ago
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="fr_FR.UTF-8"
LC_NAME="fr_FR.UTF-8"
LC_ADDRESS="fr_FR.UTF-8"
LC_TELEPHONE="fr_FR.UTF-8"
LC_MEASUREMENT="fr_FR.UTF-8"
LC_IDENTIFICATION="fr_FR.UTF-8"
5 years ago
* etc/locale.gen
4 years ago
::
en_US.UTF-8 UTF-8
fr_FR.UTF-8 UTF-8
5 years ago
5 years ago
[configure command shell](../bash/index.md)
-------------------------------------------
5 years ago
5 years ago
[configure package manager](../apt/index.md)
--------------------------------------------
5 years ago
5 years ago
redefine hostname
-----------------
5 years ago
4 years ago
.. code:: shell
echo "hostname" > "etc/hostname"
5 years ago
5 years ago
provide known file systems
--------------------------
5 years ago
* etc/fstab
Volume temporaire en RAM
4 years ago
::
tmpfs /tmp tmpfs auto,mode=1777 0 0
5 years ago
5 years ago
Install additional packages
===========================
5 years ago
5 years ago
switch into context
-------------------
5 years ago
4 years ago
.. code:: shell
mount --bind /proc proc
mount --bind /sys sys
chroot .
.. todo:: /dev
5 years ago
5 years ago
generate locales
----------------
5 years ago
4 years ago
.. code:: shell
locale-gen
5 years ago
5 years ago
define root password
--------------------
5 years ago
4 years ago
.. code:: shell
passwd
5 years ago
5 years ago
user, guest, sudo
-----------------
5 years ago
4 years ago
.. code:: shell
apt-get install sudo
5 years ago
4 years ago
useradd -s /bin/bash user
mkdir /home/user
chown user: /home/user
adduser user sudo
5 years ago
4 years ago
useradd -s /bin/bash guest
chown guest: /home/guest
5 years ago
5 years ago
authentications: passwords, SSH keys
------------------------------------
5 years ago
4 years ago
.. todo:: files
5 years ago
5 years ago
upgrade system
--------------
5 years ago
* dans tous les cas :
4 years ago
.. code:: shell
apt-get update
apt-get upgrade
5 years ago
* si besoin, car des paquets rétroportés modifient la distribution :
4 years ago
.. code:: shell
apt-get dist-upgrade
5 years ago
5 years ago
apply system type elements
--------------------------
5 years ago
4 years ago
================= ==================================================
linux-image-amd64 s’il ne s’agit pas d’un conteneur
live-boot si à destination de boot live
systemd-sysv sans quoi le système ne démarrera pas complètement
================= ==================================================
5 years ago
4 years ago
.. code:: shell
apt-get install -t stretch-backports "linux-image-amd64"
apt-get install "live-boot"
5 years ago
5 years ago
----
initialization settings
-----------------------
5 years ago
4 years ago
.. code:: shell
apt-get install -t stretch-backports "systemd-sysv"
5 years ago
* etc/sysctl.conf
Espace mémoire maximum allouable (à augmenter si hébergement de conteneurs)
Pourcentage de RAM disponible avant utilisation de la partition d’échange
4 years ago
.. code:: ini
vm.max_map_count=1048576
vm.swappiness=0
5 years ago
5 years ago
keeping things light
--------------------
5 years ago
4 years ago
.. code:: shell
apt-get install --no-install-recommends …
5 years ago
5 years ago
install useful packages
-----------------------
5 years ago
4 years ago
.. code:: shell
apt-get install \
bash-completion \
lxc \
less nano vim \
pciutils usbutils \
python3 \
squashfs-tools \
.. code:: shell
apt-get install -t "stretch-backports" \
debootstrap \
5 years ago
5 years ago
install other packages
----------------------
5 years ago
[Choix de paquets commentés](packages.md)
4 years ago
.. code:: shell
apt-get install "package1" …
apt-get install -t stretch-backports "package1" …
5 years ago
5 years ago
properly switch back from context
---------------------------------
5 years ago
* vider le cache d’APT
4 years ago
.. code:: shell
apt-get clean
5 years ago
* s’extraire de l’environnement
4 years ago
.. code:: shell
exit
5 years ago
* démonter les liens au système hôte
4 years ago
.. code:: shell
umount sys
umount proc
5 years ago
5 years ago
clean up commands history
-------------------------
5 years ago
* root/.bash_history
5 years ago
Configure installed packages
============================
5 years ago
4 years ago
.. todo:: files
5 years ago
5 years ago
Archive prepared file system
============================
.. code:: shell
mksquashfs . "../name.squashfs" -comp "xz"