In the past year or two, I have been using a laptop provided by the company. Due to security restrictions, I cannot install some virtual machine software, which makes me always feel troublesome during the learning process. Therefore, I have always wanted to try a free virtual machine software, using Windows The built-in service Hyper-V is implemented. I also tried to use Hyper-V 1 or 2 years ago. I was stuck in the problem of connecting to Wi-Fi and being able to access the server in Hyper-V with a fixed IP at the same time, so I never used this solution. Recently I tried this solution again and finally solved it. Now make the following summary, some of which are written by netizens.
Enable Hyper-V service
Right-click the Windows button and select Apps & Features.
Select “Programs and Features” on the right under relevant settings.
Select Turn Windows features on or off.
Select Hyper-V and click OK.
After the installation is complete, you will be prompted to restart your computer.
This part will not be described one by one. If there is anything unclear, you can check it online by yourself.
The following is an example of installing Centos under Hyper-V:
The following is reproduced from: https://blog.csdn.net/qq_31362933/article/details/132280598?spm=1001.2014.3001.5502
Step 1: Download the image file
We go to the centos official website download address to download. This article uses centos version 7.9 as an example. The download source is Alibaba Cloud. If you need to download other versions, you can download it yourself through the centos download URL.
centos-7.9.2009-isos-x86_64 installation package download_open source mirror station-Alibaba Cloud
Step 2: Enable Hyper-V
First, we configure the network environment of the virtual machine, as shown below, click on Virtual Switch Manager.
Then we create a virtual network switch (this step can be left unconfigured for the time being, use the Default Switch below directly (to obtain dynamic IP + use wi-fi), later configure the external network + reconfigure the network when accessing with a fixed IP )
The following page appears, click OK, and our virtual network switch is completed.
Next we are going to install centos. On the home page, click on the small triangle on the right of the new operation bar.
Select the virtual machine from the pop-up options. The following pop-up box will appear. Click the next page directly.
Create your virtual machine name, you can set it such as centos7.9, click next page?
Specify algebra
Allocate memory, you can allocate memory according to your actual needs
Configure the network and select the switch virtual network we created initially
By connecting to a virtual network disk, you can specify the installation location and hard disk size, and allocate them on demand.
Installation options, click Install operating system from bootable CD/DVD-ROM, and select the ISO image file we downloaded in the first step
Click Finish
Step 3: Install CentOS
Return to the Hyper-v homepage, select the CentOS7 we just created, and click Start
Use the up and down keys on the keyboard to select Install CentOS 7 and hit Enter
Select installation language
Summary of installation information, select installation location
Next we click on Network and Hostname to configure our network
User configuration, create our root password
Note: There is a restart in this section. It is found that when Hyper-V restarts, it will still enter the installation interface, similar to the following:
The solution is to create the CD-ROM drive’s startup item in the first place. Check virtual machine startup items
The following is reproduced from: https://blog.csdn.net/a2262726/article/details/109185657
Solution: Close the opened centos7 virtual machine, enter the Hyper-V centos8 setting interface CD/DVD and select “None” → “Confirm”. An interface similar to the following:
Check: Restart the centos virtual machine, similar to the following:
Start the system
Login to linux
Ok, our system is installed.
Please see the next chapter for the basic configuration of the centos system.
Solve the problem of being unable to connect to Wi-Fi after configuring a fixed IP, or the problem of not being able to use fixed IP at the same time
Refer to another blog post:
[Hyper-V manager virtual machine configures a fixed IP for the internal and external networks]
Solution to the problem of being unable to wget or install vim after just installing it
It cannot be installed because the default repo of Centos is an unavailable address. The solution is to replace it with Alibaba’s repo (if wget cannot be used, go directly to: /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d, then download it, and then configure the file content by manual editing)
# 1. Download and install wget yum install -y wget # 2. Back up the default yum mv /etc/yum.repos.d /etc/yum.repos.d.backup # 3. Set up a new yum directory mkdir -p /etc/yum.repos.d # 4. Download the Alibaba yum configuration to this directory and select the corresponding version. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo # 5. Update the epel source to Alibaba Cloud epel source mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo # 6. Rebuild cache yum clean all yum makecache # 7. Check how many packages there are in the yum warehouse yum repolist
After execution, execute the following command:
yum install -y wget yum -y install vim yum update -y --skip-broken --nobest
There may be something like:
Error: Failed to download metadata for repo appstream: Cannot prepare internal mirror
This kind of problem.
The solution is to execute:
/etc/yum.repos.d sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
Use git bash shell to access the server remotely
Something like this: