紀錄在 VirtualBox 安裝 Ubuntu 18.04 的過程,以及設定共享資料夾及開啟複製貼上功能
至 VirtualBox 官網下載安裝檔~
https://www.virtualbox.org/wiki/Downloads
我的桌機是 Ubuntu 24.04,就到 VirtualBox 官網下載相對應的 VirtualBox 安裝檔:
https://www.virtualbox.org/wiki/Linux_Downloads
下載後點擊它就會自動安裝了
下載 Ubuntu 18.04 image:
至以下頁面下載 Ubuntu 18.04 的 iso 檔:
https://ubuntu.com/download/alternative-downloads#past-releases-and-other-flavours
開啟 VirtualBox,點選 New
設定此虛擬機的名稱,以及放在哪個資料夾
此時先不要點選 ISO Image
!
設定 Base memory 和 Processors
Base memory 基本給個 4096 MB,Processors 就看自己電腦有多少 CPU 就選多少
設定 virtual hard disk
至少給個 50 GB
點 Finish
點選剛剛設定的虛擬機 Ubuntu 18.04
,然後點選 Settings
點左側的 Storage
,然後點 Empty
,然後再點 Optical Driver
旁邊那個光碟的圖案
點 Choose/Create a Virtual Optical Disk
點 Add
選擇剛剛下載的 Ubuntu 18.04 的 .iso
檔
點 Choose
OK
點 Start
啟動 Ubuntu 18.04 虛擬機
點選語言,然後 Install Ubuntu
點選鍵盤的 layout,然後 Continue
Normal Installation
和 Download updates while installing Ubuntu
,然後 Continue
因為等下想將 root directory /
和 home directory ~/
放在不同的 partition,所以這裡點 Something else
,然後 Continue
點 /dev/sda
,然後點 New Partition Table...
點 free space
,然後點那個 +
的按鈕
給 root directory /
20480 MB
再點選 free space
,然後再按那個 +
的按鈕
剩下的 33207 MB 都給 home directory /home
Install Now
Continue
Continue
設定 username 和密碼,然後 Continue
開始安裝~
安裝完,Restart Now
可以開始用啦~
這裡要做的設定是讓 host 跟 VirtualBox 虛擬機共用剪貼簿,這樣在 host 複製的文字,就可以在虛擬機裡面貼上,虛擬機裡面複製的文字,也可以在 host 貼上~
點選虛擬機的 Settings
,然後點 General
,再點 Advanced
,然後 Shared Clipboard
和 Drag'n'Drop
欄位都選 Bidirectional
點 Storage
,再點 Controller: SATA
,然後勾選 Use Host I/O Cache
點 Ubuntu 18.04.vdi
,然後勾選 Solid-state Drive
,然後 OK
開啟 Ubuntu 18.04 虛擬機
開啟 terminal,執行以下指令:
點選 VirtualBox 視窗上方的 Devices
欄位,再點選 Insert Guest Additions CD image...
點 Run
安裝成功會出現以下畫面
重開機後即可複製貼上啦~
設定讓 host 跟虛擬機有共享的資料夾,這樣 host 跟虛擬機只要把東西放在共享資料夾,就能透過共享資料夾傳遞東西至 host 或虛擬機~
點選 Ubuntu 18.04 virtual machine -> Settings
-> Shared Folders
點選右側的 Adds new shared folder
(如下圖箭頭所指的按鈕)
指定在 host 上要用來當作 shared folder 的資料夾的路徑,並記得勾選 Auto-mount
(ex. 我想設定 host 的 /home/cpt1020/vbox_shared
這個資料夾當作共享資料夾,選完 Folder Path
之後 Folder Name
就會自動顯示該資料夾的名稱,以我這個例子來說就會是vbox_shared
)
開啟 Ubuntu 18.04 virtual machine
在 virtual machine 中建立一個新的資料夾,等下要讓 host 端共享的資料夾掛載到這個資料夾(ex. 我設定虛擬機的 /home/cpt1020/shared_folder
這個資料夾來當作共享資料夾)
開啟 terminal 並輸入以下指令即可共用資料夾:
以我的例子就是:
每次開啟 virtual machine 都需要輸入前述指令將 shared folder 掛載