Install and use qemu Virtual Machine in BSD

Source: Internet
Author: User
What virtual machines are used in windows? Maybe most of them use VM Ware. What about BSD? When I still use 4.10, I also use VM ware, but the VM ware requires an authorization file, but this file can be downloaded. But now, we have a better choice in BSD, namely, qemu, an open-source virtual machine, which is small and fast, I plan to create a virtual win under BSD and enable win to access the Internet.

1 first, use ports to install

Code: [copy to clipboard] # cd/usr/ports/emulators/qemu

# The path is hard to remember. Sorry

Code: [copy to clipboard] # Make with_kqemu = Yes install clean

# Here is an option, with_kqemu, which was not installed at the beginning, resulting in an error. With this option, kqemu. Ko will be added during BSD startup.
Then it will take several minutes to install qemu soon (haha, shorter than the VM time)

2. Use qemu,
First, we recommend that you restart BSD. Of course, you can do it without restarting. follow these steps:

Code: [copy to clipboard] # rehash
# Kldload kqemu. Ko

3. Prepare a disk for the VM. We recommend that you use files in the IMG format as Virtual Disks. Of course, qemu is compatible with VM files. If you are interested, try again. I personally feel that IMG's disk files will be faster. Look down

Code: [copy to clipboard] # mkdir/tmp/qemu # Find a place to install your VM. Pay attention to your own space. Do not put it directly under/like me, insufficient space. We strongly recommend that you first run the DF-H code: [copy to clipboard] # cd/tmp/qemu
# Qemu-IMG create windows. IMG 2G # This is to create a virtual machine disk. The 2g after this is to create a 2G disk.

4. Next I want to install the virtual machine. I have two hands to prepare, one is the optical drive and the other is the ISO file. Install

Code: [copy to clipboard] # qemu-hda windows. IMG-CDROM/dev/acd0-boot D-M 512-enable-audio-localtime

Explain the above Syntax:
-Hda is the specified hard disk. In this article, we use the created/tmp/qemu/Windows. IMG.

-CDROM specifies to use the optical drive. This parameter must be followed by a file name. In the above example, I used my physical drive/dev/acd0. If you want to use the ISO file, then write the file path. For example, I used/MTN/e/XP for the second installation. ISO

-M indicates the memory size used by the VM. The following number indicates the memory size you want to specify. My memory size is 512 MB.

-Boot is of course the device used to start the VM. After-boot, you can select the following parameters: A, C, D. a Refers to the boot from a floppy disk, C is the boot from the hard disk, and D is the boot from the optical drive.

-Enable-audio.

-Localtime indicates the time required to use the BIOS of your actual motherboard.

Now, after following the above steps, you can smoothly enter the Virtual Machine and start the installation.

* Note: if you do not select with_kqemu when installing qemu, you will not be able to use the ISO file for installation. If you want to install kqemu. Ko on your own:

Code: [copy to clipboard] # kldstat

The following is a reference to the use of qemu in Linux. Since qemu is cross-platform, it should be generic. Of course, I just provide a reference for possible problems:

Code: [copy to clipboard] changing the disk is required during installation:

In qemu press CTRL + ALT + 2 to switch to qemu monitor mode input? Or help to view available commands and instructions.

(In other versions of qemu, after qemu is run to load the OS, the shell will automatically change to the qemu monitor mode)

Change device filename -- change a removable media

It seems that it is used to change the disk: Change CDROM/RHEL4/el_disc2.iso

5. You can use the VM after it is installed. Here are some common shortcut keys:

Code: [copy to clipboard] CTRL + ALT + f full screen switch
CTRL + ALT mouse switch between Vm and host

6. Virtual XP Internet access problems:
In fact, after the above method is installed, your XP has been able to access the Internet, of course, you need to use DHCP. You can also add the-user-net parameter at startup. I think qemu may bring this parameter by default, because I can access the Internet without any parameters.

However, to use this default parameter, you can only ping your BSD host, but cannot ping the Internet. The IP address you get is 10.0.2.x, And the gateway must be 10.0.2.2, so don't be surprised. In this way, it is inconvenient for the host to communicate with the Virtual Machine. At least Samba cannot be used and cannot be resolved.

Qemu also provides the second method for accessing the Internet: tun. This method is to virtualize a network card tun0 under your BSD, so that your BSD is connected to the Internet through a dual network card, the biggest advantage of this method is that it is easier for the VM to communicate with the host over the Internet. But first, your kernel must support Tun devices. My 5.4 release-p6

We should do this before 5.0:

Code: [copy to clipboard] # cd/dev
# Sh makedev tun0

If you are like me, it is 5. X:

Code: [copy to clipboard] # mknod tun0 C 20 0
# Ls/dev

Next:

# Ifconfig tun0 XXX. XXX # sets the tun0 IP address. Generally, it starts with 192.168. Some people like the IP address starting with 10. Whatever it is, my name is 192.168.0.1.

Enter the Virtual Machine XP, set your IP address to 192.168.0.xxx, and the gateway to 192.168.0.1 (* tun0). The DNS is the DNS of the BSD host.

After this setting, the virtual machine cannot access the Internet, but Samba can be used. If you want to use a virtual machine to access the Internet, you need to use NAT. The setting method is exactly the same as that of Nat. I will not talk about it much. The following is just a reference to FreeBSD's Nat.

If you are interested, refer to the followingArticle:
Http://www.vmware.cn/Article/376... g.tw/index.php/qemu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.