はじめに
PCを初期セットアップするたびに、いつも思うことがあります。
普段からWindowsやMac、Linuxなど複数のOSを使い分けていると、どの仮想化アプリを入れるべきか非常に悩みます。
そんな中出会ったのが「Incus」でした。 Linuxコンテナと仮想マシンの両方に対応しており、さらにマルチプラットフォームで利用できるため、非常に重宝しています。
1. incusインストール
-
下記のサイトを参考に各プラットフォーム対応する
incusをインストールする -
ログインユーザーで Incus を操作できるように管理グループに追加する
sudo adduser $USER incus-admin newgrp incus-admin -
Incus環境をするための初期設定ファイルを作成する
設定内容の概要カテゴリ 名前 主な設定 詳細 Global - config {}(グローバル設定なし)Network incusbr0 bridge / NAT IPv4: 192.168.10.1/24
NAT: true
IPv6: noneStorage Pool default dir source: /var/lib/incus/storage-pools/default Profile default 最小構成 制限なし / デバイス未定義 Profile lxc コンテナ用 CPU: 2 / Mem: 2GiB
nesting: true
NIC: incusbr0
Disk: defaultProfile vm VM用 CPU: 2 / Mem: 4GiB
NIC: incusbr0
Disk: 40GiBProject default 全機能有効 images / networks / zones / profiles / buckets / volumes 実行するコマンド内容
cat <<EOF > incus-init.yaml config: {} networks: - config: ipv4.address: 192.168.10.1/24 ipv4.nat: "true" ipv6.address: none description: "" name: incusbr0 type: bridge project: default storage_pools: - config: source: /var/lib/incus/storage-pools/default description: "" name: default driver: dir profiles: - config: {} description: Default Incus profile devices: {} name: default - config: limits.cpu: "2" limits.memory: 2GiB security.nesting: "true" description: lxc profile with Docker support devices: eth0: name: eth0 network: incusbr0 type: nic root: path: / pool: default type: disk name: lxc - config: limits.cpu: "2" limits.memory: 4GiB description: Virtual Machine profile devices: eth0: name: eth0 network: incusbr0 type: nic root: path: / pool: default size: 40GiB type: disk name: vm projects: - config: features.images: "true" features.networks: "true" features.networks.zones: "true" features.profiles: "true" features.storage.buckets: "true" features.storage.volumes: "true" description: Default Incus project name: default EOF -
作成したファイルを元に設定をする
cat incus-init.yaml | incus admin init --preseed
2. incus設定確認
-
設定内容が反映されたか確認する
incus admin init --dumpコマンド実行結果例
config: {} networks: - config: ipv4.address: 192.168.10.1/24 ipv4.nat: "true" ipv6.address: none description: "" name: incusbr0 type: bridge project: default storage_pools: - config: source: /var/lib/incus/storage-pools/default description: "" name: default driver: dir profiles: - config: {} description: Default Incus profile devices: {} name: default - config: limits.cpu: "2" limits.memory: 2GiB security.nesting: "true" description: lxc profile with Docker support devices: eth0: name: eth0 network: incusbr0 type: nic root: path: / pool: default type: disk name: lxc - config: limits.cpu: "2" limits.memory: 4GiB description: Virtual Machine profile devices: eth0: name: eth0 network: incusbr0 type: nic root: path: / pool: default size: 40GiB type: disk name: vm projects: - config: features.images: "true" features.networks: "true" features.networks.zones: "true" features.profiles: "true" features.storage.buckets: "true" features.storage.volumes: "true" description: Default Incus project name: default -
下記のコマンドでincusのグローバル設定が入っていないことを確認する
incus config showコマンド実行結果例
config: {} -
作成した
incusbr0の仮想ネットワークブリッジが設定されていることを確認するincus network info incusbr0コマンド実行結果例
Name: incusbr0 MAC address: XX:XX:XX:XX:XX:XX MTU: 1500 State: up Type: broadcast IP addresses: inet 192.168.10.1/24 (global) Network usage: Bytes received: 0B Bytes sent: 0B Packets received: 0 Packets sent: 0 Bridge: ID: 0000.000000000000 STP: false Forward delay: 1500 Default VLAN ID: 1 VLAN filtering: true Upper devices: -
ストレージプールの保存場所を確認する
incus storage get default sourceコマンド実行結果例
/var/lib/incus/storage-pools/default -
作成したプロファイルを確認する
incus profile listコマンド実行結果例
+---------+---------------------------------+---------+ | NAME | DESCRIPTION | USED BY | +---------+---------------------------------+---------+ | default | Default Incus profile | 0 | +---------+---------------------------------+---------+ | lxc | lxc profile with Docker support | 0 | +---------+---------------------------------+---------+ | vm | Virtual Machine profile | 0 | +---------+---------------------------------+---------+ -
lxcプロファイルの設定内容を確認するincus profile show lxcコマンド実行結果例
config: limits.cpu: "2" limits.memory: 2GiB security.nesting: "true" description: lxc profile with Docker support devices: eth0: name: eth0 network: incusbr0 type: nic root: path: / pool: default type: disk name: lxc used_by: [] -
vmプロファイルの設定内容を確認するincus profile show vmコマンド実行結果例
config: limits.cpu: "2" limits.memory: 4GiB description: Virtual Machine profile devices: eth0: name: eth0 network: incusbr0 type: nic root: path: / pool: default size: 40GiB type: disk name: vm used_by: []
3. 作成したプロファイルを元にLinuxコンテナ、Virtual Machineをデプロイする
-
Ubuntu 24.04 LTSベースのLinuxコンテナをデプロイする場合、下記のコマンドを実行するincus launch images:ubuntu/24.04 lxc1 --profile lxc -
Ubuntu 24.04 LTSベースの仮想マシンをデプロイする場合、下記のコマンドを実行するincus launch images:ubuntu/24.04 vm1 --vm --profile vm
4. 作成したLinuxコンテナ、Virtual Machineにアクセスする
-
下記のサイトを参考に作成したインスタンスにアクセスする