Ci-dessous, les différences entre deux révisions de la page.
Both sides previous revision Révision précédente Prochaine révision | Révision précédente Prochaine révision Both sides next revision | ||
si:lxc [2018/12/12 22:37] heraclide |
si:lxc [2018/12/12 23:29] heraclide |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== Creation d'un container LXC ==== | ====== Creation d'un container LXC ==== | ||
- | - Avoir pensé à créé le [[si:kvm|volume]] | + | - Initialisation du container<code> |
- | - Avoir formatter le volume<code> | + | sudo lxc-create -n NOM -t debian -B lvm --vgname=troll3-vg --lvname=lxc_NOM --fstype=ext4 --fssize 10G -- --release=jessie /dev/troll3-vg/lxc_NOM |
- | mkfs.ext4 /dev/trollX-vg/lxc_NOM | + | |
</code> | </code> | ||
- | - Avoir preparer le mountpoint<code> | + | - Bien noté le pass root affiché dans le /root/README |
- | mkdir /var/lib/lxc/NOM | + | - Ajoutter quelque chose du genre **EN ADAPTANT** dans le /var/lib/lxc/NOM/config<code> |
+ | lxc.network.type = veth | ||
+ | lxc.network.flags = up | ||
+ | lxc.network.link = br0 | ||
+ | lxc.network.hwaddr = 00:ZZ:C0:ZZ:01:60 | ||
+ | lxc.network.ipv4 = 192.168.1.4242/24 | ||
+ | lxc.network.ipv4.gateway = 192.168.1.1 | ||
+ | |||
+ | lxc.start.order = 42 | ||
+ | lxc.start.auto = 1 | ||
</code> | </code> | ||
- | - Avoir preparer le fstab et monter le volume<code> | + | - Pour se faciliter la vie, on va rendre le rootfs accessible depuis le host<code> |
- | echo "/dev/trollX-vg/lxc_NOM /var/lib/lxc/NOM ext4 defaults 0 2" >> /etc/fstab | + | echo "/dev/trollX-vg/lxc_NOM /var/lib/lxc/NOM/rootfs ext4 defaults 0 2" >> /etc/fstab |
- | mount /var/lib/lxc/NOM | + | mount /var/lib/lxc/NOM |
- | </code> | + | </code> |
- | - On peut maintenant creer le container pour de vrai<code> | + | |
- | sudo lxc-create -n NOM -t debian -- -r stretch -d | + | |
- | </code> | + | |
- | - Une fois fini, on le stop<code> | + | |
- | sudo lxc-stop -n NOM | + | |
- | </code> | + | |
- | - Pour moins s'embeter, on va faire les cochons ..<code> | + | |
- | rm /var/lib/lxc/NOM/config | + | |
- | cp /var/lib/lxc/proxy2/config /var/lib/lxc/NOM/config | + | |
- | sed -e 's/proxy2/NOM/g' -i /var/lib/lxc/NOM/config | + | |
- | </code> | + | |
- | - Désolé, ce n'est pas fini | + |