0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PC仮想化アプリをincusしたらに快適になった

0
Last updated at Posted at 2026-01-01

はじめに

PCを初期セットアップするたびに、いつも思うことがあります。
普段からWindowsやMac、Linuxなど複数のOSを使い分けていると、どの仮想化アプリを入れるべきか非常に悩みます。
そんな中出会ったのが「Incus」でした。 Linuxコンテナと仮想マシンの両方に対応しており、さらにマルチプラットフォームで利用できるため、非常に重宝しています。

1. incusインストール

  1. 下記のサイトを参考に各プラットフォーム対応するincusをインストールする

    Incusをインストールするには

  2. ログインユーザーで Incus を操作できるように管理グループに追加する

    sudo adduser $USER incus-admin
    newgrp incus-admin
    
  3. Incus環境をするための初期設定ファイルを作成する

    設定内容の概要

    カテゴリ 名前 主な設定 詳細
    Global - config {}(グローバル設定なし)
    Network incusbr0 bridge / NAT IPv4: 192.168.10.1/24
    NAT: true
    IPv6: none
    Storage Pool default dir source: /var/lib/incus/storage-pools/default
    Profile default 最小構成 制限なし / デバイス未定義
    Profile lxc コンテナ用 CPU: 2 / Mem: 2GiB
    nesting: true
    NIC: incusbr0
    Disk: default
    Profile vm VM用 CPU: 2 / Mem: 4GiB
    NIC: incusbr0
    Disk: 40GiB
    Project 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
    
  4. 作成したファイルを元に設定をする

    cat incus-init.yaml | incus admin init --preseed
    

2. incus設定確認

  1. 設定内容が反映されたか確認する

    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
    
  2. 下記のコマンドでincusのグローバル設定が入っていないことを確認する

    incus config show
    

    コマンド実行結果例

    config: {}
    
  3. 作成した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: 
    
  4. ストレージプールの保存場所を確認する

    incus storage get default source
    

    コマンド実行結果例

    /var/lib/incus/storage-pools/default
    
  5. 作成したプロファイルを確認する

    incus profile list
    

    コマンド実行結果例

    +---------+---------------------------------+---------+
    |  NAME   |           DESCRIPTION           | USED BY |
    +---------+---------------------------------+---------+
    | default | Default Incus profile           | 0       |
    +---------+---------------------------------+---------+
    | lxc     | lxc profile with Docker support | 0       |
    +---------+---------------------------------+---------+
    | vm      | Virtual Machine profile         | 0       |
    +---------+---------------------------------+---------+
    
  6. 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: []
    
    
  7. 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をデプロイする

  1. Ubuntu 24.04 LTSベースのLinuxコンテナをデプロイする場合、下記のコマンドを実行する

    incus launch images:ubuntu/24.04 lxc1 --profile lxc
    
  2. Ubuntu 24.04 LTSベースの仮想マシンをデプロイする場合、下記のコマンドを実行する

    incus launch images:ubuntu/24.04 vm1 --vm --profile vm
    

4. 作成したLinuxコンテナ、Virtual Machineにアクセスする

  1. 下記のサイトを参考に作成したインスタンスにアクセスする

    インスタンスの操作

    コンソールにアクセスするには

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?