Files
Obsidian-Main/05. 資料收集/Linux/lxc.md

58 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 準備
## 安裝 incus
根據 https://linuxcontainers.org/incus/docs/main/installing/#installing 的說明Ubuntu 22.04 還沒辦法使用 apt 來安裝,因此依照 https://github.com/zabbly/incus 的說明來安裝:
```shell
curl -fsSL https://pkgs.zabbly.com/key.asc | gpg --show-keys --fingerprint
mkdir -p /etc/apt/keyrings/
sudo curl -fsSL https://pkgs.zabbly.com/key.asc -o /etc/apt/keyrings/zabbly.asc
sudo sh -c 'cat <<EOF > /etc/apt/sources.list.d/zabbly-incus-stable.sources
Enabled: yes
Types: deb
URIs: https://pkgs.zabbly.com/incus/stable
Suites: $(. /etc/os-release && echo ${VERSION_CODENAME})
Components: main
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/zabbly.asc
EOF'
sudo apt update
sudo apt install incus
```
## 設定 incus
使用 `sudo incus admin init` 來設定,會問一堆問題,如下:
```
Would you like to use clustering? (yes/no) [default=no]:
Do you want to configure a new storage pool? (yes/no) [default=yes]: no
Would you like to create a new local network bridge? (yes/no) [default=yes]: no
Would you like to use an existing bridge or host interface? (yes/no) [default=no]: yes
Name of the existing bridge or host interface: enp3s0
Would you like the server to be available over the network? (yes/no) [default=no]: yes
Address to bind to (not including port) [default=all]:
Port to bind to [default=8443]:
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]:
Would you like a YAML "init" preseed to be printed? (yes/no) [default=no]:
```
大部分都預設就可以。
## 建立 pool
```shell
sudo incus storage create vmpool dir source=/lvm1/lxd_storage
```
## 建立 profile
```shell
sudo incus profile copy default windows
sudo incus profile set windows --property description="Windows: 16CPU, 16GB RAM, 1024GB DISK"
sudo incus profile set windows limits.cpu=16
sudo incus profile set windows limits.memory=16GiB
sudo incus profile set windows raw.qemu="-device intel-hda -device hda-duplex -audio spice"
sudo incus profile device add windows vtpm tpm path=/dev/tpm0
sudo incus profile device set windows root pool=vmpool
sudo incus profile device set windows root size=1024GiB
sudo incus profile device set windows eth0 nictype=macvlan
sudo incus profile device set windows eth0 parent=br0
sudo incus profile show windows
```