2022-04-25 22:28:41 +08:00
|
|
|
|
# VirtualBox 搭建Ubuntu20.04
|
|
|
|
|
## 演示环境
|
|
|
|
|
+ VirtualBox 6.1.32
|
|
|
|
|
+ ubuntu-20.04.4-live-server-amd64.iso
|
|
|
|
|
## 依赖下载
|
|
|
|
|
[VirtualBox 官网地址](https://www.virtualbox.org/wiki/Downloads)
|
|
|
|
|
[Ubuntu20.04 阿里云镜像站](http://mirrors.aliyun.com/ubuntu-releases/20.04/)
|
|
|
|
|
|
|
|
|
|
> VirtualBox 安装较为简单不做演示
|
|
|
|
|
|
|
|
|
|
## 开始搭建
|
|
|
|
|
### 新建虚拟电脑
|
|
|
|
|
选择工具点击新建
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
设置内存大小
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
默认
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
默认
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
这里我为了演示节省时间选择的是动态大小 硬盘空间充足的话建议选择固定大小
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
设置硬盘大小
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
### 设置虚拟网卡
|
|
|
|
|
ctrl+h 打开网络管理器 选中已有的网卡或新建网卡进行配置 点击属性配置网卡的信息 我这里改的是10.0.0 的网段
|
|
|
|
|
不懂网络的同学可以按照我的去做
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
### 修改虚拟机配置
|
|
|
|
|
选中我们创建的虚拟机点击设置 打开虚拟机的配置页面
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
设置内存大小 建议不超过宿主机内存的百分之五十
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
设置处理器数量 建议不超过宿主机的百分之五十
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
显存可以设置小一点
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
根据步骤添加我们下载的镜像为虚拟光盘
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
设置好的样子
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
配置网络
|
|
|
|
|
网卡一连接方式选择Host-Only 可以在这个网络下和宿主机以及其他虚拟机组成一个局域网
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
网卡二 连接方式选中桥接网卡 界面名称选择你电脑上可以链接到公网的网卡 网卡二可以让我们的虚拟机上公网
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
### 开始安装
|
|
|
|
|
双击启动 默认选择英文不需要改动 直接回车进入下一步
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
配置键盘布局 选择“Done” 回车
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
网络配置 不需要动,以防修改错误后续操作无法进行 继续Done
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
不需要填 选中Done回车
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
这里可以改为阿里云软件源的镜像地址 https://mirrors.aliyun.com/ubuntu/
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
后面的的配置默认不需要修改 选择Done 和 continue 知道自定义用户账号信息
|
|
|
|
|
|
|
|
|
|
自定义用户账号信息,输入完成之后,选择“Done”,按Enter键
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
中间页面默认不需要修改
|
|
|
|
|
|
|
|
|
|
安装ssh远程连接 建议在进入系统后手动安装
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
默认选中Done 下一步至此页面 等待漫长的安装过程
|
|
|
|
|
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
安装完成后会出现Reboot Now选项 选择此选项回车进行重启
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
等待重启过程中,如果卡住,多按几次Enter键即可
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
在登陆页面 如果卡住 同时按alt+f2 切换一个控制台进行登录 不出现的话多按几次
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
输入账号密码进入系统
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
执行以下命令解决Used fallback datasource问题 [修复此问题原文地址](https://askubuntu.com/questions/1321968/ubuntu-server-20-04-2-lts-hangs-after-bootup-cloud-init-1781-yyyy-mm-dd-h)
|
|
|
|
|
```shell
|
|
|
|
|
sudo touch /etc/cloud/cloud-init.disabled
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 配置固定ip并测试网络
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
#安装net-tools
|
|
|
|
|
sudo apt install net-tools
|
|
|
|
|
|
|
|
|
|
#查看当前的网络
|
|
|
|
|
ifconfig
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
设置固定ip地址
|
|
|
|
|
编辑/etc/netplan/ 下的yaml文件
|
|
|
|
|
`sudo vim /etc/netplan/***.yaml`
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
#使刚才设置网卡的配置生效
|
|
|
|
|
sudo netplan apply
|
|
|
|
|
#使用ifconfig查看ip是否设置成功
|
|
|
|
|
ifconfig
|
|
|
|
|
#使用ping命令查看是否可以访问公网
|
|
|
|
|
ping www.baidu.com
|
|
|
|
|
```
|
|
|
|
|
|
2022-12-30 00:38:44 +08:00
|
|
|
|

|
2022-04-25 22:28:41 +08:00
|
|
|
|
|
|
|
|
|
到此位置你的Ubuntu已经搭建完毕.
|