1.安装VirtualBox

官网下载Download

deepin && ubuntu

1
2
3
4
5
# 安装
sudo apt install virtualbox

# 卸载
sudo apt remove pool/main/v/virtualbox/

2.下载Centos镜像

阿里云镜像站https://mirrors.aliyun.com/centos/?spm=a2c6h.13651104.0.0.562e12b2jFtq9hv

开发下载Minimal版本即可,image-20201005225102026

3.创建虚拟机

image-20201005225215481

image-20201005225447144

image-20201005225500532

这里内存看着给,建议1G以上

image-20201005225619147

image-20201005225707100

image-20201005225723017

image-20201005225814438

此时还需要配置双网卡,否则宿主机无法访问虚拟机

首先进入主机网络管理

image-20201006112044066

创建一个网卡,默认192.168.56.1

image-20201006112132672

关闭

image-20201006101946351

image-20201006102002104

image-20201006102058053

image-20201005225903268

4.配置虚拟机

image-20201005230606548

image-20201005230720948

image-20201005230933973

image-20201005231034408

image-20201005231240794

image-20201005231323604

image-20201005231350509

image-20201006102358762

image-20201006102506437

image-20201006102629365

Save保存

image-20201006102718604

Done

begin installation

image-20201005232116647

安装好后Reboot

image-20201006000054303

image-20201006000231136

5.配置网络

image-20201006110028149

此时enp0s8网卡未开启,虚拟机可以ping通外网和宿主机,但是宿主机无法ping通虚拟机。

配置网卡

vi /etc/sysconfig/network-scripts/ifcfg-enp0s8

修改ONBOOTyes,保存退出

image-20201006111419084

systemctl restart network重启网卡 并查看ip

image-20201006111614889

enp0s8网卡已经开启,并且有了刚刚配置的ip 192.168.156.100

此时用宿主机ping虚拟机测试

image-20201006111829753

ssh连接测试

image-20201006111901551

连接成功!

此时虚拟机可以访问外网,可以访问宿主机,虚拟机间可以互相访问,宿主机也可以访问虚拟机

6.拓展

1
2
3
4
5
6
7
8
9
10
11
12
13
14
VBoxManage modifymedium     [disk|dvd|floppy] <uuid|filename>
[--type normal|writethrough|immutable|shareable|
readonly|multiattach]
[--autoreset on|off]
[--property <name=[value]>]
[--compact]
[--resize <megabytes>|--resizebyte <bytes>]
[--move <path>]
[--setlocation <path>]
[--description <description string>]


# # 修改磁盘大小(图形化没有修改操作)
VBoxManage modifymedium /media/aurora/05579a1d-c30b-4e3a-9d18-9bc9dfe08859/VirtualBox VMs/centos-test/centos-test.vdi --resize 30720 # 修改磁盘大小为30G

评论