Try   HackMD

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

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

下載後點擊它就會自動安裝了

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

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  3. 設定此虛擬機的名稱,以及放在哪個資料夾

    此時先不要點選 ISO Image

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  4. 設定 Base memory 和 Processors

    Base memory 基本給個 4096 MB,Processors 就看自己電腦有多少 CPU 就選多少

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  5. 設定 virtual hard disk

    至少給個 50 GB

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  6. Finish

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  7. 點選剛剛設定的虛擬機 Ubuntu 18.04,然後點選 Settings

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  8. 點左側的 Storage,然後點 Empty,然後再點 Optical Driver 旁邊那個光碟的圖案

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  9. Choose/Create a Virtual Optical Disk

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  10. Add

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  11. 選擇剛剛下載的 Ubuntu 18.04 的 .iso

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  12. Choose

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  13. OK

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  14. Start 啟動 Ubuntu 18.04 虛擬機

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  15. 點選語言,然後 Install Ubuntu

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  16. 點選鍵盤的 layout,然後 Continue

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  17. Normal InstallationDownload updates while installing Ubuntu,然後 Continue

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  18. 因為等下想將 root directory / 和 home directory ~/ 放在不同的 partition,所以這裡點 Something else,然後 Continue

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  19. /dev/sda,然後點 New Partition Table...

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  20. free space,然後點那個 + 的按鈕

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  21. 給 root directory / 20480 MB

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  22. 再點選 free space,然後再按那個 + 的按鈕

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  23. 剩下的 33207 MB 都給 home directory /home

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  24. Install Now

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  25. Continue

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  26. Continue

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  27. 設定 username 和密碼,然後 Continue

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  28. 開始安裝~

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  29. 安裝完,Restart Now

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  30. 可以開始用啦~

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

Enabling Shared Clipboard

這裡要做的設定是讓 host 跟 VirtualBox 虛擬機共用剪貼簿,這樣在 host 複製的文字,就可以在虛擬機裡面貼上,虛擬機裡面複製的文字,也可以在 host 貼上~

  1. 點選虛擬機的 Settings,然後點 General,再點 Advanced,然後 Shared ClipboardDrag'n'Drop 欄位都選 Bidirectional

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  2. Storage,再點 Controller: SATA,然後勾選 Use Host I/O Cache

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  3. Ubuntu 18.04.vdi,然後勾選 Solid-state Drive,然後 OK

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  4. 開啟 Ubuntu 18.04 虛擬機

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  5. 開啟 terminal,執行以下指令:

    ​​​​sudo apt update && sudo apt -y install build-essential dkms
    
  6. 點選 VirtualBox 視窗上方的 Devices 欄位,再點選 Insert Guest Additions CD image...

    image

  7. Run

    image

  8. 安裝成功會出現以下畫面

    image

  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(如下圖箭頭所指的按鈕)

    image

  3. 指定在 host 上要用來當作 shared folder 的資料夾的路徑,並記得勾選 Auto-mount(ex. 我想設定 host 的 /home/cpt1020/vbox_shared 這個資料夾當作共享資料夾,選完 Folder Path 之後 Folder Name 就會自動顯示該資料夾的名稱,以我這個例子來說就會是vbox_shared

    image

    image

  4. 開啟 Ubuntu 18.04 virtual machine

  5. 在 virtual machine 中建立一個新的資料夾,等下要讓 host 端共享的資料夾掛載到這個資料夾(ex. 我設定虛擬機的 /home/cpt1020/shared_folder 這個資料夾來當作共享資料夾)

  6. 開啟 terminal 並輸入以下指令即可共用資料夾:

    ​​​​$ sudo mount -t vboxsf <folder_name> /path/to/vm/shared/folder
    

    以我的例子就是:

    ​​​​$ sudo mount -t vboxsf vbox_shared /home/cpt1020/shared_folder
    

    每次開啟 virtual machine 都需要輸入前述指令將 shared folder 掛載