This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
command_line [2012/06/15 10:16] k2patel [Quick Command Ref.] |
command_line [2021/08/24 21:11] (current) k2patel |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
+ | |||
====== KVM Command Line ====== | ====== KVM Command Line ====== | ||
Line 29: | Line 31: | ||
[[http://libvirt.org/formatdomain.html|Domain Format in KVM]] | [[http://libvirt.org/formatdomain.html|Domain Format in KVM]] | ||
+ | |||
+ | ==== Test your bootable USB on kvm ==== | ||
+ | In order to test your USB using KVM use following command. | ||
+ | <code bash> | ||
+ | qemu-kvm -hdb <device> | ||
+ | </code> | ||
+ | In my case device was "/dev/sdb". | ||
==== Converting Existing Image ==== | ==== Converting Existing Image ==== | ||
Line 127: | Line 136: | ||
=== Create Disk === | === Create Disk === | ||
create disk of size 10G | create disk of size 10G | ||
+ | <code bash | for dynamic allocation> | ||
+ | qemu-img create -f raw vdisk.img 10G | ||
+ | </code> | ||
+ | OR | ||
+ | <code bash | preallowcation> | ||
+ | dd if=/dev/zero of=vdisk.img bs=1G count=0 seek=[NUMBER_OF_GB] | ||
+ | </code> | ||
+ | |||
+ | ==== How to allow network access to KVM Guest ==== | ||
+ | |||
+ | Modify guest.xml file and listen variable. | ||
+ | <code bash | vi /etc/libvirt/qemu/Archlinux.xml> | ||
+ | <graphics type='vnc' port='-1' autoport='yes' listen='192.168.1.4' passwd='testing1'/> | ||
+ | </code> | ||
+ | |||
+ | ==== Extract folder from KVM Guest Image ==== | ||
+ | This appears to be the far easy solution than I thought.\\ | ||
+ | [[http://libguestfs.org/virt-copy-out.1.html|Link to official Document]] | ||
+ | |||
+ | For RHEL you require the following packages installed. | ||
+ | * libguestfs-tools | ||
+ | * libguestfs-xfs # if guest filesystem is XFS. | ||
+ | |||
<code bash> | <code bash> | ||
- | qemu-img create -f qcow2 vdisk.img 10G | + | mkdir test |
+ | virt-copy-out -a machine2.qcow2 /metadata/testing/users test/ | ||
</code> | </code> | ||
+ | ==== Image File explorer ==== | ||
+ | This is a simple way to extract or access files.\\ | ||
+ | Scan and assign the dev node. | ||
+ | <code bash> | ||
+ | losetup --partscan --find --show sdcard.img | ||
+ | </code> | ||
+ | |||
+ | List all the block devices, including newly scanned. | ||
+ | <code bash> | ||
+ | lsblk --fs | ||
+ | </code> | ||
+ | |||
+ | Mounting the file system | ||
+ | <code bash> | ||
+ | mount /dev/loop0p2 /mnt/sdcard | ||
+ | </code> | ||
+ | |||
+ | Once unmounted remove the lo drive. | ||
+ | <code bash> | ||
+ | losetup --detach-all | ||
+ | </code> | ||