# Installing Ubuntu 18.04 on VirtualBox > 紀錄在 VirtualBox 安裝 Ubuntu 18.04 的過程,以及設定共享資料夾及開啟複製貼上功能 ## Installing VirtualBox 至 VirtualBox 官網下載安裝檔~ https://www.virtualbox.org/wiki/Downloads 我的桌機是 Ubuntu 24.04,就到 VirtualBox 官網下載相對應的 VirtualBox 安裝檔: https://www.virtualbox.org/wiki/Linux_Downloads  下載後點擊它就會自動安裝了 ## Installing Ubuntu 18.04 1. 下載 Ubuntu 18.04 image: 至以下頁面下載 Ubuntu 18.04 的 iso 檔: https://ubuntu.com/download/alternative-downloads#past-releases-and-other-flavours 2. 開啟 VirtualBox,點選 `New`  3. 設定此虛擬機的名稱,以及放在哪個資料夾 :::danger 此時先不要點選 `ISO Image`! :::  4. 設定 Base memory 和 Processors Base memory 基本給個 4096 MB,Processors 就看自己電腦有多少 CPU 就選多少  5. 設定 virtual hard disk 至少給個 50 GB  6. 點 `Finish`  7. 點選剛剛設定的虛擬機 `Ubuntu 18.04`,然後點選 `Settings`  8. 點左側的 `Storage`,然後點 `Empty`,然後再點 `Optical Driver` 旁邊那個光碟的圖案  9. 點 `Choose/Create a Virtual Optical Disk`  10. 點 `Add`  11. 選擇剛剛下載的 Ubuntu 18.04 的 `.iso` 檔  12. 點 `Choose`  13. `OK`  14. 點 `Start` 啟動 Ubuntu 18.04 虛擬機  15. 點選語言,然後 `Install Ubuntu`  16. 點選鍵盤的 layout,然後 `Continue`  17. `Normal Installation` 和 `Download updates while installing Ubuntu`,然後 `Continue`  18. 因為等下想將 root directory `/` 和 home directory `~/` 放在不同的 partition,所以這裡點 `Something else`,然後 `Continue`  19. 點 `/dev/sda`,然後點 `New Partition Table...`  20. 點 `free space`,然後點那個 `+` 的按鈕  21. 給 root directory `/` 20480 MB  22. 再點選 `free space`,然後再按那個 `+` 的按鈕  23. 剩下的 33207 MB 都給 home directory `/home`  24. `Install Now`  25. `Continue`  26. `Continue`  27. 設定 username 和密碼,然後 `Continue`  28. 開始安裝~  28. 安裝完,`Restart Now`  29. 可以開始用啦~  ## Enabling Shared Clipboard 這裡要做的設定是讓 host 跟 VirtualBox 虛擬機共用剪貼簿,這樣在 host 複製的文字,就可以在虛擬機裡面貼上,虛擬機裡面複製的文字,也可以在 host 貼上~ 1. 點選虛擬機的 `Settings`,然後點 `General`,再點 `Advanced`,然後 `Shared Clipboard` 和 `Drag'n'Drop` 欄位都選 `Bidirectional`  2. 點 `Storage`,再點 `Controller: SATA`,然後勾選 `Use Host I/O Cache`  3. 點 `Ubuntu 18.04.vdi`,然後勾選 `Solid-state Drive`,然後 `OK`  4. 開啟 Ubuntu 18.04 虛擬機  5. 開啟 terminal,執行以下指令: ```shell sudo apt update && sudo apt -y install build-essential dkms ``` 6. 點選 VirtualBox 視窗上方的 `Devices` 欄位,再點選 `Insert Guest Additions CD image...`  7. 點 `Run`  8. 安裝成功會出現以下畫面  9. 重開機後即可複製貼上啦~ ## Setting Shared Folder between Host and Virtual Machine 設定讓 host 跟虛擬機有共享的資料夾,這樣 host 跟虛擬機只要把東西放在共享資料夾,就能透過共享資料夾傳遞東西至 host 或虛擬機~ 1. 點選 Ubuntu 18.04 virtual machine -> `Settings` -> `Shared Folders` 2. 點選右側的 `Adds new shared folder`(如下圖箭頭所指的按鈕)  3. 指定在 host 上要用來當作 shared folder 的資料夾的路徑,並記得勾選 `Auto-mount`(ex. 我想設定 host 的 `/home/cpt1020/vbox_shared` 這個資料夾當作共享資料夾,選完 `Folder Path` 之後 `Folder Name` 就會自動顯示該資料夾的名稱,以我這個例子來說就會是`vbox_shared`)   4. 開啟 Ubuntu 18.04 virtual machine 5. 在 virtual machine 中建立一個新的資料夾,等下要讓 host 端共享的資料夾掛載到這個資料夾(ex. 我設定虛擬機的 `/home/cpt1020/shared_folder` 這個資料夾來當作共享資料夾) 6. 開啟 terminal 並輸入以下指令即可共用資料夾: ```shell $ sudo mount -t vboxsf <folder_name> /path/to/vm/shared/folder ``` 以我的例子就是: ```shell $ sudo mount -t vboxsf vbox_shared /home/cpt1020/shared_folder ``` :::info 每次開啟 virtual machine 都需要輸入前述指令將 shared folder 掛載 :::
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.