qemu 在當前OS中執行其它的作業系統
qemu從某種意義上功能類似於vmware/virtual box之類的軟體,可以讓你在當前OS中執行其它的作業系統,但是這僅僅是qemu的一種功能
qemu還可以模擬不同的cpu架構下的系統,比如在普通的個人pc上執行 arm linux之類,這個vmware之類的可能沒有
關於qemu的使用
先到官網上下載qemu的原始碼,目前是 1.2,如果使用的是linux系統,這個好辦,直接編譯安裝,網上有不少說明的文件
使用的過程一般分為三步
1. 建立虛擬機器檔案系統
qemu-img create /f qcow2 xxx.img 10G
2. 在虛擬機器檔案系統中安裝作業系統
qemu-system-i386 -hda xxx.img -cdrom xxx.iso -boot d 以xxx.img為檔案系統,xxx.iso是系統安裝ISO檔案
3. 執行安裝好的作業系統
qemu-system-i386 -hda xxx.img 執行xxx.img中的系統
Creating a hard disk image
If you are using FILO, you must create a hard disk image containing the Linux kernel and optional initramfs that FILO loads.
Whether or not you use FILO, you may also wish to populate the disk image with the root filesystem of whatever Linux distribution you want to run.
Create an empty disk image:
$ qemu-img create -f raw disk.img 200M
Format it:
$ mkfs.ext2 -F disk.img
The remaining steps must be performed as root. Create a temporary mountpoint and mount the image:
# mkdir /mnt/rootfs # mount -o loop disk.img /mnt/rootfs
Create a boot directory and copy your Linux kernel (vmlinuz) and initramfs (initrd) to it:
# mkdir /mnt/rootfs/boot # cp vmlinuz /mnt/rootfs/boot/vmlinuz # cp initrd /mnt/rootfs/boot/initrd
At this point, you can also copy a complete root filesystem to the disk image.
# cp -R /* /mnt/rootfs
Alternatively, with Debian you can use the debootstrap command to create a basic root filesystem:
If you are using a debootstrap filesystem, open the file /mnt/rootfs/etc/inittab and change runlevel to level 1:
id:1:initdefault:
cd out of /mnt/rootfs and umount it:
# umount /mnt/rootfs
Exit from the root account:
# exit
Starting coreboot in QEMU
Execute QEMU using the following parameters:
$ qemu -bios path/to/coreboot.rom -hda disk.img -nographic