about summary refs log tree commit diff stats
path: root/tools/qemu.html
diff options
context:
space:
mode:
Diffstat (limited to 'tools/qemu.html')
-rw-r--r--tools/qemu.html105
1 files changed, 93 insertions, 12 deletions
diff --git a/tools/qemu.html b/tools/qemu.html
index f79b955..e32d03f 100644
--- a/tools/qemu.html
+++ b/tools/qemu.html
@@ -46,12 +46,14 @@
         $ qemu-img create -f qcow2 crux-img.qcow2 2000M
         </pre>
 
+        <h3 id="mount">2.1. Mount images</h3>
+
         <p>Qemu disk images can be treated as regular disks using
         qemu disk network block device server;</p>
 
         <pre>
         $ sudo modprobe nbd
-        $ sudo qemu-nbd -c /dev/nbd0 /crux-img.qcow2
+        $ sudo qemu-nbd -c /dev/nbd0 crux-img.qcow2
         </pre>
 
         <p>Information about preparing
@@ -64,10 +66,10 @@
         parted --script ${DEV} \
                 mklabel gpt \
                 unit mib \
-                mkpart primary 1 3 \
+                mkpart primary 2 4 \
                 set 1 bios_grub on \
                 name 1 grub \
-                mkpart ESP fat32 3 59 \
+                mkpart ESP fat32 4 59 \
                 set 2 boot on \
                 name 2 efi \
                 mkpart primary ext4 103 200 \
@@ -122,7 +124,68 @@
         $ sudo qemu-nbd -d /dev/nbd0
         </pre>
 
-        <h2 id="net">2. Network</h2>
+        <h3 id="resize">2.2. Resize images</h3>
+
+        <p>Verify disk image information;</p>
+
+        <pre>
+        $ qemu-img info c1-storage.qcow2
+        </pre>
+
+        <pre>
+	image: c1-storage.qcow2
+	file format: qcow2
+	virtual size: 10G (10737418240 bytes)
+	disk size: 7.6G
+	cluster_size: 65536
+	Format specific information:
+	    compat: 1.1
+	    lazy refcounts: false
+	    refcount bits: 16
+	    corrupt: false
+	$
+	</pre>
+
+	<p>In this example is added 25G to the image;</p>
+
+	<pre>
+	$ qemu-img resize c1-storage.qcow2 +25G
+	</pre>
+
+        <p>Read <a href="lvm.html#resize">lvm resize</a> if image
+        is using lvm, or use resize2fs. If size is not provided to resize2fs,
+        by default it will grow file system to all partition;</p>
+
+        <pre>
+        $ sudo qemu-nbd -c /dev/nbd0 /srv/qemu/img/c1-server.qcow2
+        </pre>
+
+        <pre>
+        # kpartx -a -s -l -u /dev/nbd0
+        GPT:Primary header thinks Alt. header is not at the end of the disk.
+        GPT:Alternate GPT header not at the end of the disk.
+        GPT: Use GNU Parted to correct GPT errors.
+
+        # parted /dev/nbd0
+        GNU Parted 3.2
+        Using /dev/nbd0
+        Welcome to GNU Parted! Type 'help' to view a list of commands.
+        (parted) print
+        Warning: Not all of the space available to /dev/nbd0 appears to be used, you can
+        fix the GPT to use all of the space (an extra 16777216 blocks) or continue with
+        the current setting?
+        Fix/Ignore? Fix
+
+        (parted) resize 3 100%
+        (parted) quit
+        </pre>
+
+        <pre>
+        # resize2fs /dev/mapper/nbd0p3
+        # e2fsck /dev/mapper/nbd0p3
+        </pre>
+
+        <h2 id="net">3. Network</h2>
 
         <p>Network configuration;</p>
 
@@ -140,7 +203,7 @@
         KERNEL=="tun", GROUP="kvm", MODE="0660", OPTIONS+="static_node=net/tun"
         </pre>
 
-        <h3>2.1. Routing</h3>
+        <h3>3.1. Routing</h3>
 
         <p>Create interface with correct permissions set for kvm group.</p>
 
@@ -152,7 +215,7 @@
         # iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -j MASQUERADE
         </pre>
 
-        <h3>2.2. Public Bridge</h3>
+        <h3>3.2. Public Bridge</h3>
 
         <p>Create <a href="network.html#bridge">bridge</a>, create new
         tap and add it to bridge;</p>
@@ -162,7 +225,7 @@
 
         ADDR=10.0.0.254
         NET=10.0.0.0
-        GW=192.168.1.254
+        GW=10.0.0.1
         MASK=24
 
         # one tap for each cpu core
@@ -213,7 +276,7 @@
         # End of file
         </pre>
 
-        <h2 id="guest">Guest System</h2>
+        <h2 id="guest">4. Guest System</h2>
 
         <p>See <a href="scripts/runvm/runvm.sh">scripts/runvm/runvm.sh</a>,
         as template. Example scripts;</p>
@@ -253,7 +316,7 @@
         <p>Set guests machines to run under the total resolution provided
         by  host system configure grub on the guest with gfxmode;</p>
 
-        <h3 id="guest">Guest Graphics</h3>
+        <h3 id="graphics">4.1. Guest Graphics</h3>
 
         <p>Get current resolution on host machine;</p>
 
@@ -275,7 +338,7 @@
         # update-grub
         </pre>
 
-        <h3 id="sound">Guest Sound</h3>
+        <h3 id="sound">4.2. Guest Sound</h3>
 
         <p>Check if DMAR is enable on kernel configuration,
         Intel and AMD uses different technology. To check on
@@ -298,11 +361,12 @@
         other="-soundhw hda -vga std -display sdl"
         </pre>
 
-        <h3 id="sound">Guest USB</h3>
+        <h3 id="usb">4.3. Guest USB</h3>
 
         <pre>
         # lsusb
         # ls /dev/v4l
+        # ls /dev/bus/usb
         </pre>
 
         <pre>
@@ -319,9 +383,26 @@
         mac="54:60:be:ef:5c:72"
         other="-soundhw hda -vga std -display sdl -usb -device usb-host,vendorid=0x13d3,productid=0x5652"
         </pre>
+
+        <h2 id="bootusb">5. Boot iso on usb</h2>
+
+        <pre>
+        # lsusb
+        # ls /dev/bus/usb
+        </pre>
+
+        <pre>
+        # chown root:kvm /dev/bus/usb/003/012
+        </pre>
+
+
+        <pre>
+        $ qemu-system-x86_64 -m 512 -enable-kvm -vnc :0 -usb  -device usb-host,hostbus=3,hostaddr=12
+        </pre>
+
         <a href="index.html">Tools Index</a>
         <p>This is part of the c9 Manual.
-        Copyright (C) 2016
+        Copyright (C) 2018
         c9 team.
         See the file <a href="../fdl-1.3-standalone.html">Gnu Free Documentation License</a>
         for copying conditions.</p>