安装虚拟机(KVM)
这种KVM只能安装windows无法安装安卓
(From https://phoenixnap.com/kb/ubuntu-install-kvm)
A type 2 hypervisor enables users to run isolated instances of other operating systems inside a host system. As a Linux based OS, Ubuntu supports a wide range of virtualization solutions.
Aside from popular third-party apps, such as VirtualBox and VMWare, the Linux kernel has its own virtualization module called KVM (Kernel-based Virtual Machine).
In this tutorial you will learn how to install and set up KVM on Ubuntu 20.04.
Prerequisites
A system running Ubuntu 20.04
An account with sudo privileges
Access to the command line/terminal
Check Virtualization Support on Ubuntu 20.04
1. Before you begin with installing KVM, check if your CPU supports hardware virtualization via egrep command:
egrep -c '(vmx|svm)' /proc/cpuinfo
Check the number in the output:
If the command returns a value of 0, your processor is not capable of running KVM. On the other hand, any other number means you can proceed with the installation.
2. Now, check if your system can use KVM acceleration by typing:
sudo kvm-ok
The output should look like this:
If kvm-ok returns an error stating KVM acceleration cannot be used, try solving the problem by installing cpu-checker.
3. To install cpu-checker, run the following command:
sudo apt install cpu-checker
4. When the installation completes, restart the terminal.
You are now ready to start installing KVM.
Note: When it is performed for servers, hardware virtualization is referred to as server virtualization.
Install KVM on Ubuntu 20.04
To enable KVM virtualization on Ubuntu 20.04:
Install related packages using apt
Authorize users to run VMs
Verify that the installation was successful
Step 1: Install KVM Packages
1. First, update the repositories:
sudo apt update
2. Then, install essential KVM packages with the following command:
sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils
This will start the installation of four KVM packages:
3. When prompted, type Y, press ENTER, and wait for the installation to finish.
Step 2: Authorize Users
1. Only members of the libvirt and kvm user groups can run virtual machines. Add a user to the libvirt group by typing:
sudo adduser ‘username’ libvirt
Replace username with the actual username.
2. Now do the same for the kvm group:
sudo adduser ‘[username]’ kvm
Note: If you need to remove a user from the libvirt or kvm group, just replace adduser with deluser in the command above.
Step 3: Verify the Installation
1. Confirm the installation was successful by using the virsh command:
virsh list --all
You can expect an output as seen below:
2. Or use the systemctl command to check the status of libvirtd:
sudo systemctl status libvirtd
If everything is functioning properly, the output returns an active (running) status.
3. Press Q to quit the status screen.
4. If the virtualization daemon is not active, activate it with the following command:
sudo systemctl enable --now libvirtd
Creating a Virtual Machine on Ubuntu 20.04
1. Before you choose one of the two methods listed below, install virt-manager, a tool for creating and managing VMs:
sudo apt install virt-manager
2. Type Y and press ENTER. Wait for the installation to finish.
Make sure you download an ISO containing the OS you wish to install on a VM and proceed to pick an installation method.
Method 1: Virt Manager GUI
1. Start virt-manager with:
sudo virt-manager
2. In the first window, click the computer icon in the upper-left corner.
3. In the dialogue box that opens, select the option to install the VM using an ISO image. Then click Forward.
4. In the next dialogue, click Browse Local and navigate to the path where you stored the ISO you wish to install.
5. The ISO you chose in the previous window populates the field in Step 2. Proceed to Step 3 by clicking Forward.
6. Enter the amount of RAM and the number of CPUs you wish to allocate to the VM and proceed to the next step.
7. Allocate hard disk space to the VM. Click Forward to go to the last step.
8. Specify the name for your VM and click Finish to complete the setup.
9. The VM starts automatically, prompting you to start installing the OS that’s on the ISO file.
Method 2: Using Command Line
Use the virt-install command to create a VM via Linux terminal. The syntax is:
virt-install --option1=value --option2=value ...
In the following example, virt-install is used to install Fedora 33 Workstation.
Tip: For tidier appearance of commands with many options, type a back-slash after each option. That way, when you press Enter, the command will not execute, and the cursor will go to the next line.
Options behind the command serve to define the parameters of the installation.
Here is what each of them means:
Option | Description |
--name | The name you give to the VM |
--description | A short description of the VM |
--ram | The amount of RAM you wish to allocate to the VM |
--vcpus | The number of virtual CPUs you wish to allocate to the VM |
--disk | The location of the VM on your disk (if you specify a qcow2 disk file that does not exist, it will be automatically created) |
--cdrom | The location of the ISO file you downloaded |
--graphics | Specifies the display type |
Conclusion
After reading this article, you should know how to install KVM on Ubuntu 20.04. Additionally, the article describes two methods of setting up virtual machines, using the virt-manager GUI and the virt-install command.
安装虚拟机(VirtualBox)
(From https://beebom.com/run-android-on-linux-using-virtual-machine/)
Recently, we curated a list of top Android emulators for Linux systems and were disappointed to find that there is no proper application that can mimic Android on a Linux distro. That said, we did find a cool way to run Android on Linux using a virtual machine with Play Store support. And in fact, it works better than emulators due to better binary translation and desktop-like features. So in this article, we are going to show you how to run Android on Linux using a virtual machine. On that note, let’s go ahead and learn about the steps without any delay.
Run Android on Linux Using Virtual Machine
Before we go ahead, let me briefly explain how we are going to run Android on Linux. We are going to use an open-source project called Android-x86 that ports ARM-based Android OS to x86 based systems. Basically, with Android-x86’s ISO image, you can boot Android on any desktop platform, be it Windows or Linux.
You can also install and run the best of Android games and apps on your Linux machine. So here are the instructions that you have to go through to install Android on Linux as a virtual machine. You can click on the link below to seamlessly move between various sections.
Table Of Contents
Basic Setup
1. First of all, download the ISO image of Android 9 from here. Depending on your computer architecture, choose either a 64-bit or 32-bit ISO image. By the way, currently, Android 9 is the latest OS ported for desktop computers.
2. Once you have downloaded the Android ISO image, go ahead and download VirtualBox. You can find the setup file for all Linux distributions from here. After the download is complete, install VirtualBox on your system.
3. Here, I am running VirtualBox on Ubuntu. Now, click on “New” on the menubar and give a name to your virtual machine. For example, I have entered “Android”. Further, select the Type as “Linux” and choose “Other Linux (64-bit)” under Version. If you have a 32-bit machine then select “Other Linux (32-bit)”. Finally, click on “Next”.
4. On the next window, allot at least 2GB of RAM. If you have extra RAM available, increase it to 4GB for better performance while using Android.
5. Next, select “Create a virtual hard disk now” and click on “Create”.
6. Further, select “VDI” and click on “Next”.
7. Select “Dynamically allocated” and click on “Next”.
8. Here, enter the amount of storage that you want to allot to Android. The default is 8GB, but you can increase the storage to 16GB or more depending on your usage. Finally, click on “Create”.
Configure the Android Virtual Machine on Linux
1. Now that you have created the VM, it’s time to configure a few things so that you get the best performance while running Android on Linux. On the VirtualBox, click on “System“.
2. Move to the “Processor” tab and allot at least 2 CPU cores. You can also increase it to 4 for better gaming performance.
3. Next, switch to the “Acceleration” tab and choose “KVM” from the drop-down menu.
4. Once you have done that, move to the “Display” section and change the “Graphics controller” to “VBoxSVGA“. This is the most important step otherwise you will be stuck on a blank screen. Besides that, increase the Video Memory to at least 64-128MB.
5. Finally, go to “Storage” and select the “Empty” sub-menu. Here, click on the disc icon and select “Choose a disk file”.
6. Now, select the Android ISO image that you downloaded in the first step. You are basically done. Simply, click on the “OK” button.
Boot Android within Linux
1. After the basic setup and configuration, you are now ready to boot Android on Linux. Simply, select “Android” on the left pane and then click on “Start“.
2. Here, move to the “Advanced options“.
3. Now, select “Auto_Installation…” and hit enter.
4. On the next screen, select “Yes” and hit enter.
5. Finally, you will get the option to “Run Android-x86” on your Linux machine. Press enter and Android will starting booting on your Linux machine then and there.
6. You can go through the initial setup screen just like Android smartphones.
7. Finally, there you have it. Android 9 running on Linux with near-native performance. How great is that? Now onwards, you just need to press the “Start” button in VirtualBox and Android will be ready for you.
9. In case, you want to delete Android from Linux then simply right-click on the Android VM that you have created and choose “Remove”.
10. Next, click on “Delete all files”. It will remove the virtual hard drive and all associated files freeing up all the space on your computer. That’s it.
Install Android VM on Linux and Enjoy Android Games and Apps
So that is how you can install and run Android on Linux without using an emulator. One of the added benefits of this setup is that it makes things possible that you cannot do on your Android smartphone like taking screenshots on Snapchat without notifying sender, screen recording of protected content, playing games like PUBG, and much more.
You can even use Android as a desktop with the Taskbar launcher that ships with Android-x86 ISO image. Anyway, that is all from us. If you are facing any issue then do comment down below and let us know. We will surely try to help you out.
Solve network issue
(From https://askubuntu.com/questions/363003/no-internet-connection-on-virtualbox-windows-7-as-guest-ubuntu-13-04-as-host)
125
I was having the same problem on Ubuntu 12.10 64bit using Virtualbox 4.2.22. Here are the steps I took to solve my problem:
Open Virtualbox Manager
Select the machine you cannot get internet on in the left pane
Click the Settings button in the top menu
Click Network in the left pane in the settings window
Switched to Bridged Adapter in the Attached to drop-down menu
Select the name of the network adapter you are currently using on your host machine. I am using wireless so I chose eth0 which is my wireless network adapter. You can check which adapter you are currently using by opening the terminal (CTRL+ALT+T by default) and running ifconfig. It will probably be the eth adapter that shows an inet addr and shows data transfer next to RX bytes.
Under Advanced, make sure the machine is using the Desktop Adapter Type
Under Advanced, make sure Promiscuous Mode is set to Allow All
Under Advanced, make sure Cable connected is checked on
Hit OK to save your changes
Start your VM
At that point you should be able to start a web browser in your VM and get a connection. This video provided the information I listed above, even though they are using a Windows 7 host with a Windows Server guest.
This is an image showing an example of the settings you need (taken from this answer).