KVM on Debian

来自开放百科 - 灰狐
跳转到: 导航, 搜索

1. Run these commands as root:

# apt-get update
# apt-get install kvm kvm-source qemu module-assistant
# m-a a-i kvm

Depending on if you are using an AMD or Intel processor, run one of these commands:

# modprobe kvm-amd
# modprobe kvm-intel

2. The installation of kvm created a new system group named kvm in /etc/group. You need to add the user accounts that will run kvm to this group (replace username with the user account name to add):

# adduser username kvm 

3. Log out and then login again to acquire the new group added to the account. The following commands can be run with an ordinary user account that is a member of the kvm group.

4. Create a virtual disk image (10 gigabytes in the example, but it is a sparse file and will only take as much space as is actually used, which is 0 at first, as can be seen with the du command: du vdisk.qcow, while ls -l vdisk.qcow shows the sparse file size):

$ qemu-img create vdisk.qcow 10G

5. Install an operating system. The -m option sets the RAM size for the guest, in megabytes:

$ kvm \
   -hda vdisk.qcow \
   -cdrom /path/to/boot-media.iso \
   -boot d \
   -m 384

If you're installing Windows, add the -no-acpi flag.

6. After installation is complete, run it with:

$ kvm \
   -hda vdisk.img \
   -m 384

7. Read the manual page for more information:

$ man kvm