Projet

Général

Profil

Libvirt (ancien) » Historique » Version 7

Version 6 (Mehdi Abaakouk, 06/04/2013 19:09) → Version 7/61 (Mehdi Abaakouk, 06/04/2013 19:53)

h1. Libvirt

h2. Installation VM sans bridge avec routage static (en /32 pour l'ipv4)

h3. Configuration de la libvirt

On créé un réseau libvirt qui fait rien (déjà fait sur n7):

<pre>
cat > dump-net.xml <<EOF
<network ipv6='yes'>
<name>dump-net</name>
<bridge name='dumpbr0' />
</network>
EOF

virsh net-define dump-net.xml
virsh net-autostart dump-net
virsh net-start dump-net
</pre>

On créé un hook libvirt (déjà fait sur n7):
<pre>
mkdir -p /etc/libvirt/hooks /etc/libvirt/ttnn
vi /etc/libvirt/hooks/qemu
----8<--------------->8----
#!/bin/bash

name="$1"
operation="$2"
suboperation="$3"

[ "$operation" != "start" "started" ] && exit 0
[ "$suboperation" != "begin" ] && exit 0

# get interface from the libvirt xml
interface=$(cat - | sed -ne "/vnet/s/.*dev='\([^']*\)'.*/\1/gp")

[ -f /etc/libvirt/ttnn/${name}.conf ] && source /etc/libvirt/ttnn/${name}.conf

[ "$ip" -o "$ip6" ] && brctl delif dumpbr0 $interface
[ "$ip" ] && ip route add $ip/32 dev $interface
[ "$ip6" ] && ip route add $ip6/56 dev $interface
[ "$ip6" ] && ip -6 addr add fe80::31/64 dev $interface
exit 0
----8<--------------->8----
</pre>

h3. Preparation de l'installer

Pour une squeeze on met à jour virtinst (déjà fait sur n7):

<pre>
wget http:// u/debian/pool/main/v/virtinst/virtinst_0.600.1-3_all.deb
dpkg -i virtinst_0.600.1-3_all.deb
</pre>

On install le preseed.cfg attaché à la page dans /etc/libvirt/preseed.cfg (déjà fait sur n7)

h4. Installation d'une VM

Creation du disk (déjà fait sur n7):
<pre>
lvcreate -n picttn -L 50G /dev/raid5
</pre>

Configuration du routage static:

<pre>
vi /etc/libvirt/ttnn/picttn.conf
ip="91.224.148.252"
ip6="2a01:6600:8080:FC00::"
</pre>

Lancement de l'installation
<pre>
cd
virt-install -n picttn -r 2048 --os-type=linux \
--disk /dev/raid5/picttn,bus=virtio,cache=none,io=native \
--network network=dump-net,model=virtio \
--nographics \
--location http://ftp.debian.org/debian/dists/wheezy/main/installer-amd64/ \
--serial pty \
--initrd-inject /etc/libvirt/ttnn/preseed.cfg \
--initrd-inject /etc/libvirt/ttnn/picttn.conf \
--initrd-inject /etc/libvirt/ttnn/postinstall.sh \
--extra-args "console=ttyS0,9600n8 DEBIAN_FRONTEND=text auto priority=critical preseed/file=/preseed.cfg hostname=picttn domain=le-pic.org netcfg/get_ipaddress=2a01:6600:8080:FC00::1 netcfg/get_netmask=ffff:ffff:ffff:ff00:: netcfg/get_gateway=fe80::31 netcfg/get_nameservers=2001:4860:4860::8888"
</pre>

On peux regarder l'avancement de l'installation avec
<pre>
virsh console picttn
</pre>

Ensuite on se connecte à la VM
<pre>
ssh root@2a01:6600:8080:FC00::1
</pre>