From 2e952e8ae40eaf147b6cba822411db93a8ee9190 Mon Sep 17 00:00:00 2001
From: Silvino Silva Load modules, in this case kvm of intel cpu; Add users to kvm group; To disconnect image disk (ndb);
+ To disconnect image disk (ndb); You can use image as a normal disk, example how
+ Information about preparing
+ partitions
+ and storage administration.
+ You can use image as a normal disk, example how
to use parted to create a gpt system table; More information about
- gpt partition table.
- If partitions are on qcow2 image then setup partitions; Mount partition; Network configuration;1. Host System
+
+ # modprobe -a kvm-intel tun virtio
+
+
+
# usermod -a -G kvm c9admin
# usermod -a -G kvm username
@@ -42,40 +50,51 @@
$ sudo qemu-nbd -c /dev/nbd0 /crux-img.qcow2
-
$ sudo qemu-nbd -d /dev/nbd0
-
# parted /dev/nbd0
(parted) mklabel gpt
+ (parted) mkpart ext4 0% 100%
+ (parted) set 1 boot on
-
+ # kpartx -a -s -l -u /dev/nbd0
+
-
+ # mkfs.ext4 /dev/mapper/nbd0p1
+
+
+
- # kpartx -a -s -l /dev/nbd0
+ # mount /dev/mapper/nbd0p1
2. Network
@@ -90,7 +109,7 @@
you can set only user or group;
- # tunctl -u username -g kvm + # tunctl -u username -g kvm -t tap0
Set permissions to existing tap interface;
@@ -102,12 +121,24 @@Manual creation of tap interface;
-- # ip tuntap add name tap0 mode tap ++ ++ # ip tuntap add name tap0 mode tap # chmod 0666 /dev/tap0 # chown root:username /dev/tap0 - # ip link show -+
+ # ip addr add 10.0.2.1/24 dev tap0 + # ip link set dev tap0 up + # ip link show ++ +
+ # sysctl -w net.ipv4.ip_forward=1 + # iptables -t nat -A POSTROUTING -s 10.0.2.0/24 -o eth0 -j MASQUERADE ++ +
Start qemu with 512 of ram, mydisk.img as disk and boot from iso
@@ -117,25 +148,19 @@ -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 ++ $ 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 -- Tools IndexThis is part of the c9 Manual. Copyright (C) 2016 -- cgit 1.4.1-2-gfad0