diff options
author | Silvino Silva <silvino@bk.ru> | 2016-09-24 00:09:00 +0100 |
---|---|---|
committer | Silvino Silva <silvino@bk.ru> | 2016-09-24 00:09:00 +0100 |
commit | cf0657e1b62b59e2f54bc0cb88870c4db1e36769 (patch) | |
tree | f67b29bed550198df390c3d278941806c83e55de /tools/qemu.html | |
parent | 1b8d9ebe8bf86e4fb413bf8d51669baa701a603f (diff) | |
parent | 2e952e8ae40eaf147b6cba822411db93a8ee9190 (diff) | |
download | doc-cf0657e1b62b59e2f54bc0cb88870c4db1e36769.tar.gz |
release 'r-0.2.2'
Diffstat (limited to 'tools/qemu.html')
-rw-r--r-- | tools/qemu.html | 100 |
1 files changed, 62 insertions, 38 deletions
diff --git a/tools/qemu.html b/tools/qemu.html index ef1c36d..ce1b66d 100644 --- a/tools/qemu.html +++ b/tools/qemu.html @@ -10,31 +10,37 @@ <h1>Qemu</h1> - <h2 id="kern">Kernel configuration</h2> + <h2 id="kern">1. Host System</h2> + + <p>Load modules, in this case kvm of intel cpu;</p> + + <pre> + # modprobe -a kvm-intel tun virtio + </pre> + + <p>Add users to kvm group;</p> <pre> # usermod -a -G kvm c9admin # usermod -a -G kvm username </pre> - <h2 id="disk">Disk images</h2> + <h2 id="disk">2. Disk images</h2> <dl> <dt>img</dt> - <dd>network slirp</dd> + <dd>Raw disk image, allows dd to a physical device.</dd> <dt>raw</dt> - <dd>network tap</dd> + <dd>Raw disk image, allows dd to a physical device.</dd> <dt>qcow2</dt> - <dd>... ...</dd> + <dd>Qcow disk image file used by qemu.</dd> </dl> - - <p>Create hard disk image, there is different types, this describes how to create a qcow2 type;</p> <pre> - $ qemu-img create -f qcow2 crux-img.qcow2 20G + $ qemu-img create -f qcow2 crux-img.qcow2 15G </pre> <p>You can mount disk image;</p> @@ -44,44 +50,55 @@ $ sudo qemu-nbd -c /dev/nbd0 /crux-img.qcow2 </pre> - <p>To disconnect image disk (ndb);</a> + <p>To disconnect image disk (ndb);</p> <pre> $ sudo qemu-nbd -d /dev/nbd0 </pre> - <p>You can use image as a normal disk, example how + <p>Information about preparing + <a href="../core/install.html#step2">partitions</a> + and <a href="storage.html">storage</a> administration. + You can use image as a normal disk, example how to use parted to create a gpt system table;</p> <pre> # parted /dev/nbd0 (parted) mklabel gpt + (parted) mkpart ext4 0% 100% + (parted) set 1 boot on </pre> - <p>More information about - <a href="http://devil-detail.blogspot.pt/2013/07/install-grub2-on-gpt-disk-dedicated-partition.html">gpt partition table</a>. - </p> + <pre> + # kpartx -a -s -l -u /dev/nbd0 + </pre> - <p>If partitions are on qcow2 image then setup partitions;</p> + <pre> + # mkfs.ext4 /dev/mapper/nbd0p1 + </pre> + + <p>Mount partition;</p> <pre> - # kpartx -a -s -l /dev/nbd0 + # mount /dev/mapper/nbd0p1 </pre> + <h2 id="net">2. Network</h2> <p>Network configuration;</p> + <dl> <dt>slirp</dt> - <dd>network slirp</dd> + <dd>Default virtual NAT'd network.</dd> <dt>tun/tap</dt> - <dd>network tap</dd> - <dt>...</dt> - <dd>... ...</dd> + <dd>Good performance to create virtually any type of network + topology.</dd> + <dt>vde</dt> + <dd>The VDE networking backend.</dd> </dl> - <h2>Network configuration</h2> - <h3>Tap interfaces</h3> + <h3>2.1. Tap interfaces</h3> <pre> KERNEL=="tun", GROUP="kvm", MODE="0660", OPTIONS+="static_node=net/tun" @@ -92,7 +109,7 @@ you can set only user or group;</p> <pre> - # tunctl -u username -g kvm + # tunctl -u username -g kvm -t tap0 </pre> <p>Set permissions to existing tap interface;</p> @@ -104,12 +121,24 @@ <p>Manual creation of tap interface;</p> - <pre> - # ip tuntap add name tap0 mode tap + <pre> + # ip tuntap add name tap0 mode tap # chmod 0666 /dev/tap0 # chown root:username /dev/tap0 - # ip link show - </pre> + </pre> + + <pre> + # ip addr add 10.0.2.1/24 dev tap0 + # ip link set dev tap0 up + # ip link show + </pre> + + <pre> + # sysctl -w net.ipv4.ip_forward=1 + # iptables -t nat -A POSTROUTING -s 10.0.2.0/24 -o eth0 -j MASQUERADE + </pre> + + <h2 id="guest">Guest System</h2> <p>Start qemu with 512 of ram, mydisk.img as disk and boot from iso</p> @@ -119,24 +148,19 @@ -m 512 \ -boot d -cdrom image.iso \ -hda mydisk.img - </pre> + </pre> <p>Start qemu with 1024 of ram, network configured using tap0 interface device no host and boot from crux.qcow2;</p> - <pre> - $ qemu-system-x86_64 \ - -enable-kvm \ - -m 1024 \ - -hda c9/local/crux.qcow2 \ - -net nic,model=virtio -net tap,ifname=tap0,script=no,downscript=no + <pre> + $ qemu-system-x86_64 \ + -enable-kvm \ + -m 1024 \ + -hda c9/local/crux.qcow2 \ + -net nic,model=virtio -net tap,ifname=tap0,script=no,downscript=no </pre> - <p>On host machine test network;</p> - - <pre> - # tcpdump tap0 - </pre> <a href="index.html">Tools Index</a> <p>This is part of the c9 Manual. Copyright (C) 2016 |