End of Week 1 - Day 2
This commit is contained in:
@@ -33,7 +33,7 @@ sudo lxc-start -n NOM_CONTENEUR
|
||||
sudo lxc-attach -n NOM_CONTENEUR
|
||||
|
||||
# Stopper
|
||||
sudo lxc-
|
||||
sudo lxc-stop -n NOM_CONTENEUR
|
||||
|
||||
# Supprimer
|
||||
sudo lxc-destroy -n NOM_CONTENEUR
|
||||
@@ -52,4 +52,110 @@ lxc.mount.entry = /dossier_hote dossier_interne_conteneur none bind,create=dir 0
|
||||
|
||||
# Méthode 2 : Montage d'un disque entier ou partition de l'hôte
|
||||
lxc.mount.entry = /dev/disque_ou_partition dossier_interne_conteneur FS_type defaults,create=dir 0 0
|
||||
```
|
||||
|
||||
## Exercice 1
|
||||
|
||||
https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/x86_64/alpine-xen-3.17.10-x86_64.iso
|
||||
|
||||
```
|
||||
wget https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-13.1.0-amd64-netinst.iso
|
||||
|
||||
mv debian-13.1.0-amd64-netinst.iso debian.iso
|
||||
|
||||
sudo chmod 666 debian.iso
|
||||
```
|
||||
|
||||
Ensuite
|
||||
|
||||
```
|
||||
sudo virt-install \
|
||||
--name test-vm \
|
||||
--os-variant=debiantesting \
|
||||
--ram 2048 \
|
||||
--vcpus 2 \
|
||||
--location ./debian.iso \
|
||||
--disk path=/var/lib/libvirt/images/vm.qcow2,size=15,format=qcow2 \
|
||||
--graphics none \
|
||||
--console pty,target_type=serial \
|
||||
--extra-args "console=ttys0,115200n8 serial"
|
||||
```
|
||||
|
||||
`virsh attach-interface --type bridge --source enp0s3 --model virtio test-vm`
|
||||
|
||||
## Exercice 2
|
||||
|
||||
### Petit A
|
||||
|
||||
C'est installé.
|
||||
|
||||
### Petit B
|
||||
|
||||
```
|
||||
sudo lxc-create -n ConteneurDebian -t download
|
||||
# debian, bullseye, amd64
|
||||
|
||||
sudo lxc-start ConteneurDebian
|
||||
sudo lxc-attach ConteneurDebian
|
||||
|
||||
### In the container ###
|
||||
uname -a
|
||||
|
||||
> Linux ConteneurDebian 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64 GNU/Linux
|
||||
|
||||
cat /proc/version
|
||||
> Linux version 6.1.0-40-amd64 (gcc-12 (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20)
|
||||
|
||||
exit
|
||||
|
||||
### Outside the container ###
|
||||
|
||||
sudo lxc-ls
|
||||
> ConteneurDebian Test-Linux
|
||||
|
||||
sudo lxc-ls --running
|
||||
> ConteneurDebian
|
||||
|
||||
sudo lxc-stop ConteneurDebian
|
||||
|
||||
sudo lxc-ls --running
|
||||
>
|
||||
```
|
||||
|
||||
### Petit C
|
||||
|
||||
```
|
||||
sudo ls -glAiF /var/lib/lxc/
|
||||
> ConteneurDebian
|
||||
> Test-Linux
|
||||
|
||||
sudo ls -glAiF /var/lib/lxc/ConteneurDebian
|
||||
> -rw-r----- root config
|
||||
> drwxr-xr-x root rootfs/
|
||||
|
||||
sudo du -h -glAiF /var/lib/lxc/ConteneurDebian
|
||||
> ...
|
||||
> 412M
|
||||
|
||||
sudo lxc-copy -n ConteneurDebian -N NewConteneur ### -N pour NewName
|
||||
|
||||
sudo ls -glAiF /var/lib/lxc/
|
||||
> ConteneurDebian
|
||||
> NewConteneur
|
||||
> Test-Linux
|
||||
```
|
||||
|
||||
### Petit D
|
||||
|
||||
```
|
||||
sudo nano /var/lib/lxc/ConteneurDebian/config
|
||||
|
||||
### Dans le fichier config ###
|
||||
|
||||
# Folder Attachment
|
||||
lxc.mount.entry = /mnt/lxc-debian-storage /var/lib/lxc/ConteneurDebian/rootfs/data none bind,create=dir 0 0
|
||||
|
||||
### Fin du fichier config ###
|
||||
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user