Iam going to build this based on a series of small posts I've made as I feel much of the information is actually hard to find and piece together from the rest of the web.
What I'm going to focus on is how to use virtio as the NIC because if you don't you get very slow NIC speeds but with the virtio NIC model you basically get host speeds.
/usr/libexec/qemu-kvm -enable-kvm -smp 8 -m 16000 -net user -net nic,model=virtio -drive file=ubuntu-gpt2large.img,if=virtio........
This is caused because the user is running as qemu for virt-resize and if qemu does not have privileges to read from the source and write to the destination, it will fail with the below. So either change the uid of qemu or change the ownership of the source and target.
virt-resize --expand /dev/sda2 /root/kvmtemplates/windows2019-eval-template.img /root/kvmguests/kvmkvmuser451511/kvmkvmuser451511.img
[ 0.0] Examining /root/kvmtemplates/windows201........
The reason for doing this is that the installer doesn't seem to work properly for LUKS and the server installer doesn't even support LUKS anymore. When you use the GUI install on Desktop for LUKS it won't boot and will just hang after you enter your password. So the only reliable way is to do it ourselves.
1.) Make a default minimal install of Ubuntu
2.) Have a secondary disk on the server or VM.
The cool thing here is that we only need 1 drive to make a RAID 10 or RAID 1 array, we just tell the Linux mdadm utility that the other drive is "missing" and we can then add our original drive to the array after booting into our new RAID array.
Step#1 Install tools we need
yum -y install mdadm rsync
Step #2 Create your partitions on the drive that will be our RAID array
Here I assume it is /dev........
This should work but the key thing is having the "-cpu host" flag.
Once you add the correct -cpu host flag then it should boot just fine on KVM.
qemu-system-x86_64 --enable-kvm -cpu host -smp 8 -m 8192 -drive format=raw,file=the-file.img
Examples can be found here on how to boot Windows properly with KVM.........
dd is a very handy tool and there are some more practical things we can do. For example if we want to dump a 3TB drive and want to preserve it and only 200GB are being used on the 3TB we can save a lot of space with gzip.
Backing Stuff up with dd
How to Use dd to backup a raw hard drive and tar gzip at once
Change /dev/sda to the drive you want to backup
This problem has been around forever, Linux seems to think it is fine to use the r8169 driver for an r8168 NIC but this often causes problems including the link not working at all.
In my case ethttool shows the link up and detected but it simply does not work especially on a laptop that has been resumed from suspension. Sometimes it takes several minutes for it to work or to unplug and replug the ethernet.
Here is the solution:
Now older versions of qemu-kvm didn't throw this error say if you just had "-video cirrus" when starting qemu-kvm. But newer versions do care.
And this probably only applies to you if you are running from bash/terminal with remote kvm images.
What you need to do is remove the "-video" part and just add -vnc :5
eg. this would fix the error:
qemu-system-x86_64 -enable-kvm -boot order=cd,once=dc -m 1024 -drive........
This is something I've seen some run into. Take an old install of Linux Mint 18.1
ii linux-image-4.4.0-53-generic 4.4.0-53.74 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
Install Errors on Version 12:
This error happened on QEMU emulator version 2.11.1 pve-qemu-kvm_2.11.1-5
on Proxmox/Debian but installing on QEMU.12 on Centos 6 did not produce the error.
*Update it is not related to the OS or QEMU version. This happened in Centos 6 too after a second install.
What really causes this even though you successfully install........
The strange thing is that usually the first install or two will work on any new machine but then it suddenly won't. I had this experience on QEMU 2.13 on a different machine. There is something finicky or buggy about the CUCM installer even when choosing the same virtual hardware specs.
QEMU PC emulator version 0.12.1 (qemu-kvm-0.12.1.2-2.506.el6_10.1), Copyright (c) 2003-2008 Fabrice Bellard
WARNING: Image format was not specified for '/mnt/space/cucm12.img' and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
Specify the 'raw' format explicitly to remove the restrictions.
#you should manually specify the format
The key thing is that you must use a "machine"id of "pc-1.3" or it will say your hardware is not supported.
Additionally you MUST use a virtio disk or you will get a ks_pre.sh error as soon as the install starts (a look at logs will show it can't find a disk). This is funny because even though the OS finds the disk and an fdisk -l shows it, it looks like the script looks for a /dev/vda device (virtio) and nothing else, so if you didn't use Virtio as you........
What you need to do if you have taken a dd or real raw image dump of a hard disk:
VBoxManage convertdd windows2019-eval-template.img windows2019.vdi --format VDI
The .img is the raw dd dump and the .vdi is the output file.
--format VDIspecifies to output to .vdi format
If you are in a pinch you can always use qemu-kvm binary and manually specify the .img as your disk and i........
I tried to stop a qemu-img copy or clone and it broke everything. It was fine to "stop" it from the GUI but a process still persisted so I killed the relevant qemu-img and the kernel went crazy. It also may not have helped that I tried to lvremove a different volume (an unused disk). But either way it breaks LVM (you cannot even run lvdisplay) so a reboot is necessary.
Jan 17 06:45:21 testserver kernel: [ 5680.439337] systemd-udevd D 0&nbs........
1.) Create Image using qemu-img
qemu-img create -f qcow2 skype.img 40G
2.) Start VM using flags
-m = memory in MB
qemu-system-x86_64 -m 4096 -drive file=skype.img -cdrom ~/Downloads/SfB-E-9319.0-enUS.ISO
Enable Bridged Networking........
The Correct Way To Resize In Place
qemu-img resize kvmuserwindows2008dcetest.img +1G
Below is a common mistake that some users make they are trying to specify a new image name but it can be resized in place (just make sure the VMis NOT running and you've backed up the data in case something goes wrong).
qemu-img resize kvmuser453111.img kvmuser453111-larger.img +5G
This is one thing that has me wondering about SMF. It is apparently a known issue but in the latest version and new install nothing looked right because it was using http://127.0.0.1 to find everything! How on earth would it ever do this or think it is normal?
Excerpt of crazy html code it produces that causes the issue:
guestmount -a kvmuserscra.img -m /dev/sda1 mount
libguestfs: error: mount_options: /dev/sda1 on / (options: ''): mount: unknown filesystem type 'ntfs'
guestmount: '/dev/sda1' could not be mounted.
guestmount: Did you mean to mount one of these filesystems?
guestmount: /dev/sda1 (ntfs)
guestmount: /dev/sda2 (ntfs)
yum -y install ntfs-3g
add this style="background-size: contain;max-width: 100%; height: auto;" to your img code.
/usr/bin/supermin-helper exited with error status 1.
To see full error messages you may need to enable debugging.
See http://libguestfs.org/guestfs-faq.1.html#debugging-libguestfs at /usr/bin/virt-list-partitions line 177.
Very simple browse to your /boot directory
It does make more sense to extract the image in its own directory eg "initramfs-blabla-dir" as it will literally extract directly to the pwd.
cp initramfs.img someotherdir
zcat initramfs-3.10.0-514.el7.x86_64.img | cpio -idmv........
The old MBR 512 bytes partition table is no longer valid if you are using GPT.
To copy a GPT table with dd to another disk do it like so:
Below sda is the source disk and destination disk is sdb (change to meet your needs).
dd if=/dev/sda of=/dev/sdb bs=1536 count=1
You can also use dd to backup your partition table like normal but with the bs of 1536
Done on Centos 7.3 very important as clearly based on older guides it was a lot easier and more simpler! Hint do not use grub2-install!
One huge caveat if you are an oldschool user or sysadmin who has avoided UEFIbooting
The normal way will not work here if your Centos was using UEFI. Newer systems use it by default.
The easiest way to check is to do an fdisk -l if your sy........
In this case we want to mount partition #2
fdisk -lu Centos-6.6-x86_64.img
You must set cylinders.
You can do this from the extra functions menu.
Disk Centos-6.6-x86_64.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Here is the scenario you or a client have a remote machine that was installed as a standard/default minimal Centos 6.x machine on a single disk with LVM for whatever reason. Often many people do not know how to install it to a RAID array so it is common to have this problem and why reinstall if you don't need to? In some cases on a remote system you can't easily reinstall without physical or KVM access.
So in this case you add a second physical or disk or already ha........
libguestfs tools howto guide for managing virtual machine images.
libguestfs-tools aka guestfs tools has a lot of tools that make this very easy for you. You can easily mount partitons from an image with some of the commands below.
To mount a partition
#mount the kvmuser102821.img image and the /dev/sda1 partition from it to the local directory "mount"
guestmount -a kvmuser102821.img -m /dev/sda1 mount
error: Failed to create domain from /home/kvm/kvm101/kvm101.xml
error: cannot open file '/dev//dev/kvmcontainer/kvm101_img': No such file or directory
This is caused by what we consider a quark in SolusVMthat Ihelped a client with.
SolusVMhas as config for the "LVMvolume name" and does not enforce any convention.
Naturally most technical people would use the actual path eg "/dev/kvmcontainer".
#count=10000 makes an image of 10000MB make sure your image is at least the same as your existing
dd if=/dev/zero of=yourimage.img bs=1M count=10000
# losetup -fv newimage.raw
# fdisk -cu /dev/loop0
# kpartx -a /dev/loop0
# dd if= of=/dev/mapper/loop0p1
# e2fsck -f /dev/mapper/loop0p1
# resize2fs /dev/mapper/loop0p1
# a lot of guides tell you to edit /etc/fst........
./configure: line 91: cd: /lib/modules/2.6.32-042stab084.25/build: No such file or directory
Error: kernel version not found.
Please make sure your kernel is configured.
dr-xr-xr-x. 4 root root 4096 Feb 21 06:13 ..
lrwxrwxrwx 1 root root 45 Feb 21 06:13 build -> ../../../usr/src/kernels/2.6.32-042stab084.25
drwxr-xr-x 2 root root 4096 Feb 12 20........
root@hkhosting [/]# service httpd start
Starting httpd: Syntax error on line 2 of /etc/httpd/conf/httpd.conf:
Invalid command 'Alias', perhaps misspelled or defined by a module not included in the server configuration
I was having an issue with only certain random/jpeg files with the functions imagecreatefromjpeg imagecreatetruecolor and other related ones.
This issue was annoying basically it seems like a libgd issue/bug with newer versions of PHP and it was difficult to trace-out. One very useful thing that helped me was using "php-cgi" and passing the query string as an argument eg:
php-cgi images.php source=IMG.jpg (that way you get all the error messages wh........
On the same OS with the same kernels basically I cannot boot FreeBSD installer, I believe the issue is the host CPU.
One host runs an Intel and works, while an Opteron 2373 does not work despite suggestions from this thread: http://184.108.40.206/showthread.php?t=36761
I've tried cpu options like "kvm64" "Opteron_G3" and none........
mount -o bind /proc /sda2/proc
mount -o bind /dev/ /sda2/dev
mount -o bind /sys /sda2/sys
mint / # mount -o bind /proc /sda2/proc
mint / # mount -o bind /dev/ /sda2/dev
mint / # mount -o bind /sys /sda2/sys
mint / # chroot /sda2
mint / # cd ~
mint ~ # ls
mint ~ # cd /
mint / # ls
bin Desktop dev-temp home&nb........
guestmount -a yourimage.img -m /dev/sda1 --ro /mountpoint
Change "yourimage.img"to the actual disk image.
Change "/dev/sda1" to the device on the disk image you want to mount.
--ro is specified only if you don't want write access (good to ensure you don't mess anything up if you just want to recover data).........
qemu-img create -f qcow2 isotest.qcow2 10G
The above creates a "qcow2" format image called "isotest.qcow2" that is 10GB in size.
If you want to preallocate all of the space for increased performance do this:
qemu-img create -f qcow2 isotest.qcow2 -o preallocation=full 10G
It is controlled with the preallocation=full option, of course by default this is set to off........
cat | grub --device-map=/dev/null
Now pay close to the attention of the beginning.
Type: "device (hd0) VPS.img" this is telling what hd0 will be to GRUB and we're telling it the disk image file "VPS.img" in the current directory is hd0, you can specify alternate paths and image names of course.
GNU GRUB version 0.97 (640K lower / 3072K upper memory)
[ Minimal BASH-li........
This booting error is because the Xen PV guest image uses the Xen kernel, this is not compatible with anything but a host running a Xen kernel.
I did a kpartx -av virtual.img and then it created some partitions that showed up in fdisk.
I mounted it and did a chroot into it and removed the xen kernel and installed a normal kernel but Xen still shows the same kernel in Grub (only the Xen one).
This is strange but it seems like this Xen PV guest has some sort of hidden or........
The example below converts youvm.img into a vdi.
The -O vdi specifies the new format will be vdi but you can use any other valid formats/vice versa.
qemu-img convert yourvm.img -O vdi yourvm.vdi
This is very handy for those who need to switch between virtualization technologies.........
This is something I often setup for clients because it's very helpful for people in datacenters, this allows custom OS installs on demand, you can customize it more by using kickstart etc.. but here's a base I use before customizing more:
This little script below will install everything you need to get booting by PXE Linux.
It also assumes you set a local IP (be sure not to overwrite your existing IP) on eth0:0 (note the :0) as 192.168.1.10 and it........
qemu-img create -b centos.5-8.x86.20120308.qcow2 -f qcow2 ../kvmguests/25000-centos5.8x86.qcow2
Formatting '../kvmguests/25000-centos5.8x86.qcow2', fmt=qcow2, backing_file=centos.5-8.x86.20120308.qcow2, size=10485760 kB
-b the source/base image
-f format is qcow2 and the location of the destination image
What is so special about this? It's even quicker than creating a template with OpenVZ but this is an actual OS.
It saves time a........
GNU Parted 1.8.8
Welcome to GNU Parted! Type 'help' to view a list of commands.
I backed up everything in the /mnt/sd_card directory thinking that some dataloss could occur for some reason but purposely left my microSDHC unbacked up thinking that "it won't touch that since it's external" and Samsung's and other manufacturers website even say this (that it won't be affected and not to worry etc).
Apparently I was wrong, my microSD was "undetected" and asked to be formatted after the upgrade (there goes 3-months worth of family photos). No........
fdisk -lu VPS.img
last_lba(): I don't know how to handle files with mode 81ed
You must set cylinders.
You can do this from the extra functions menu.
Disk VPS.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End ........
I dread updating the kernel and rebooting to find the Ubuntu graphics aren't working and you have to manually intervene. This is usually because Ubuntu for whatever reason didn't update the drivers you need (eg. the manually compiled Nvidia Kernel driver that MUST be recompiled for each and every kernel update unfortunately).
The most common reason may be that "linux-source" hasn't been installed automatically on my system. I tried to manually reinstall the........
I found this technique listed in many places which shows you how to use a common Linux tool "dd" to dump the raw partition of your iPhone.
I give credit to this site for showing me the correct way to dd from the iPhone, I never thought to try it in the other direction:http://log.ijulien.com/post/182804914/iphone-3gs-data-recovery
1.) Jailbreak your........
I'm posting this because it wasn't easy or obvious how this would be accomplished and the man page leaves it to guesswork.
Copy the initrd to somewhere else, say /tmp:
mv initrd.img to initrd.gz
*the mv to .gz is needed otherwise gunzip won't work/it will refuse to operate without the correct .gz extension
cat initrd | cpio -idmv
The last command extracts the contents of initrd to your present working directory.
For 7z .lz initrd........
I wanted to Import/Use a .vmdk hard disk image file from VMWare. Generally you can just "point" VirtualBox to it and use it and it will work but I found an exception.
One of my Centos 4.4 x64 images wouldn't boot. I had two copies, an older one and the newer one. The older one booted as normal (once I changed the VirtualBox driver to IDE from SATA). The newer one stopped at the "GRUB loading" message no matter what I tried.
As far as........
Iused to get all kinds of weird annoying characters like "‚" during compilation with gcc especially.
dmg2img.c:456: error: ‚BZ_OK‚ undeclared (first use in this function)
dmg2img.c:471: warning: implicit declaration of function ‚BZ2_bzCompressEnd‚
dmg2img.c:482: warning: implicit declaration of function ‚BZ2_bzDecompress‚
dmg2img.c:484: error: ‚BZ_PARAM_ERROR‚ undecl........
The dmg format is silly and annoying to work with, why couldn't Apple stick with the .iso standard? Anyway, there's an excellent Linux and Windows based tool to convert it back to a normal .iso Image called dmg2iso
I'll only cover theLinux version although the Windows pre-built binary works the same way.
Download dmg2iso here for free (from the author's website)
It's just silly and doesn't make sense that Ubuntu doe........