SITCON
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- GA: UA-34467841-15 --- PVE 虛擬化 —— 給我一個邁出 Windows 的理由! - 牟展佑/William Mou === <blockquote> 自古以來,學生,可謂是夢想最多,動作最少的一群人。 想學 Linux 當個黑客?你說系統不能打熱門 3A 大作?當我沒說! 想算 ML/DL 跟潮流?你說顯卡佔用會導致遊戲根本沒法開?算了吧! 想組 NAS 學習協議與存儲?你說先把系統刷掉不然買一台整機?沒錢! 學海無涯,先玩在說! 那些年,是多少障礙阻止我成為我所嚮往的極客?沒錢、沒硬體、沒授權! 同學感同身受嗎?這裏有一批上好的乾貨 ,看看不?試用免費呀!(當然之後也免費囉!) 本議程將分享以 Promox VE 搭配眾多開源軟體,低成本自架一個滿足上敘條件的: 「學生學習、娛樂至上、必備良品!」 ## 先備知識 我希望把它設計成一個——懂越多、聽越多的議程。 但為了能理解脈絡,需要「能理解摘要(大綱)的名詞在做什麼,以及這些技術解決什麼問題」 EX:Linux 可能的用途、ML需要的環境(顯卡、顯存佔用等)、NAS 用來解決哪些痛點?等。 </blockquote> ###### tags: `SITCON 2020 共筆` `SITCON 2020` `2020` `共筆` `R1` > 請從這裡開始 [Slide](https://drive.google.com/file/d/1n9AXiiwXrkWIVycdpxxEwDyewOWZNTeH/view?usp=drivesdk) ## Some Link 1. Deep Learning 2. GPU Gaming 3. NAS Service ## Installation Tip: - Alt + N 下一頁 - Option 裡選ZFS - 不支援 Hardware RAID Card 有時會抓不到 DHCP IP(手動填) ## Virtual Machine ### 系統虛擬機器 - 當你想在一個OS上虛擬化另一個OS時 - Host OS 認為自己負責管理所有硬體 - 為了避免OS打架,必須妥善切分他們的: - CPU (Register) - Memory (MMU) - IO Device - Interrupt - timer ### Kernel Mode(mode bit = 1) vs User Mode(mode bit = 0) ### 全虛擬化、硬體模擬、半虛擬化 ### 虛擬機發展-1 - 虛擬化的發展 - 純軟體模擬 - 可以模擬甚至不存在的硬體 - 低效率:一班用於研究環境 ### Classic virtulization ### 虛擬化發展-2 - 軟體全虛擬化方案 - VMM 擷取特權指令處理 - Hypervisor 大量負載 - 由 VMware 公司提出 > 每個指令都要捕捉會拖累效能 > -> 虛擬機執行指令時,先偷看 <!-- 好快...... --> ### 虛擬化發展-3 - 硬體輔助全虛擬化(把虛擬化做到硬體裡面)(MMU) > 把 Memory 位址轉換內建在 CPU - 透過硬體廠商 Intel AMD 加速 - Guest OS 支持任何系統 - 效率高:當前技術主流(KVM 也使用這種虛擬化) --- - VT-x - 在CPU設置兩種模式 >讓 CPU 知道他是不是正在執行 VM 指令 - 新增 13 種指令 實現進出 VM - 新增 VMCS 管理記憶體分頁表 ### 虛擬化發展-2.5 > 不需要硬體支援,接近原生效能 - 半虛擬化方案 - 虛擬機知道自己是虛擬機 - 虛擬機自己對特權指令更改 - 效率中高:需更改 Guest Kernel (不支援 Windows 等不開源系統) | | 全虛擬化 | 硬體輔助 | 硬體輔助虛擬 | | -------- | -------- | -------- | -------- | | 實現技術 | Binary Translation和直接執行 | 遇到特權指令轉到root 執行 | Hypercall | | Guest 兼容性 | 無修改 Guest 兼容性高 | 無修改 Guest 兼容性高 | 需修改 Guest 僅適用開源 OS | | 性能 | 差 | 僅切換模式的開銷 | 接近於物理機 | | 應用廠商 | VMware,QEMU | Microsoft Hyper-V,KVM | XEN | ## 03 PVE Architecture ### KVM - Kernel Based Virtual Machine - a Kernel module - 一開始獨立發行 - 後來和 kernel 一起發行 ### QEMU Quick Emulator - 全軟體虛擬化 ### KVM-QEMU 架構 Userspace - Linux host qemu Kernel spacce - host kernel - KVM modules Hardware - VT-x (intel) ### QEMU I/O request 1. Guest 被 KVM module 中 I/O trap 捕捉並處理 2. 處理結果放到 I/O sharing page 中 3. 通知QEMU process來取得I/O資訊,並交由QEMU I/O Emulation code來模擬I/O request 4. 完成後將結果放回 I/O sharing page 通知 KVM module 中的 I/O trap <!-- 5. 向下送出 I/O Request 完成任務 --> 5. 將處理結果取回並回傳給 virtual machine --- Libvirt > 管理所有類型虛擬機的 API - virsh - virt-manager - OpenStack - oVirt - KVM - LXC - OpenVZ - UML - ESX - other --- PVE vs Libvirt > 不建議在 PVE 中用 Libvirt ,容易爆炸 >> 兩者可以管理 KVM,但願景不同: >> PVE 期待能簡化管理 KVM >> Libvirt 期待能管理所有 VM >> 導致 PVE 易但功能較少,反之。 ## 04 PVE device IO Device:能插在電腦內的 - 網卡 - 硬碟 - SSD ### Device 分配的三種方法 - Emulated QEMU軟體模擬 - VirtIO VM 內驅動裡應外合 - VT-d 支援硬體搭配 IOMMU 穿透 ### QEMU 虛擬 IO ### VirtIO 解決 qemu 中冗餘操作 用 virtIO driver 取代 guest driver 在guest要用到的時候立刻做轉換 >> 降維來說: >> QEMU: >> 有一個員工 Guest ,寫一份中文文件 >> 跑到老闆 Host 辦公室,送給他核准 >> 但老闆看不懂中文,希望看英文...... >> 每個員工另外找翻譯官,翻譯完再給老闆 >> >> --- >> VirtIO: >> 所有員工把文件送到老闆的翻譯官手上 - 好處: - driver寫一個就好(? - 換HyperVisor(老闆)也沒事 ### VFIO > 還是不夠快 > 直接把翻譯官幹掉,老闆學什麼語言,員工就要學會什麼語言 > 越過(隱藏) Linux kernel ,讓 Guest OS 直接管理 Device - 要其他技術輔助:DMA, IOMMU... ### DMA (Direct Memory Access) ```graphviz digraph G{ } ``` ### IOMMU > 每一張網卡可以分別分給不同 Guest OS > 將虛擬記憶體位置轉成實體 > 1. CPU writes to Memory 2. CPU programs the IOMMU <!-- 3. Devices need to ... --> 3. Device reads from memory ## DMA-remapping - 將不同 Device 傳給不同虛擬機 ## 05 VM 實例 - BIOS設定 - BIOS 虛擬化 - intel 虛擬化 - VT-D 開啟:IO 虛擬化 - ASPM 開啟:Active State Power Management - 直通相關設定 - 開啟 iommu - 修改 grub 設定 $ vi /etc/default/grub # RUB_CMDLINE_LINUX_DEFAULT="quiet" GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on video=efifb:off" --- ### [PCIe Pass Pass 經驗](https://hackmd.io/@William-Mou/H1VljdQaI#/) ### [PVE Outline](https://hackmd.io/wkC_VD8STO2F2XWDk5E1wg?view) - ASPM ### 直通相關設定 1. 開起 iommu - 修改 grub 設定 2. 修改VFIO設定 3. 禁止啟動驅動 - 為了由VFIO直通至GuestOS #### SeaBIOS 不想聽就照著簡報這樣點 #### OVMF (UEFI) - 優先使用 Windows VM 安裝時要同時掛載 VirtIO 驅動光碟 iso 顯卡 Pass through > 需要先知道 PCI function group function - .0 視訊 - .1 音訊 ## 06 PVE 更多玩法 > 想要玩神奇的東西 AMD 有很多神奇的 功能/Bug ### SR-IOV 只有一張網卡可以給每個虛擬機用 #### Proxmox community 方案 #### ceph 儲存系統 #### Proxmox Backup Server 如果儲存很穩還不夠可以讓虛擬機很穩並備份下來 ## Q&A 請問伺服器分配vm V.S. container? 不想踩雷就用 VM 用 LXC 碰到 kernel module 容易遇到問題 <style> @keyframes move { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(360deg); } } @keyframes flipX { 0% { transform: scaleX(1); } 25% { transform: scaleX(0); } 50% { transform: scaleX(-1); } 75% { transform: scaleX(0); } 100% { transform: scaleX(1); } } @keyframes flipY { 0% { transform: scaleY(1); } 25% { transform: scaleY(0); } 50% { transform: scaleY(-1); } 75% { transform: scaleY(0); } 100% { transform: scaleY(1); } } @keyframes pudon { 0%, 100% { transform: scale(1); } 50% { transform: scale(0.5); } 60% { transform: scale(1); } 75% { transform: scale(1.5); } 80% { transform: scale(1.75); } } @keyframes buuu { 0%, 100% { transform: scale(1); } 50% { transform: scale(0.5); } 55% { transform: scale(1.5); } 60% { transform: scale(0.75); } 80% { transform: scale(1.25); } } @keyframes fade{ 100%,0%{ color: rgb(0,0,0); } 50% { color: rgb(255,255,255); } } @keyframes pretty-rainbox { 0%, 100% { filter: hue-rotate(0deg); } 50% { filter: hue-rotate(180deg); } } @keyframes doooom { 0%, 100% { top: 0px; } 15% { top: 0px; } 20% { top: 10px; } 25% { top: 5px; } 50% { top: 10px; } 55% { top: 7px; } 85% { top: 10px; } } .ui-avatar { animation: move 5s infinite; } .ui-menu { animation: doooom 1s linear infinite; } .ui-help { animation: flipX 3s infinite; } .ui-sharing { animation: pudon .5s linear infinite; } .ui-status { animation: pretty-rainbox 3s infinite; } .btn-group .btn { animation: buuu 3s linear infinite; } .announcement-area { animation: flipY 3s infinite; } .navbar-brand > span.hidden-xs { color: transparent; } .navbar-brand > .fa-file-text { display: none; } .navbar-brand > span.hidden-xs:before { background-image: url(https://sitcon.org/2020/img/logo-dark.54871ec0.svg); background-repeat: no-repeat; content: '  '; background-size: contain; } .navbar-brand > span.hidden-xs:after { content: "PVE 虛擬化 — 給我一個邁出 Windows 的理由!"; color: #4b4645; margin-left: -4em; animation: fade 20s linear; animation-iteration-count: infinite; } </style>

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully