|
@@ -0,0 +1,326 @@
|
|
|
|
|
+% Configuration de deux disques avec LVM
|
|
|
|
|
+
|
|
|
|
|
+:::information
|
|
|
|
|
+
|
|
|
|
|
+Sur ce schéma de partitionnement, on ne privilégie pas la fiabilité ou la redondance mais l'espace disque.
|
|
|
|
|
+
|
|
|
|
|
+Ici, ce serveur (de secours) est configuré pour être en *backup* d'un autre serveur (principal): si le serveur principal plante, le serveur de secours prend le relais.
|
|
|
|
|
+
|
|
|
|
|
+La sauvegarde des données n'est donc pas ici assurée: elle doit l'être par un autre moyen, en mettant une politique de sauvegarde réfléchie.
|
|
|
|
|
+
|
|
|
|
|
+:::
|
|
|
|
|
+
|
|
|
|
|
+# Schéma de partitionnement
|
|
|
|
|
+
|
|
|
|
|
+:::warning
|
|
|
|
|
+
|
|
|
|
|
+Tuto à refaire: on va partir en RAID0 car plus simple pour un déchiffrement en une fois du système.
|
|
|
|
|
+
|
|
|
|
|
+:::
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+## Partition de boot
|
|
|
|
|
+
|
|
|
|
|
+On crée une partition de boot uniquement sur le premier disque: 512 Mo
|
|
|
|
|
+
|
|
|
|
|
+## *Swap*
|
|
|
|
|
+
|
|
|
|
|
+On crée deux partitions (une sur chaque disque) de 11,6 Go.
|
|
|
|
|
+
|
|
|
|
|
+## Données
|
|
|
|
|
+
|
|
|
|
|
+Le reste des disques sera affecté aux données.
|
|
|
|
|
+
|
|
|
|
|
+# Partitionnement
|
|
|
|
|
+
|
|
|
|
|
+## Vérification de la présence d'UEFI
|
|
|
|
|
+
|
|
|
|
|
+:::warning
|
|
|
|
|
+
|
|
|
|
|
+Bien vérifier si vous avez un système UEFI:
|
|
|
|
|
+
|
|
|
|
|
+```bash
|
|
|
|
|
+ls /sys/firmware/efi
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+**Si ce fichier n'existe pas, il faut utiliser une table MBR**
|
|
|
|
|
+
|
|
|
|
|
+Source: [Check if Computer Uses UEFI or Legacy BIOS [Linux & Windows]](https://itsfoss.com/check-uefi-or-bios/)
|
|
|
|
|
+
|
|
|
|
|
+:::
|
|
|
|
|
+
|
|
|
|
|
+Dans le cas contraire: il faut utiliser une table de partition MBR.
|
|
|
|
|
+
|
|
|
|
|
+## Partitionnement du premier disque
|
|
|
|
|
+
|
|
|
|
|
+```bash
|
|
|
|
|
+fdisk /dev/sda
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+### Création de la partition de boot
|
|
|
|
|
+
|
|
|
|
|
+Utilisation de la commande `n`
|
|
|
|
|
+
|
|
|
|
|
+```
|
|
|
|
|
+Command (m for help): n
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+Ensuite, on crée la partition numéro `1`
|
|
|
|
|
+
|
|
|
|
|
+```
|
|
|
|
|
+Partition number (1-128, default 1): 1
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+On laisse la valeur par défaut pour le premier secteur en appuyant sur `Entrée`
|
|
|
|
|
+
|
|
|
|
|
+```
|
|
|
|
|
+First sector (2048-3907029134, default 2048):
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+Puis on indique la taille `+512M`:
|
|
|
|
|
+
|
|
|
|
|
+```
|
|
|
|
|
+Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-3907029134, default 3907028991): +512M
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+Le message suivant indique que la première partition est bien créée:
|
|
|
|
|
+
|
|
|
|
|
+```
|
|
|
|
|
+Created a new partition 1 of type 'Linux filesystem' and of size 512 MiB.
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+### Création de la partition de Swap
|
|
|
|
|
+
|
|
|
|
|
+À nouveau, on utilise la commande `n`, mais cette fois on choisit une taille en secteurs (qui correspond ici à 11,5Go):
|
|
|
|
|
+
|
|
|
|
|
+```
|
|
|
|
|
+Command (m for help): n [ENTREE]
|
|
|
|
|
+Partition number (2-128, default 2): [ENTREE]
|
|
|
|
|
+First sector (1050624-3907029134, default 1050624): [ENTREE]
|
|
|
|
|
+Last sector, +/-sectors or +/-size{K,M,G,T,P} (1050624-3907029134, default 3907028991): +24117248 [ENTREE]
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+Le message de confirmation permet de vérifier la taille:
|
|
|
|
|
+
|
|
|
|
|
+```
|
|
|
|
|
+Created a new partition 2 of type 'Linux filesystem' and of size 11.5 GiB.
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+On modifie ensuite le type de partition pour la `2` avec la commande `t`:
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+```
|
|
|
|
|
+Command (m for help): t
|
|
|
|
|
+Partition number (1,2, default 2): 2
|
|
|
|
|
+Partition type or alias (type L to list all): 19
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+### Création de la partition principale
|
|
|
|
|
+
|
|
|
|
|
+Ici, on appuie sur `Entrée` pour laisser les valeurs par défaut:
|
|
|
|
|
+
|
|
|
|
|
+```
|
|
|
|
|
+Command (m for help): n
|
|
|
|
|
+Partition number (3-128, default 3):
|
|
|
|
|
+First sector (25167873-3907029134, default 25169920):
|
|
|
|
|
+Last sector, +/-sectors or +/-size{K,M,G,T,P} (25169920-3907029134, default 3907028991):
|
|
|
|
|
+
|
|
|
|
|
+Created a new partition 3 of type 'Linux filesystem' and of size 1.8 TiB.
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+Et on modifie le type de la partition pour la passer en `Linux LVM`:
|
|
|
|
|
+
|
|
|
|
|
+```
|
|
|
|
|
+Command (m for help): t
|
|
|
|
|
+Partition number (1-3, default 3):
|
|
|
|
|
+Partition type or alias (type L to list all): 43
|
|
|
|
|
+
|
|
|
|
|
+Changed type of partition 'Linux LVM' to 'Linux LVM'.
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+On termine par la commande `w` pour sauvegarder les changements de la nouvelle table des partitions:
|
|
|
|
|
+
|
|
|
|
|
+```
|
|
|
|
|
+Command (m for help): w
|
|
|
|
|
+The partition table has been altered.
|
|
|
|
|
+Calling ioctl() to re-read partition table.
|
|
|
|
|
+Syncing disks.
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+## Partitionnement du second disque
|
|
|
|
|
+
|
|
|
|
|
+Cette fois, on ne crée que deux partitions:
|
|
|
|
|
+
|
|
|
|
|
+- une Swap de `+24117248` secteurs
|
|
|
|
|
+- une principale sur le reste du disque
|
|
|
|
|
+
|
|
|
|
|
+```bash
|
|
|
|
|
+fdisk /dev/sdb
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+```
|
|
|
|
|
+Command (m for help): g
|
|
|
|
|
+Created a new GPT disklabel (GUID: EB07A51E-0F98-0949-8126-E55071DD5879).
|
|
|
|
|
+
|
|
|
|
|
+Command (m for help): n
|
|
|
|
|
+Partition number (1-128, default 1):
|
|
|
|
|
+First sector (2048-3907029134, default 2048):
|
|
|
|
|
+Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-3907029134, default 3907028991): +24117248
|
|
|
|
|
+
|
|
|
|
|
+Created a new partition 1 of type 'Linux filesystem' and of size 11.5 GiB.
|
|
|
|
|
+
|
|
|
|
|
+Command (m for help): t
|
|
|
|
|
+Selected partition 1
|
|
|
|
|
+Partition type or alias (type L to list all): 19
|
|
|
|
|
+Changed type of partition 'Linux filesystem' to 'Linux swap'.
|
|
|
|
|
+
|
|
|
|
|
+Command (m for help): n
|
|
|
|
|
+Partition number (2-128, default 2):
|
|
|
|
|
+First sector (24119297-3907029134, default 24121344):
|
|
|
|
|
+Last sector, +/-sectors or +/-size{K,M,G,T,P} (24121344-3907029134, default 3907028991):
|
|
|
|
|
+
|
|
|
|
|
+Created a new partition 2 of type 'Linux filesystem' and of size 1.8 TiB.
|
|
|
|
|
+
|
|
|
|
|
+Command (m for help): t
|
|
|
|
|
+Partition number (1,2, default 2):
|
|
|
|
|
+Partition type or alias (type L to list all): 43
|
|
|
|
|
+
|
|
|
|
|
+Changed type of partition 'Linux filesystem' to 'Linux LVM'.
|
|
|
|
|
+
|
|
|
|
|
+Command (m for help): w
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+# Configuration de LVM
|
|
|
|
|
+
|
|
|
|
|
+## Installation de LVM
|
|
|
|
|
+
|
|
|
|
|
+```bash
|
|
|
|
|
+apt update && apt install -y cryptsetup lvm2 debian-keyring
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+## Création des deux Physical Volumes
|
|
|
|
|
+
|
|
|
|
|
+Création sur la partition 3 du premier disque:
|
|
|
|
|
+
|
|
|
|
|
+```
|
|
|
|
|
+pvcreate /dev/sda3
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+Création sur la partition 2 du second disque:
|
|
|
|
|
+
|
|
|
|
|
+```
|
|
|
|
|
+pvcreate /dev/sdb2
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+## Ajout des PV à un nouveau Volume Group
|
|
|
|
|
+
|
|
|
|
|
+Création du VG
|
|
|
|
|
+
|
|
|
|
|
+```bash
|
|
|
|
|
+vgcreate debian-zeta-vg /dev/sda3
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+Extension du VG
|
|
|
|
|
+
|
|
|
|
|
+```bash
|
|
|
|
|
+vgextend debian-zeta-vg /dev/sdb2
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+Vérification (ici le VG doit faire 3,6To):
|
|
|
|
|
+
|
|
|
|
|
+```
|
|
|
|
|
+# vgdisplay debian-zeta-vg
|
|
|
|
|
+ --- Volume group ---
|
|
|
|
|
+ VG Name debian-zeta-vg
|
|
|
|
|
+ System ID
|
|
|
|
|
+ Format lvm2
|
|
|
|
|
+ Metadata Areas 2
|
|
|
|
|
+ Metadata Sequence No 2
|
|
|
|
|
+ VG Access read/write
|
|
|
|
|
+ VG Status resizable
|
|
|
|
|
+ MAX LV 0
|
|
|
|
|
+ Cur LV 0
|
|
|
|
|
+ Open LV 0
|
|
|
|
|
+ Max PV 0
|
|
|
|
|
+ Cur PV 2
|
|
|
|
|
+ Act PV 2
|
|
|
|
|
+ VG Size <3.62 TiB
|
|
|
|
|
+ PE Size 4.00 MiB
|
|
|
|
|
+ Total PE 947846
|
|
|
|
|
+ Alloc PE / Size 0 / 0
|
|
|
|
|
+ Free PE / Size 947846 / <3.62 TiB
|
|
|
|
|
+ VG UUID i58CcT-sZgA-mjZc-8Kb1-qhLW-LOZP-rlI0if
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+## Création des volumes logiques
|
|
|
|
|
+
|
|
|
|
|
+Pour ce serveur Proxmox, on aura deux partitions LVM:
|
|
|
|
|
+
|
|
|
|
|
+- une partition de démarrage
|
|
|
|
|
+- une partition de données
|
|
|
|
|
+
|
|
|
|
|
+```bash
|
|
|
|
|
+lvcreate -L 100G -n lv_root debian-zeta-vg
|
|
|
|
|
+lvcreate -l 100%FREE -n lv_data debian-zeta-vg
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+## Formater et monter les volumes
|
|
|
|
|
+
|
|
|
|
|
+Formater en ext4 :
|
|
|
|
|
+
|
|
|
|
|
+```bash
|
|
|
|
|
+mkfs.ext4 /dev/vg_raid/lv_root
|
|
|
|
|
+mkfs.ext4 /dev/vg_raid/lv_data
|
|
|
|
|
+mkfs.ext4 /dev/sda1
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+# Installation du système Debian
|
|
|
|
|
+
|
|
|
|
|
+## Debootstrap
|
|
|
|
|
+
|
|
|
|
|
+Aller sur la page [Debian -- Details of package debootstrap in bookworm](https://packages.debian.org/bookworm/debootstrap)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+Récupérer l'adresse dans la section *Télécharger* et en cliquant sur `all`
|
|
|
|
|
+
|
|
|
|
|
+Copier un des liens et l'utiliser pour télécharger sur le serveur:
|
|
|
|
|
+
|
|
|
|
|
+```bash
|
|
|
|
|
+wget http://ftp.fr.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.128+nmu2+deb12u2_all.deb
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+On l'installe:
|
|
|
|
|
+
|
|
|
|
|
+```bash
|
|
|
|
|
+dpkg -i debootstrap*.deb && rm -f debootstrap*.deb
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+## Montage des volumes pour l'installation
|
|
|
|
|
+
|
|
|
|
|
+Rappel:
|
|
|
|
|
+
|
|
|
|
|
+- /dev/sda1 > /boot
|
|
|
|
|
+- mount /dev/debian-zeta-vg/lv_root > /
|
|
|
|
|
+- mount /dev/debian-zeta-vg/lv_data > /data
|
|
|
|
|
+
|
|
|
|
|
+Le tout étant dans un premier temps monté sur le point de montage `/mnt`
|
|
|
|
|
+
|
|
|
|
|
+```bash
|
|
|
|
|
+mount /dev/debian-zeta-vg/lv_root
|
|
|
|
|
+mkdir /mnt/data
|
|
|
|
|
+mount /dev/debian-zeta-vg/lv_data /mnt/data/
|
|
|
|
|
+mkdir /mnt/boot
|
|
|
|
|
+mount /dev/sda1 /mnt/boot
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+## Chiffrement des volumes
|
|
|
|
|
+
|