$ ssh -4 -root@$MYIP -L 5911:localhost:5911
# wget http://releases.ubuntu.com/18.04.1/ubuntu-18.04.1-desktop-amd64.iso
# apt update
# apt install -y qemu-system qemu-kvm byobu
# byobu
# export IP4=`ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'`
# qemu-system-x86_64 -cpu host -netdev type=user,id=eth0,hostfwd=tcp:$IP:443-:22 -device virtio-net-pci,netdev=eth0 -m 24G -localtime -enable-kvm -drive index=0,id=DISK0,media=disk,if=virtio,cache=none,file=/dev/sda -drive index=1,id=DISK1,media=disk,if=virtio,cache=none,file=/dev/sdb -drive index=2,id=DISK2,media=disk,if=virtio,cache=none,file=/dev/sdc -drive index=3,id=DISK3,media=disk,if=virtio,cache=none,file=/dev/sdd -vga qxl -spice port=5911,addr=127.0.0.1,disable-ticketing -daemonize -cdrom ubuntu-18.04.1-desktop-amd64.iso -boot d
$ spicy -h 127.0.0.1 -p 5911

UEFI

install

ovmf

package and add

-bios /usr/share/ovmf/OVMF.fd

install afresh

#!/bin/bash
# MEM in MB
HOST=$1
MEM=$2
CPUS=$3
DISK=$4
SHORT=`echo $HOST|cut -f1 -d "."`
virt-install --name $SHORT \
        --ram $MEM \
        --vcpus $CPUS \
        --hvm --virt-type kvm \
        --memballoon model=virtio \
        --location=https://ftp.halifax.rwth-aachen.de/ubuntu/dists/bionic/main/installer-amd64/ \
        --os-type=linux --os-variant=ubuntu16.04 \
        --bridge=siec,model=virtio \
        --disk path=$DISK,cache=none,bus=virtio \
        --cpu=host \
        --autostart --nographics \
        --extra-args="console=tty0 console=ttyS0,115200n8 serial"

virsh

# virsh autostart szafa
# virsh attach-disk --domain szafa --source /dev/sda6 --target vdr --serial swap1 --persistent --cache none --io native --sourcetype block 
# 
# virsh detach-disk --domain szafa --persistent --target vdr

hacking offline

# kpartx -av /dev/MD10/szafa
# mount /dev/mapper/MD10-szafa1 /mnt
# ...
# umount /mnt
# kpartx -dv /dev/MD10/szafa
  • faq/kvm.txt
  • Last modified: 9 months ago
  • by Dr Serge Victor