Quick qemu (virtual machines made easy) date: 2014-09-20 23:21:50+00:00
This assumes that you already have an iso to install from. If you're just using a live CD, skip making a virtual hard drive and drop the "-hda" argument from booting the machine. If you can spare it, give the VM more RAM by increasing 256 to something higher
First, you need a hard drive image. Raw images are useful, but qcow2 is sparse, so it won't gobble a lot of space for a quick test machine.
qemu-img create -f qcow2 fbsd0.qcow2 5G
Then boot the VM from your iso with the hard drive attached:
qemu-system-i386 -cdrom ~/Downloads/FreeBSD-10.0-RELEASE-i386-bootonly.iso -hda fbsd0.qcow2 -boot d -net nic -net user -m 256 -localtime
Once you've installed your system, shut down and then start from the hard drive:
qemu-system-i386 -hda fbsd0.qcow2 -boot c -net nic -net user -m 256 -localtime
Most of this was based on https://fedoraproject.org/wiki/Howtouseqemu except that I had to specify the disk format
Explanation:
-
qemu-img: manipulates qemu virtual disks
-
create: we're creating a disk image; alternative uses include resize, convert, and check
-
-f qcow2: use the qcow2 format for the image
-
fbsd0.qcow2: file name to save the disk image in
-
5G: set its max size to 5 Gigs; because qcow2 is a sparse format, this will not be preallocated by default
-
-
qemu-system-i386: the actual virtual machine; replace with -x8664 for a 64 bit machine (or something else)
-
-cdrom yourImageHere.iso: sets the VM's CD drive to attach to our iso
-
-hda fbsd0.qcow2: set the first hard disk to the image file we just made
-
-boot d: boot from the CD drive (d = CD drive, c = hard disk)
-
-net nic -net user: I'm pretty sure this is setting the VM to have a NIC for network that runs through user mode networking in qemu
-
-m 256: give the VM 256 Megs of RAM (give it more if you can)
-
-localtime: keeps the VM's clock in step with the real world
-