From 07bedee34d9ded6f86904c7e4b4e02464ff8cb14 Mon Sep 17 00:00:00 2001 From: Silvino Silva Date: Thu, 15 Sep 2016 00:47:34 +0100 Subject: added tools --- tools/qemu.html | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 tools/qemu.html (limited to 'tools/qemu.html') diff --git a/tools/qemu.html b/tools/qemu.html new file mode 100644 index 0000000..9110b10 --- /dev/null +++ b/tools/qemu.html @@ -0,0 +1,148 @@ + + + + + 1. Qemu + + + + Tools Index + +

1. Qemu

+ +

Disk images;

+ +
+
img
+
network slirp
+
raw
+
network tap
+
qcow2
+
... ...
+
+ + +

Network configuration;

+
+
slirp
+
network slirp
+
tun/tap
+
network tap
+
...
+
... ...
+
+ +

Kernel configuration

+ +
+        # usermod -a -G kvm c9admin
+        # usermod -a -G kvm username
+        
+ +

Network configuration

+ +

Tap interfaces

+ +
+        KERNEL=="tun", GROUP="kvm", MODE="0660", OPTIONS+="static_node=net/tun"
+        
+ +

Automatic creation of tap interface with + correct permissions set for user and group, + you can set only user or group;

+ +
+        # tunctl -u username -g kvm
+        
+ +

Set permissions to existing tap interface;

+ +
+        # tunctl -u username -t tap0
+        
+ + +

Manual creation of tap interface;

+ +
+	# ip tuntap add name tap0 mode tap
+        # chmod 0666 /dev/tap0
+        # chown root:username /dev/tap0
+	# ip link show
+	
+ +

Start qemu with 512 of ram, mydisk.img as disk and boot from iso

+ +
+        $ qemu-system-x86_64 \
+        -enable-kvm \
+        -m 512 \
+        -boot d -cdrom image.iso \
+        -hda mydisk.img
+    	
+ +

Start qemu with 1024 of ram, network configured using tap0 + interface device no host and boot from crux.qcow2;

+ +
+	$ 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
+        
+ +

On host machine test network;

+ +
+	# tcpdump tap0
+	
+ +

Disk image files

+ +

Create hard disk image, there is different types, + this describes how to create a qcow2 type;

+ +
+        $ qemu-img create -f qcow2 crux-img.qcow2 20G
+        
+ +

You can mount disk image;

+ +
+        $ sudo modprobe nbd
+        $ sudo qemu-nbd -c /dev/nbd0 /crux-img.qcow2
+        
+ +

To disconnect image disk (ndb); + +

+        $ sudo qemu-nbd -d /dev/nbd0
+        
+ +

You can use image as a normal disk, example how + to use parted to create a gpt system table;

+ +
+        # parted /dev/nbd0
+        (parted) mklabel gpt
+        
+ +

More information about + gpt partition table. +

+ +

If partitions are on qcow2 image then setup partitions;

+ +
+        # kpartx -a -s -l /dev/nbd0
+        
+ + Tools Index +

This is part of the c9 Manual. + Copyright (C) 2016 + Silvino Silva. + See the file Gnu Free Documentation License + for copying conditions.

+ + -- cgit 1.4.1-2-gfad0