Table of Contents

Vytvareni virtual serveru KVM

  1. virt-builder (pokud jiz neni predpripraveny)

pokud jiz je, tak jen “cp debian-9_<heslo>.img ../images/nazev_zakaznika.img

  1. virt-intall –ram xxxx –vcpu yyyy podle objednavky
  2. koupit verejnou ip adresu - zmenit MAC a uvnit vps /etc/network/interfaces
  3. pripadne zaradit do xenbr40 a pridelit 10.0.40.xx
  4. zmenit vnc na verenou IP a port 59000 + posledni cislo IP napr. 59020
  5. hotovo :)
virt-builder debian-9 --size=6G --format qcow2 -o /vps/debian9-XXXX.qcow2 \
   --hostname XXXX \
   --network \
   --timezone Europe/Prague \
   --firstboot-command "dpkg-reconfigure openssh-server"

Typicky vystup vypada takto pozor je zde heslo, vystup docasne uchovat

[   3.0] Downloading: http://libguestfs.org/download/builder/debian-9.xz
[   4.3] Planning how to build this image
[   4.3] Uncompressing
[  10.2] Opening the new disk
[  38.8] Setting a random seed
virt-builder: warning: random seed could not be set for this type of guest
[  38.8] Setting the hostname: puppet
[  39.3] Setting the timezone: Europe/Prague
[  39.3] Setting passwords
virt-builder: Setting random password of root to bzuaAnt6fEHp7Giu
[  39.8] Finishing off
                   Output file: /var/lib/libvirt/images/debian9-puppet.raw
                   Output size: 6.0G
                 Output format: raw
            Total usable space: 5.8G
                    Free space: 5.0G (86%)
virt-install --import --name XXXX --vcpu 1 --memory 2000 --disk path=/var/lib/libvirt/images/debian9-XXXX.img --os-variant debian9 --network=bridge=xenbr10,model=virtio --noautoconsole

virsh console = pristup

osinfo-query os

Ziskani a nastaveni IP adres

http://storman.starlab.cz pod uzivatelem storman dat assigned IPS MAC adresu ziskame

 root@puppet:~# ip a
root@puppet:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether **52:54:00:1f:2f:3c** brd ff:ff:ff:ff:ff:ff

IP adresu zapiseme do

/etc/network/interfaces
# The primary network interface
allow-hotplug ens3
iface ens3 inet static
	address 10.0.40.18
	netmask 255.255.255.0
	gateway 10.0.40.1

Pozor na prejmenovani ens2 na ens3.

Nahodit rozhranni

 ifup ens3

Nastaveni nameserveru a domeny

/etc/resolv.conf
search starlab.cz
nameserver 213.133.100.100
nameserver 213.133.98.98
nameserver 213.133.99.99
nameserver 2a01:4f8:0:1::add:9898
nameserver 2a01:4f8:0:1::add:1010
nameserver 2a01:4f8:0:1::add:9999

Verejna IP

  <interface type='bridge'>
      <mac address='00:50:56:0c:a5:80'/>
      <source bridge='xenbr10'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

Zvetseni image

qemu-img resize tzdebian.img +10G
<graphics type='vnc' port='*' autoport='no' listen='ipdpddr' passwd='x'>
<listen type='address' address='ipaddr'>

kdyz mam ip od hetzner dam request separate mac address ve virsh edit mac address pastecertus

   <graphics type='vnc' port='*' autoport='no' listen='ipdpddr' passwd='x'>
   <listen type='address' address='ipaddr'>

 * ipaddr je adresa hlavniho serveru napr. 88.198.64.144

pripojim se pak pres virsh console nebo vncviewer

   vncviewer 88.198.64.144:59181

musim na novem terminalu, ne kdyz jsem prihlasen na nemeckem serveru

virt-install --name w1 --vcpu 2 --memory 4000 --disk path=/var/lib/libvirt/images/w1.img,size=50 --cdrom /var/lib/libvirt/images/SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_Czech_-3_MLF_X21-30351.ISO --noautoconsole --graphics vnc,listen=0.0.0.0
virt-install --name irobot-b2b --vcpu 1 --memory 4000 --os-type=windows --disk path=/vps/irobot-b2b.img,size=100 --cdrom /srv/storage/install/virtio-win.iso --cdrom /srv/storage/install/SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_Czech_-3_MLF_X21-30351.ISO  --noautoconsole --graphics vnc,listen=0.0.0.0,port=59101 --network=bridge=xenbr40,model=virtio

