KVM下安装操作系统

时间:2022-12-19 18:01:09


本文假设已安装完成kvm,如果未安装。KVM安装查看

文章来源,翻译自http://www.linux-kvm.org/page/HOWTO1


为用户创建系统空间

/usr/local/kvm/bin/qemu-img create -f qcow2 vdisk.img 10G 

vdisk.img 表示我们即将分配的系统所占空间的大小,相当于在我们的硬盘上分离出了一个10G的空间,
用于虚拟机中操作系统的空间分配。我安装的XP ,分配了5G足够了,没有用10G 。


安装操作系统

sudo /usr/local/kvm/bin/qemu-system-x86_64 -hda vdisk.img -cdrom /path/to/boot-media.iso \ 
-boot d -m 384
此句命令是利用 qemu-system-x86_64 这个工具把系统安装在刚刚分配完空间的vdisk.img 里面,其中注意的是:
/path/to/boot-media.iso 是你所安装的系统目录。比如我的就是 home/yaung/app/winxp.iso
此处还需格外注意的是:注意你的工作目录,也就是你运行命令的目录,应该在上一步就该注意一下,你把vdisk.img
分配到那个目录下也就意味着你的系统将安装在何处。
值得一提的事,也可以安装在WINDOWS分区下,(因为本人为双系统,win7 + ubuntu ,在ubuntu下对windows分
区是可见的,当时因为在windows分区目录下执行的安装命令,所以就把系统又安装在windows分区下了)

(kvm doesn't make a distinction between i386 and x86_64 so even in i386 you should use `qemu-system-x86_64`)​​BR​

If you have less than 1GB of memory don't use the -m 384 flag (which allocates 384 MB of RAM for the guest). For computers with 512MB of RAM it's safe to use -m 192, or even -m 128 (the default)



运行安装的用户系统

sudo /usr/local/kvm/bin/qemu-system-x86_64 vdisk.img -m 384

or a slightly more complicated example, where it is assumed that bridged networking is available on tap0; see ["Kernel-optimizations"] for some setup hints:

/usr/local/kvm/bin/qemu-system-x86_64 -hda xp-curr.img -m 512 -soundhw es1370 -no-acpi -snapshot -localtime -boot c -usb -usbdevice tablet -net nic,vlan=0,macaddr=00:00:10:52:37:48 -net tap,vlan=0,ifname=tap0,script=no

(kvm doesn't make a distinction between i386 and x86_64 so even in i386 you should use `qemu-system-x86_64`)

If you're on Debian Etch, substitute `kvm` for `qemu-system-x86_64` (thanks to fromport, soren and mael_). See also the entries under the label "Ubuntu" on the​​HOWTO​​ page.qemu-system-x86_64`

If you're on Fedora/RHEL/CentOS (and installed a kvm package and not built kvm yourself from source) then substituteqemu-kvm for qemu-system-x86_64

说明:
(1).如果你要安装windows系统,要在命令中添加参数-no-acpi。
(2).  如果你的内存不到1G,不要加入参数-m 384,否则将会把384m的内存分配给客户机。如果你的内存是512m,保险的做法是将参数设置为:-m 192,或者是-m128(这是默认值)。