https://help.ubuntu.com/11.10/serverguide/C/virtualization.html
http://bojack.pixnet.net/blog/post/29040863-%E3%80%90linux%E3%80%91%E5%9C%A8-ubuntu-11.04-%E4%B8%8A%E5%AE%89%E8%A3%9D-kvm
2012/03/14 補: 用一個 image 當作 base, 然後 create 出來其他 image 檔
http://jamyy.dyndns.org/blog/2012/02/3594.html
2012/03/14 補: 把.img 轉成 qcow2
2012/03/15 補: 如何直接 mount qcow2
2012/03/16 補: 如何 boot from network
Reference:
http://www.howtoforge.com/virtualization-with-kvm-on-ubuntu-10.10
Console problem
http://serverfault.com/questions/338770/kvm-on-ubuntu-console-connection-displays-nothing
http://bojack.pixnet.net/blog/post/29040863-%E3%80%90linux%E3%80%91%E5%9C%A8-ubuntu-11.04-%E4%B8%8A%E5%AE%89%E8%A3%9D-kvm
wistor@wistor-003:~$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
wistor@wistor-003:~$ lsmod | grep kvm
kvm_intel 137721 3
kvm 407077 1 kvm_intel
wistor@wistor-003:~$ sudo modprobe -l | grep kvm
kernel/arch/x86/kvm/kvm.ko
kernel/arch/x86/kvm/kvm-intel.ko
kernel/arch/x86/kvm/kvm-amd.ko
wistor@wistor-003:~$ sudo apt-get install kvm libvirt-bin
wistor@wistor-003:~$ cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto br0
iface br0 inet static
bridge_ports eth0
bridge_fd 9
bridge_hello 2
bridge_maxage 12
bridge_stp off
address 172.16.123.83
network 172.16.0.0
netmask 255.255.0.0
gateway 172.16.1.254
auto br0:1
iface br0:1 inet static
address 192.168.123.83
netmask 255.255.255.0
wistor@wistor-003:~$ ifconfig
br0 Link encap:Ethernet HWaddr 00:26:2d:0a:36:7e
inet addr:172.16.123.83 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::226:2dff:fe0a:367e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:186911 errors:0 dropped:5837 overruns:0 frame:0
TX packets:79278 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:136435680 (136.4 MB) TX bytes:8542559 (8.5 MB)
br0:1 Link encap:Ethernet HWaddr 00:26:2d:0a:36:7e
inet addr:192.168.123.83 Bcast:0.0.0.0 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0 Link encap:Ethernet HWaddr 00:26:2d:0a:36:7e
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:278356 errors:0 dropped:10 overruns:0 frame:0
TX packets:91634 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:176265990 (176.2 MB) TX bytes:9623004 (9.6 MB)
Memory:fbea0000-fbec0000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:98 errors:0 dropped:0 overruns:0 frame:0
TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:9439 (9.4 KB) TX bytes:9439 (9.4 KB)
virbr0 Link encap:Ethernet HWaddr 52:6b:4e:82:ba:f8
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wistor@wistor-003:~$ groups
wistor adm dialout cdrom plugdev lpadmin sambashare admin libvirtd
wistor@wistor-003:~$ virsh -c qemu:///system list
Id Name State
----------------------------------
wistor@wistor-003:~$ sudo iptables -t nat -L -n
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE tcp -- 192.168.122.0/24 !192.168.122.0/24 masq ports: 1024-65535
MASQUERADE udp -- 192.168.122.0/24 !192.168.122.0/24 masq ports: 1024-65535
MASQUERADE all -- 192.168.122.0/24 !192.168.122.0/24
wistor@wistor-003:~$ sudo apt-get install virtinst wistor@wistor-003:~$ cat build_vm.sh HOSTNAME=vm3 MEMORY=512 CPUS=1 DISK_SIZE=10000 IP=172.16.123.84 sudo virt-install \ -v \ -n $HOSTNAME \ -r $MEMORY \ --disk path=$HOSTNAME.img,bus=virtio,size=4 \ -c ubuntu-11.10-server-amd64.iso \ --accelerate \ --network bridge=br0 \ --connect=qemu:///system \ --virt-type=kvm \ --graphics vnc,listen=0.0.0.0 wistor@wistor-003:~$ sudo ./build_vm.sh wistor@wistor-003:~$ virsh vncdisplay vm3 :0
2012/03/14 補: 用一個 image 當作 base, 然後 create 出來其他 image 檔
http://jamyy.dyndns.org/blog/2012/02/3594.html
wistor@wistor-001:~$ sudo qemu-img create -b iscsi-server-base.qcow2 -f qcow2 wistor-004.qcow2 Formatting 'wistor-004.qcow2', fmt=qcow2 size=4294967296 backing_file='iscsi-server-base.qcow2' encryption=off cluster_size=0
2012/03/14 補: 把.img 轉成 qcow2
wistor@wistor-001:~$ sudo qemu-img convert -O qcow2 iscsi-server-base.img iscsi-server-base.qcow2
2012/03/15 補: 如何直接 mount qcow2
wistor@wistor-003:~$ modprobe nbd wistor@wistor-003:~$ sudo kvm-nbd -c /dev/nbd0 ~/kvm/ubuntu-11.10-3.2-base.qcow2 wistor@wistor-003:~$ sudo mount /dev/nbd0p1 /mnt/kvm wistor@wistor-003:~$ sudo umount /mnt/kvm wistor@wistor-003:~$ sudo kvm-nbd -d /dev/nbd0
2012/03/16 補: 如何 boot from network
# 記得要先安裝這個套件 wistor@ubuntu:~/kvm$ sudo apt-get install kvm-pxe [sudo] password for wistor: Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: kvm-pxe 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 128 kB of archives. After this operation, 201 kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com/ubuntu/ oneiric/universe kvm-pxe all 5.4.4-7ubuntu3 [128 kB] Fetched 128 kB in 2s (58.7 kB/s) Selecting previously deselected package kvm-pxe. (Reading database ... 71450 files and directories currently installed.) Unpacking kvm-pxe (from .../kvm-pxe_5.4.4-7ubuntu3_all.deb) ... Setting up kvm-pxe (5.4.4-7ubuntu3) ... # 在內加上 network 選項, 如果需要 bootmenu 就再加上設定 wistor@ubuntu:~/kvm$ sudo cat /etc/libvirt/qemu/ubuntu-11.10-3.2-base.xml | grep -A 10 os hvm
Reference:
http://www.howtoforge.com/virtualization-with-kvm-on-ubuntu-10.10
Console problem
http://serverfault.com/questions/338770/kvm-on-ubuntu-console-connection-displays-nothing

沒有留言:
張貼留言