Odladeno na h7 a h9

qemu-img create /vps/Foo.qcow2 60G

virt-install --connect qemu:///system --name Foo --ram 8192 --vcpus 4 \
--disk path=/vps/Foo.qcow2,format=qcow2,bus=virtio,cache=none \
--disk path=/srv/storage/install/virtio-win.iso,device=cdrom \
--cdrom /srv/storage/install/SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_Czech_-3_MLF_X21-30351.ISO \
--network=bridge=xenbr10,model=virtio  \
--os-type=windows --os-variant=win2k8 \
--noautoconsole --accelerate --noapic  --graphics type=vnc,listen=0.0.0.0,port=59201,password=somepass

links

Odladeno na h5

virt-install --connect qemu:///system --name windows-smitka --ram 8192 --vcpus 1
--disk path=/vps/windows-customer.qcow2,format=qcow2,bus=virtio,cache=none 
--disk path=/srv/storage/install/virtio-win.iso,device=cdrom 
--cdrom /srv/storage/install/SW_DVD9_Win_Server_STD_CORE_2019_1809.2_64Bit_Czech_DC_STD_MLF_X22-18450.ISO --network=bridge=xenbr10,model=virtio  
--os-type=windows --os-variant=win2k16 
--noautoconsole 
--accelerate --noapic  --graphics type=vnc,listen=0.0.0.0,port=59249,password=somepass

Odladeno na h1

virt-install --connect qemu:///system --name windows-syrmex --ram 8192 --vcpus 1
--disk path=/vps/windows-syrmex.qcow2,format=qcow2,bus=virtio,cache=none
--disk path=/srv/storage/install/SW_DVD9_Win_Server_STD_CORE_2019_1809.2_64Bit_Czech_DC_STD_MLF_X22-18450.ISO,device=cdrom 
--disk path=/srv/storage/install/virtio-win.iso,device=cdrom
--network=bridge=xenbr10,model=virtio 
--os-type=windows --os-variant=win2k16 --noautoconsole --accelerate --noapic  --graphics type=vnc,listen=0.0.0.0,port=59249
 

pred editaci udelat vzdy zalohu configu pomoci

 virsh dumpxml

nebo virsh edit a nasledne :w /tmp/zaloha-xx-w2.xml

a provest diff -u /zalozni /novy

protokol ipv4 na internet ip 10.0.40.x maska 255.255.255.0 brana 10.0.40.1 dns 8.8.8.8

h5 2023

virt-install --connect qemu:///system --name win-berny --ram 16192 --vcpus 2 --disk path=/vps/win-berny.qcow2,format=qcow2,bus=virtio,cache=none --disk path=/srv/storage/install/virtio-win.iso,device=cdrom --cdrom /srv/storage/install/SW_DVD9_Win_Server_STD_CORE_2022_2108.27_64Bit_Czech_DC_STD_MLF_X23-64867.ISO --network=bridge=xenbr40,model=virtio --os-type=windows --os-variant=win2k16 --noautoconsole --accelerate --noapic --graphics type=vnc,listen=0.0.0.0,port=59158,password=thaDouph22fee --check path_in_use=off

prepis na modeltype virtio

pridam dummy disk

<disk>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'>
<source file='XXXX'>
<target dev='hdX' bus='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' /> 

nainstaluji vse podle navodu:

ve spravci zarizeni by mely byt uplne nahore dva disky vypnu pc a ve virsh edit zmenim: parametry disku s windows prepisu na parametry dummy image a tu smazu

Instalace OPNSense, pfSense z iso

qemu-img create -f qcow2  /vps/vmname_fw.qcow2 6G
 virt-install --name vname_fw --vcpu 1 --memory 1024 \
     --os-type=freebsd --os-variant=freebsd11.2 \
     --disk /vps/vmname_fw.qcow2,device=disk,bus=virtio \
     --network bridge=br11,model=virtio \
     --network bridge=br40,model=virtio \
     --noautoconsole --graphics vnc,listen=0.0.0.0,port=5901,password=some_password \
     --cdrom /path/to/OPNsense-19.1-OpenSSL-dvd-amd64.iso

Errors

/root/.cache/virt-builder/debian-9.x86_64.2: invalid block (error 5)
virt-builder: error: internal error: invalid argument: some threads failed, see earlier errors

Our case was: Not enough free memory. (Dosla pamet RAM)