My Wiki!

kvm image disck qcow2 Apply for: debian, linux…

Creating images

Creating base image: like creating normal image

  qemu-img create -f qcow2 windows-master.qcow2 10G

Install OS on that image.

qemu-system-x86_64  -hda  windows-master.qcow2  -m  512  -boot d  -cdrom /home/user/isos/en_winxp_pro_with_sp2.iso

Debian

  • Use guilded lvm separate all
  • configure lvm manager and edit lv partitions

Creating working images

qemu-img create -b windows-master.qcow2 -f  qcow2   windows-clone.qcow2

This working image have the same virtual size as the base image. The actual size is small because the working image only contain the difference to the base image from the time it is created.

  • Important *: Never boot or modify the base image. It will cause inconsistency. working image = base image + (concat) diff.

    qemu-img info windows-clone.qcow2

    image: windows-clone.qcow2 file format: qcow2 virtual size: 10G (10737418240 bytes) disk size: 56K cluster_size: 4096 backing file: windows-master.qcow2 (actual path: windows-master.qcow2)

Multiple working images can share the same base image.

Network

Rebasing:

Merging working image with based image to create a new indipendent base image.

qemu-img convert windows-clone.qcow2 –O qcow2 windows-marketing.qcow2

* This need more study * Create cow new image with convert.

When there is a need to change base image to other location.

qemu-img convert -O qcow2 -B master-windows2003-base.qcow2 master-windows2003.qcow2 final.qcow2

1. cloud-init user login

1.1 virt-customize

$ virt-customize -a bionic-server-cloudimg-amd64.img --root-password password:coolpass

1.2 cloud init image

$ ssh-keygen -f atomic_rsa
Generating public/private rsa key pair.
<truncating output>
$ cat atomic_rsa.pub 

$ vim meta-data

instance-id: Atomic01
local-hostname: atomic-host-001

$ vim user-data

#cloud-config
password: redhat
chpasswd: { expire: False }
ssh_pwauth: True
ssh_authorized_keys:
   - ... ssh-rsa new public key here user@host ...
$ genisoimage -output atomic01-cidata.iso -volid cidata -joliet -rock user-data meta-data

Managing VMs

virtmanager

spice already supported from Fed 15.

yum install kvm
yum install virt-manager libvirt libvirt-python python-virtinst 

vm manger script

yum install spice-client

Check enable_nat.sh for correct ethernet name (em1 vs eth0)

Configure Start scritp

The VM will be configured with ip, MAC, bridge in NAT mode…

Edit the followings:

  • IP
  • VNC
  • SPice
  • MAC
  • Hostname

Configure VMs

network, hostname, ip

Open VNC connection

Login with root:r4o9o9t5

user dev:dev

IP

Static IP
     auto eth0
     iface eth0 inet static
      address 192.168.0.7
      netmask 255.255.255.0
      gateway 192.168.0.254

Then restart network

/etc/init.d/networking restart
or
ifdown ethx
ifup ethx

apt-get

Now that Lenny has been archived, you will need to update your /etc/apt/sources.list file. It should now look like this:

deb http://archive.debian.org/debian lenny main
deb http://archive.debian.org/debian-security lenny/updates main
deb http://archive.debian.org/debian-volatile lenny/volatile main
deb http://archive.debian.org/backports.org lenny-backports main

tcp_window_scaling

Attention

Causes problem when debian guests download large file from internet. Disable tcpwindowscaling on host machine.

net.ipv4.tcp_window_scaling=0"
sysctl -w net.ipv4.tcp_window_scaling=0

Navigation