rtfd/docs/public/debian/system/system.rst

333 lines
5.9 KiB
ReStructuredText
Raw Normal View History

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
2019-12-15 23:08:26 +00:00
.. todo:: sync mirrors
.. todo:: check 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
2021-12-04 17:57:21 +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
2021-12-04 17:57:21 +00:00
* make root directory
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. code:: shell
su
.. code:: shell
2021-12-04 17:57:21 +00:00
mkdir '/squashfs-root'
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 \
2021-12-04 17:57:21 +00:00
--arch 'amd64' \
--variant 'minbase' \
--include 'locales,apt-utils,dialog' \
'bullseye' \
'/squashfs-root' \
'https://deb.debian.org/debian'
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
2021-12-04 17:57:21 +00:00
define default locale
---------------------
2018-01-14 19:58:14 +00:00
* etc/default/locale
2018-05-10 10:54:35 +00:00
::
2021-12-04 17:57:21 +00:00
LANG='en_US.UTF-8'
LANGUAGE='en_US:en'
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'
define locales to generate
--------------------------
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
2021-12-04 17:57:21 +00:00
generate locales
----------------
.. code:: shell
locale-gen
define default keyboard layouts
-------------------------------
* /etc/default/keyboard
::
XKBMODEL="pc105"
XKBLAYOUT="fr,fr"
XKBVARIANT="oss,bepo"
XKBOPTIONS=""
BACKSPACE="guess"
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
2021-12-04 17:57:21 +00:00
for f in 'dev' 'dev/pts' 'proc' 'sys' ; do
mount --bind "/${f}" "/squashfs-root/${f}"
done
chroot '/squashfs-root'
2018-05-10 10:54:35 +00:00
.. todo:: /dev
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
2021-12-04 17:57:21 +00:00
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 \
2021-12-04 17:57:21 +00:00
squashfs-tools
2018-05-10 10:54:35 +00:00
.. code:: shell
2021-12-04 17:57:21 +00:00
apt-get install \
--target-release 'bullseye-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
2021-12-04 17:57:21 +00:00
* empty APT's cache
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. code:: shell
apt-get clean
2018-01-14 19:58:14 +00:00
2021-12-04 17:57:21 +00:00
* exit the environment
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. code:: shell
exit
2018-01-14 19:58:14 +00:00
2021-12-04 17:57:21 +00:00
* untie links to host system
2018-01-14 19:58:14 +00:00
2018-05-10 10:54:35 +00:00
.. code:: shell
2021-12-04 17:57:21 +00:00
for f in 'sys' 'proc' 'dev/pts' 'dev' ; do
umount --lazy "/squashfs-root/${f}"
done
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
2021-12-04 17:57:21 +00:00
mksquashfs \
'/squashfs-root' \
'filesystem.squashfs' \
-b '1m' \
-comp 'zstd' \
-Xcompression-level 22