Здесь показаны различия между двумя версиями данной страницы.
Предыдущая версия справа и слева Предыдущая версия Следующая версия | Предыдущая версия | ||
howto:linux:kvm [2014/12/29 16:22] Алексей Кожевников |
howto:linux:kvm [2019/01/17 11:09] (текущий) Алексей Кожевников ↷ Страница перемещена из installation:linux:kvm в howto:linux:kvm |
||
---|---|---|---|
Строка 1: | Строка 1: | ||
====== KVM ====== | ====== KVM ====== | ||
+ | |||
Проверка аппаратной виртуализации:\\ | Проверка аппаратной виртуализации:\\ | ||
''cat /proc/cpuinfo | egrep 'flags.*(svm|vmx)''' | ''cat /proc/cpuinfo | egrep 'flags.*(svm|vmx)''' | ||
- | {{tag> linux kvm }} | + | ''tasksel install virt-host'' |
+ | ===== lvm pool ===== | ||
+ | |||
+ | ''/etc/libvirt/storage/vg01.xml'' | ||
+ | <code> | ||
+ | <pool type='logical'> | ||
+ | <name>vg01</name> | ||
+ | <target> | ||
+ | <path>/dev/vg01</path> | ||
+ | </target> | ||
+ | </pool> | ||
+ | </code> | ||
+ | |||
+ | ''virsh pool-define /etc/libvirt/storage/vg01.xml\\ | ||
+ | virsh pool-start vg01\\ | ||
+ | virsh pool-autostart vg01\\ | ||
+ | virsh pool-info vg01'' | ||
+ | |||
+ | ===== virt-install ===== | ||
+ | |||
+ | ''apt-get install virtinst'' | ||
+ | |||
+ | <code>virt-install --os-variant list</code> | ||
+ | |||
+ | ==== Linux ==== | ||
+ | === Ubuntu 14.04 === | ||
+ | |||
+ | ''lvcreate -L51200 -n nti09 /dev/vg01'' | ||
+ | |||
+ | ''virsh pool-refresh vg01'' | ||
+ | <code> | ||
+ | virt-install --connect=qemu:///system \ | ||
+ | --name=nti09 \ | ||
+ | --cpu host \ | ||
+ | --vcpus=1,sockets=1,cores=1,threads=1 \ | ||
+ | --ram=512 \ | ||
+ | --os-type=linux \ | ||
+ | --os-variant=ubuntutrusty \ | ||
+ | --disk vol=vg01/nti09,bus=virtio,cache=none \ | ||
+ | --cdrom=/tmp/ubuntu-14.04.1-server-amd64.iso \ | ||
+ | --network bridge:br0,model=virtio \ | ||
+ | --graphics vnc,listen=0.0.0.0,port=46599,password=zzzzzz \ | ||
+ | --accelerate \ | ||
+ | --hvm \ | ||
+ | --noautoconsole | ||
+ | </code> | ||
+ | |||
+ | === RHEL 6 === | ||
+ | == LVM, iso, vnc == | ||
+ | |||
+ | ''lvcreate -L51200 -n nti08 /dev/vg01'' | ||
+ | |||
+ | ''virsh pool-refresh vg01'' | ||
+ | <code> | ||
+ | virt-install --connect=qemu:///system \ | ||
+ | --name=nti08 \ | ||
+ | --cpu host \ | ||
+ | --vcpus=1,sockets=1,cores=1,threads=1 \ | ||
+ | --ram=512 \ | ||
+ | --os-type=linux \ | ||
+ | --os-variant=rhel6 \ | ||
+ | --disk vol=vg01/nti08,bus=virtio,cache=none \ | ||
+ | --cdrom=/tmp/CentOS-6.6-x86_64-minimal.iso \ | ||
+ | --network bridge:br0,model=virtio \ | ||
+ | --graphics vnc,listen=0.0.0.0,port=46598,password=zzzzzz \ | ||
+ | --accelerate \ | ||
+ | --hvm \ | ||
+ | --noautoconsole | ||
+ | </code> | ||
+ | |||
+ | == img, net, console == | ||
+ | |||
+ | <code> | ||
+ | virt-install --connect=qemu:///system \ | ||
+ | --name=mon-proxy \ | ||
+ | --cpu host \ | ||
+ | --vcpus=1,sockets=1,cores=1,threads=2 \ | ||
+ | --ram=1024 \ | ||
+ | --os-type=linux \ | ||
+ | --os-variant=rhel6 \ | ||
+ | --disk path=/srv/virtual/mon_proxy.img,bus=virtio,size=50 \ | ||
+ | --location=http://mirror.yandex.ru/centos/6/os/x86_64/ \ | ||
+ | --network bridge:br201,model=virtio \ | ||
+ | --network bridge:br1790,model=virtio \ | ||
+ | --network bridge:br3044,model=virtio \ | ||
+ | --graphics vnc,listen=0.0.0.0 \ | ||
+ | --accelerate \ | ||
+ | --hvm | ||
+ | </code> | ||
+ | |||
+ | |||
+ | === RHEL 7 === | ||
+ | |||
+ | <code> | ||
+ | lvcreate -L50000 -n vm-adm1-root /dev/vg01 | ||
+ | |||
+ | virsh pool-refresh vg01 | ||
+ | |||
+ | virt-install --connect=qemu:///system \ | ||
+ | --name=adm1 \ | ||
+ | --cpu host \ | ||
+ | --vcpus=1,sockets=1,cores=2,threads=1 \ | ||
+ | --ram=512 \ | ||
+ | --os-type=linux \ | ||
+ | --os-variant=rhel7 \ | ||
+ | --disk vol=vg01/vm-adm1-root,bus=virtio,cache=none \ | ||
+ | --location=http://mirror.yandex.ru/centos/7/os/x86_64/ \ | ||
+ | --network bridge:br0,model=virtio \ | ||
+ | --nographics \ | ||
+ | --extra-args='console=tty0 console=ttyS0,115200n8' \ | ||
+ | --accelerate \ | ||
+ | --hvm | ||
+ | </code> | ||
+ | ==== Windows ==== | ||
+ | |||
+ | ''lvcreate -L102500 -n nti02 /dev/vg01'' | ||
+ | |||
+ | ''virsh pool-refresh vg01'' | ||
+ | <code> | ||
+ | virt-install --connect=qemu:///system \ | ||
+ | --name=nti02 \ | ||
+ | --cpu host \ | ||
+ | --vcpus=8,sockets=1,cores=8,threads=1 \ | ||
+ | --ram=12288 \ | ||
+ | --os-type=windows \ | ||
+ | --os-variant=win2k8 \ | ||
+ | --disk vol=vg01/nti02,bus=virtio,cache=none \ | ||
+ | --cdrom=/bak/iso/ru_windows_server_2008_r2_standard_enterprise_datacenter_web_vl_build_x64_dvd_x15-59789.iso \ | ||
+ | --network bridge:br0,model=virtio \ | ||
+ | --graphics vnc,listen=0.0.0.0,port=46591,password=zzzzzz \ | ||
+ | --accelerate \ | ||
+ | --hvm \ | ||
+ | --noautoconsole | ||
+ | </code> | ||
+ | |||
+ | |||
+ | ===== attach-interface ===== | ||
+ | <code> | ||
+ | virsh attach-interface --domain web9 --type bridge --source br1790 --model virtio --config | ||
+ | virsh detach-interface web9 bridge --mac '52:54:00:e5:6b:eb' | ||
+ | </code> | ||
+ | |||
+ | |||
+ | ===== attach-disk ===== | ||
+ | |||
+ | Подключить образ: | ||
+ | |||
+ | <code> | ||
+ | virsh attach-disk guest01 /root/disc1.iso hdc –driver file –type cdrom –mode readonly | ||
+ | </code> | ||
+ | |||
+ | Отключить образ: | ||
+ | |||
+ | <code> | ||
+ | virsh attach-disk vguest01 " " hdc –driver file –type cdrom –mode readonly | ||
+ | </code> | ||
+ | |||
+ | ===== Boot from cdrom ===== | ||
+ | |||
+ | ''virsh edit guest01'' | ||
+ | <code> | ||
+ | <os> | ||
+ | <type arch='x86_64' machine='pc-0.12'>hvm</type> | ||
+ | <boot dev='cdrom'/> | ||
+ | <boot dev='hd'/> | ||
+ | </os> | ||
+ | </code> | ||
+ | |||
+ | <code> | ||
+ | <disk type='file' device='cdrom'> | ||
+ | <driver name='qemu' type='raw'/> | ||
+ | <source file='/tmp/ubuntu-14.04.1-server-amd64.iso'/> | ||
+ | <target dev='hdc' bus='ide'/> | ||
+ | <readonly/> | ||
+ | <address type='drive' controller='0' bus='1' unit='0'/> | ||
+ | </disk> | ||
+ | </code> | ||
+ | |||
+ | |||
+ | ===== attach-device ===== | ||
+ | |||
+ | ''virsh attach-device nti02 /etc/libvirt/qemu/devices/usbpwc2.xml'' | ||
+ | <code> | ||
+ | <hostdev mode='subsystem' type='usb'> | ||
+ | <source> | ||
+ | <vendor id='0x0d9f' /> | ||
+ | <product id='0x00a3' /> | ||
+ | </source> | ||
+ | </hostdev> | ||
+ | </code> | ||
+ | |||
+ | {{tag> linux Ubuntu kvm virt-install attach-device }} |