rtfd/docs/public/debian/system.rst

326 lines
5.7 KiB
ReStructuredText
Raw Normal View History

2019-08-03 13:48:05 +00:00
******************
Image from scratch
******************
2018-01-14 19:58:14 +00:00
2018-01-14 20:08:01 +00:00
.. todo::
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
* /etc/motd
2018-01-14 19:58:14 +00:00
2018-01-14 20:08:01 +00:00
Choices
=======
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
have up-to-date mirrors available
---------------------------------
2018-01-14 19:58:14 +00:00
2018-05-10 10:56:18 +00:00
.. todo:: mirrors
2018-01-14 19:58:14 +00:00
2019-08-03 13:48:05 +00:00
critical base packages
----------------------
2018-01-14 19:58:14 +00:00
2019-08-03 13:48:05 +00:00
+-----------+--------------------------------------------------+
| locales | to get localization binaries for system messages |
+-----------+--------------------------------------------------+
| apt-utils | otherwise packages configuration gets delayed |
+-----------+--------------------------------------------------+
| dialog | to have user interaction possible with APT |
+-----------+--------------------------------------------------+
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
decide the desired type of system
---------------------------------
2018-01-14 19:58:14 +00:00
2019-12-15 10:52:11 +00:00
* 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?
2018-01-14 19:58:14 +00:00
2018-01-14 20:08:01 +00:00
Install required tools
======================
2018-01-14 19:58:14 +00:00
2019-08-03 14:05:49 +00:00
============== ========================================
debootstrap generate a minimal base file system
squashfs-tools archive or unarchive a file system image
============== ========================================
2018-01-14 19:58:14 +00:00
2019-08-03 14:05:49 +00:00
.. code:: shell
2018-05-10 10:54:35 +00:00
2019-08-03 14:05:49 +00:00
apt install debootstrap squashfs-tools
2018-01-14 19:58:14 +00:00
2018-01-14 20:08:01 +00:00
Create a base file hierarchy
============================
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
prepare the system's directory
------------------------------
2018-01-14 19:58:14 +00:00
2019-12-15 10:52:11 +00:00
* become root
* make a directory and step into it
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. code:: shell
su
.. code:: shell
2019-12-15 10:52:11 +00:00
mkdir -p "path"
cd "path"
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
generate the minimal base
-------------------------
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. code:: shell
debootstrap \
--arch="amd64" \
--include="locales,apt-utils,dialog" \
--variant="minbase" \
"stretch" \
. \
"miroir"
2018-01-14 19:58:14 +00:00
2018-01-14 20:08:01 +00:00
Configure preinstalled packages
===============================
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
define default keyboard layouts
-------------------------------
2018-01-14 19:58:14 +00:00
* /etc/default/keyboard
2018-05-10 10:54:35 +00:00
::
XKBMODEL="pc105"
XKBLAYOUT="fr,fr"
XKBVARIANT="oss,bepo"
XKBOPTIONS=""
BACKSPACE="guess"
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
define default locales to generate
----------------------------------
2018-01-14 19:58:14 +00:00
* etc/default/locale
2018-05-10 10:54:35 +00:00
::
LANG=en_US.UTF-8
2018-07-26 07:08:37 +00:00
LANGUAGE=en_US:en
2018-05-10 10:54:35 +00:00
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"
2018-01-14 19:58:14 +00:00
* etc/locale.gen
2018-05-10 10:54:35 +00:00
::
en_US.UTF-8 UTF-8
fr_FR.UTF-8 UTF-8
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
[configure command shell](../bash/index.md)
-------------------------------------------
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
[configure package manager](../apt/index.md)
--------------------------------------------
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
redefine hostname
-----------------
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. code:: shell
echo "hostname" > "etc/hostname"
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
provide known file systems
--------------------------
2018-01-14 19:58:14 +00:00
* etc/fstab
Volume temporaire en RAM
2018-05-10 10:54:35 +00:00
::
tmpfs /tmp tmpfs auto,mode=1777 0 0
2018-01-14 19:58:14 +00:00
2018-01-14 20:08:01 +00:00
Install additional packages
===========================
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
switch into context
-------------------
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. code:: shell
mount --bind /proc proc
mount --bind /sys sys
chroot .
.. todo:: /dev
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
generate locales
----------------
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. code:: shell
locale-gen
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
define root password
--------------------
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. code:: shell
passwd
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
user, guest, sudo
-----------------
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. code:: shell
apt-get install sudo
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
useradd -s /bin/bash user
mkdir /home/user
chown user: /home/user
adduser user sudo
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
useradd -s /bin/bash guest
chown guest: /home/guest
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
authentications: passwords, SSH keys
------------------------------------
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. todo:: files
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
upgrade system
--------------
2018-01-14 19:58:14 +00:00
* dans tous les cas :
2018-05-10 10:54:35 +00:00
.. code:: shell
apt-get update
apt-get upgrade
2018-01-14 19:58:14 +00:00
* si besoin, car des paquets rétroportés modifient la distribution :
2018-05-10 10:54:35 +00:00
.. code:: shell
apt-get dist-upgrade
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
apply system type elements
--------------------------
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
================= ==================================================
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
================= ==================================================
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. code:: shell
apt-get install -t stretch-backports "linux-image-amd64"
apt-get install "live-boot"
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
----
initialization settings
-----------------------
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. code:: shell
apt-get install -t stretch-backports "systemd-sysv"
2018-01-14 19:58:14 +00:00
* 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
2018-05-10 10:54:35 +00:00
.. code:: ini
vm.max_map_count=1048576
vm.swappiness=0
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
keeping things light
--------------------
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. code:: shell
apt-get install --no-install-recommends …
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
install useful packages
-----------------------
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. 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 \
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
install other packages
----------------------
2018-01-14 19:58:14 +00:00
[Choix de paquets commentés](packages.md)
2018-05-10 10:54:35 +00:00
.. code:: shell
apt-get install "package1" …
apt-get install -t stretch-backports "package1" …
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
properly switch back from context
---------------------------------
2018-01-14 19:58:14 +00:00
* vider le cache d’APT
2018-05-10 10:54:35 +00:00
.. code:: shell
apt-get clean
2018-01-14 19:58:14 +00:00
* s’extraire de l’environnement
2018-05-10 10:54:35 +00:00
.. code:: shell
exit
2018-01-14 19:58:14 +00:00
* démonter les liens au système hôte
2018-05-10 10:54:35 +00:00
.. code:: shell
umount sys
umount proc
2018-01-14 19:58:14 +00:00
2018-01-14 22:08:42 +00:00
clean up commands history
-------------------------
2018-01-14 19:58:14 +00:00
* root/.bash_history
2018-01-14 20:08:01 +00:00
Configure installed packages
============================
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. todo:: files
2018-01-14 19:58:14 +00:00
2018-01-14 20:08:01 +00:00
Archive prepared file system
============================
.. code:: shell
mksquashfs . "../name.squashfs" -comp "xz"