2015年9月2日 星期三

[ QEMU KVM ] Install Windows7 with KVM from CentOS7

Install KVM 
First thing first. Let's install KVM packages: 
# yum -y install qemu-kvm libvirt virt-install bridge-utils tigervnc
# find / -name qemu-kvm // Find the location of qemu-kvm
...
/usr/libexec/qemu-kvm

# vi ~/.bashrc // Add to search path
  1. ...  
  2. export PATH=/usr/libexec/:$PATH  
  3. ...  
# . ~/.bashrc // Enable the setting
# qemu-kvm --version
QEMU emulator version 1.5.3 (qemu-kvm-1.5.3-86.el7_1.5), Copyright (c) 2003-2008 Fabrice Bellard
# lsmod | grep kvm // Make sure kvm kernel module is loaded
kvm_intel 148081 0
kvm 461126 1 kvm_intel
 

Create QCOW2 Filesystem 
We need a filesystem to install system: 
// Create simulated filesystem
# qemu-img create -f qcow2 win7.qcow2 20G
Formatting 'win7.qcow2', fmt=qcow2 size=21474836480 encryption=off cluster_size=65536 lazy_refcounts=off
# ls -lt win7.qcow2 // cow means 'copy on write'
-rw-r--r-- 1 root root 197120 Sep 1 09:44 win7.qcow2
# qemu-img info win7.qcow2 
image: win7.qcow2
file format: qcow2
virtual size: 20G (21474836480 bytes)
disk size: 196K
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false

# qemu-img resize win7.qcow2 35G // Resize the filesystem to 35G
Image resized.
# qemu-img info win7.qcow2
image: win7.qcow2
file format: qcow2
virtual size: 35G (37580963840 bytes)
disk size: 200K
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false

Start KVM And Installing Windows7 
It's about time to start KVM and install Windows7 from ISO 'Windows_7_Home_Basic_32Bit_64Bit.iso': 
// -m megs: set virtual RAM size to megs MB [default=128]
// -hda/-hdb file: use 'file' as IDE hard disk 0/1 image
// -boot [order=drives][,once=drives][,menu=on|off]: floppy (a), hard disk (c), CD-ROM (d), network (n)
// -cdrom fileuse 'file' as IDE cdrom image (cdrom is ide1 master)

# qemu-kvm -m 1G -hda win7.qcow2 -boot d -cdrom ../vmware/ISO/Windows_7_Home_Basic_32Bit_64Bit.iso
VNC server running on `::1:5900'
# vncviewer localhost:0 // Use VNC to open UI for Windows7 Installation 

Taking Snapshot 
After installation, you can shutdown the system and create a snapshot for it: 

//Parameters to snapshot subcommand:
// 'snapshot' is the name of the snapshot to create, apply or delete
// '-a' applies a snapshot (revert disk to saved state)
// '-c' creates a snapshot
// '-d' deletes a snapshot
// '-l' lists all snapshots in the given image

# qemu-img snapshot -c "right after installation" win7.qcow2 // Create shapshot


Supplement 
Enabling Intel VT-x and AMD-V virtualization hardware extensions in BIOS 
Enable Virtual VT-x/AMD-V support in VMware Workstation 8 
虛擬機器-QEMU簡介 
CentOS7 - KVM Installation 

沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...