[TOC] #### 1. 前言 --- VirtualBox 官網(wǎng):<https://www.virtualbox.org> 以 Centos 7 為例,可以從 [阿里云鏡像](https://mirrors.aliyun.com/centos/7.9.2009/isos/x86_64/) 或 [我的百度云網(wǎng)盤](https://pan.baidu.com/s/1Pl8xU31GiKuW6m32ZaI5BA?pwd=schw) 下載 Centos 操作系統(tǒng)的鏡像文件 本文使用的鏡像文件是 `CentOS-7-x86_64-Minimal-2009.iso`,也就是最小化安裝的鏡像文件 #### 2. 創(chuàng)建虛擬機 --- **啟動 VirtualBox 軟件,點擊界面中的【新建】**  **輸入虛擬機名稱、設(shè)置虛擬機存放文件夾、選擇鏡像文件**  **使用自動安裝,有默認的用戶名和密碼,以及主機名和域名,使用默認的就行**  **使用默認設(shè)置就行,直接點擊【下一步】**  **使用默認設(shè)置就行,直接點擊【下一步】**  **點擊【完成】,虛擬機創(chuàng)建成功**  #### 3. 運行虛擬機 --- ##### 設(shè)置網(wǎng)絡(luò) **點擊【設(shè)置】,默認的網(wǎng)絡(luò)連接方式為【網(wǎng)絡(luò)地址轉(zhuǎn)換】,改為【橋接網(wǎng)卡】**  ##### 啟動虛擬機 **點擊【啟動】運行虛擬機,按照下圖序號依次點擊**  **接下來將開始安裝 Centos,然后進行初始化設(shè)置**  **選擇語言,點擊【繼續(xù)】**  ##### 安裝位置 **點擊【安裝位置】,然后點擊其界面左上角中的【完成】(默認是自動分區(qū)),接下來點擊【開始安裝】**  ##### 設(shè)置網(wǎng)絡(luò) **點擊【網(wǎng)絡(luò)和主機名】**  **右上角默認是【關(guān)閉】,點擊修改為【打開】,然后點擊左上角的【完成】,即可回到安裝界面**  ##### 關(guān)閉 Kdump Kdump 是一個內(nèi)核崩潰轉(zhuǎn)儲機制,默認是啟用的,我們可以將它關(guān)閉掉  ##### 開始安裝 **安裝信息設(shè)置好后,點擊【開始安裝】**  **然后就會開始安裝操作系統(tǒng)了,在自動安裝的過程中我們可以先設(shè)置 root 用戶的密碼**  **安裝完成后,點擊【重啟即可】**  #### 4. 網(wǎng)絡(luò)鏈接問題 --- 首先,我們要確保安裝的虛擬機操作系統(tǒng)可以正常訪問網(wǎng)絡(luò) ```bash # 測試網(wǎng)絡(luò) ping -c 3 baidu.com # 查看 IP 地址 ip addr ``` 如果沒有網(wǎng)絡(luò),輸出結(jié)果可能是下圖這樣的,繼續(xù)往下看,查看解決方法 ``` mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 ```  運行以下命令重啟 enp0s3 網(wǎng)卡,就可以正常訪問網(wǎng)絡(luò)并且能看到局域網(wǎng) IP 地址了 ```bash ifup enp0s3 ```  現(xiàn)在雖然解決了沒有網(wǎng)絡(luò)的問題,但是重啟系統(tǒng)后可以發(fā)現(xiàn)又沒有網(wǎng)絡(luò)了 其實開機沒有網(wǎng)絡(luò)的本質(zhì)原因是因為安裝操作系統(tǒng)時,沒有設(shè)置打開【以太網(wǎng)連接】,如下圖  如果忘記設(shè)置打開【以太網(wǎng)連接】,我們只需要手動設(shè)置 enp0s3 網(wǎng)卡開機自啟 修改網(wǎng)絡(luò)配置文件 `/etc/sysconfig/network-scripts/ifcfg-enp0s3`,將文件內(nèi)容中的 `ONBOOT=no` 改為 `ONBOOT=yes` #### 5. 安裝常用工具 --- 因為我們是安裝最小化的 CentOS 7,也就是只安裝最基本的軟件包和組件,不安裝其他非必要的軟件包和組件 但是,當我們使用虛擬機系統(tǒng)時,有些工具是經(jīng)常使用的,可以運行以下命令安裝它們 ```bash yum install wget vim lrzsz -y ``` | 軟件包 | 說明 | | ------------ | ------------ | | vim | 終端編輯器 | | wget | 多用于下載源碼包 | | lrzsz | 本地電腦和虛擬機系統(tǒng)之間進行文件傳輸 | 其他工具:[Linux 目錄跳轉(zhuǎn)的好工具 z.sh](http://beautifulforever.com.cn/index/639.html)