====== Créer une machine virtuel qemu ====== (ou Comment bypass proxmox pour installer une qemu) ===== Introduction ===== Si on a pas d’accès VPN sur la dev, on ne peut pas lancer la console de proxmox ou alors il faut utiliser sshutle par exemple. Voici comment installer une VM qemu en utilisant le port série des VMs. ===== I) Utiliser une image ISO ===== __ Étape 1 : Create somewhere to work: __ mkdir deb-serial; cd deb-serial __ Étape 2 : Grab the net install ISO : __ curl -L -O http://cdimage.debian.org/debian-cd/8.2.0/amd64/iso-cd/debian-8.2.0-amd64-netinst.iso __ Étape 3 : Mount the image via loop : __ mkdir old ; sudo mount -o loop debian-8.2.0-amd64-netinst.iso old __ Étape 4: Copy all the files away to a new 'master' so that you can edit some : __ mkdir new ; shopt -s dotglob ; cp -rv old/* new/ ; ('shopt -s dotglob' - this tells bash that '*' should also match (hidden) '.dot' files) __ Étape 5 : Edit the boot loader (syslinx / isolinux) to use the serial console: __ See files changes below: vim new/isolinux/isolinux.cfg ; vim new/isolinux/txt.cfg ; vim new/isolinux/adtxt.cfg ; __ Étape 6 : Build a new boot ISO (with Hybrid MBR): __ You will need xorriso and syslinx installed: sudo apt-get install syslinux xorriso xorriso -as mkisofs -r -J -joliet-long -l -cache-inodes -isohybrid-mbr /usr/lib/syslinux/bios/isohdpfx.bin -partition_offset 16 -A "Debian8.2" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o debian-8.2-serial-install.iso ./new/ ; __ Étape 7 : Write the new ISO to a USB stick: __ '/dev/sdX' is your USB sticks device node. I like to use 'file -s' to check that I have the correct node. (May need to prefix dd with 'sudo') | file -s /dev/sdX ; dd if=debian-8.2-serial-install.iso of=/dev/sdX bs=1k ; ^ Isolinux.cfg ^ txt.cfg ^ adtxt.cfg ^ | # D-I config version 2.0 # search path for the c32 support libraries (libcom32, libutil etc.) serial 0 115200 console 0 path include menu.cfg #default vesamenu.c32 #prompt 0 #timeout 0 | default install label install menu label ^Install menu default kernel /install.amd/vmlinuz append vga=off console=ttyS0,115200n8 initrd=/install.amd/initrd.gz --- console=ttyS0,115200n8 | label expert menu label ^Expert install kernel /install.amd/vmlinuz append priority=low vga=off console=ttyS0,115200n8 initrd=/install.amd/initrd.gz --- console=ttyS0,115200n8 include rqtxt.cfg label auto menu label ^Automated install kernel /install.amd/vmlinuz append auto=true priority=critical vga=off console=ttyS0,115200n8 initrd=/install.amd/initrd.gz --- console=ttyS0,115200n8 | [[ http://pcengines.info/forums/?page=post&id=51C5DE97-2D0E-40E9-BFF7-7F7FE30E18FE / source pour la création de l'iso]] ===== II) Installer l’ISO ===== ==== Mise en place du bridge: ==== Rappel: Un bridge agit comme un switch virtuel. Les interfaces réelles sont de la forme ethX en général et les interfaces virtuelles tapX. Brctl est un paquet de bridge-utils. brctl show //montrer les bridge actifs ip tuntap add dev tap0 mode tap user root // ip link set tap0 up //activer l’interface tap0 brctl addif vmbr999 tap0 //add the device tap0 to the bridge vmbr999 ==== Booter sur l’image iso : ==== kvm -cpu kvm64 -nographic -serial mon:stdio -drive file=/mnt/pve/scylla/images/146/vm-146-disk-1.qcow2 -cdrom /mnt/pve/scylla/template/iso/debian-8.5-serial-install.iso -boot d -net user,vlan=999,model=e1000e où : * cpu kvm64 sert à spécifier pour le proxmox l’utilisation de qemu-system-x86_64. * nographic empêche l’affichage dans une fenêtre gérer par quemu * serial mon:stdio émule l’affichage sur un autre port série. * drive file spécifie un nouveau drive avec le fichier mit après file * cdrom utilise le fichier qui suit comme image CD-ROM * boot specify boot order drives as a string of drive letters. Valid drive letters depend on the target architecture. The x86 PC uses: a, b (floppy 1 and 2), c (first hard disk), d (first CD-ROM), n-p (Etherboot from network adapter 1-4) * net user,vlan=,model= Créer une nouvelle interface réseau dans le vlan 999 avec le modèle donné. Pendant l’installation, il faut sélectionner la carte intel e1000e sur challenger. ==== Pour se connecter : ==== kvm -cpu kvm64 -nographic -serial mon:stdio -drive file=/mnt/pve/scylla/images/146/vm-146-disk-1.qcow2 -cdrom /mnt/pve/scylla/template/iso/debian-8.5-serial-install.iso -boot c -net user,vlan=999,model=e1000e