Skip to content
reubenajohnston edited this page Feb 4, 2025 · 18 revisions

Important: This use case isn't working well. We will not use it for now.

Notes for running Images in Incus

Important: Apparently, there is some discourse between Canonical (LXD) and Incus. Kali images are only supported now by Incus and are not available to LXD.

Incus on Ubuntu host

Instructions for starting from our Ubuntu server VM. Assumes that /dev/sdb is an unused disk on your Unbuntu server that can be used for the Incus storage pool.

  1. Create a new hard disk device as described below in 'Setup virtual hard disk for Incus' (e.g., /dev/sdb)
  2. (host) Update Ubuntu:
    sudo apt-get update
  3. (host) Install incus:
    sudo apt-get install incus qemu-system incus-tools
  4. (host) Setup incus:
    sudo adduser <USERNAME> incus-admin
    newgrp incus-admin
    incus admin init
    • Here are example prompts for the incus admin init step (you will want to specify the appropriate device for the disk you created above; e.g., /dev/sdb):
      Would you like to use clustering? (yes/no) [default=no]:
      Do you want to configure a new storage pool? (yes/no) [default=yes]:
      Name of the new storage pool [default=default]:
      Name of the storage backend to use (dir, lvm, lvmcluster, btrfs) [default=btrfs]:
      Create a new BTRFS pool? (yes/no) [default=yes]:
      Would you like to use an existing empty block device (e.g. a disk or partition)? (yes/no) [default=no]: yes
      Path to the existing block device: /dev/sdb
      Would you like to create a new local network bridge? (yes/no) [default=yes]:
      What should the new bridge be called? [default=incusbr0]:
      What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
      What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
      Would you like the server to be available over the network? (yes/no) [default=no]:
      Would you like stale cached images to be updated automatically? (yes/no) [default=yes]: no
      Would you like a YAML "init" preseed to be printed? (yes/no) [default=no]:
      

Kali image (w/X11) in Incus

  1. (host) Create a profile settings file named x11kali.txt with the content below:
    # LXD profile to enable graphics support for Kali containers
    #
    # Source: https://blog.simos.info/how-to-run-graphics-x11-applications-in-the-kali-lxd-container
    
    config:
      environment.DISPLAY: :0
      user.user-data: |
        runcmd:
          - sed -i '$ a\DISPLAY=:0' /root/.bashrc
          - sed -i '$ a\DISPLAY=:0' /home/kali/.bashrc
        packages:
          - x11-apps
          - mesa-utils
    description: X11 LXD profile
    devices:
      X0:
        bind: container
        connect: unix:@/tmp/.X11-unix/X1
        listen: unix:@/tmp/.X11-unix/X0
        security.gid: "1000"
        security.uid: "1000"
        type: proxy
    name: x11kali
    used_by: []
    
  2. (host) Create an incus profile x11kali
    incus profile create x11kali
    cat x11kali.txt | incus profile edit x11kali
  3. (host) Launch an instance of the Kali image
    incus launch images:kali/current/amd64 xkali --profile default --profile x11kali
  4. (host) Create a kali user in the instance with sudo privileges and setup its .bashrc for X11:
    incus exec xkali -- adduser kali
    incus exec xkali -- usermod -aG sudo kali
    incus exec xkali -- echo "export DISPLAY=:0" >> /home/kali/.bashrc
  5. (host) Todo (update with proper mcookie X11 authentication), Disable X11 authentication for localhost:
    xhost +
  6. (host) Start a console with the instance (you can exit it with 'ctrl-a' and then 'q'):
    incus console xkali
  7. (instance) Install test X11 application (first step might not be needed if packages specified by x11kali.txt were installed earlier, need to confirm) in the instance and test X11:
    sudo apt-get install x11-apps
    xeyes
    image

Setup virtual hard disk for Incus

  • Create the device:
    • VM->Settings, Add new device
    • Specify Hard Disk and select next
    • Specify SCSI and select next
    • Specify Create a new virtual disk and select next
    • Specify the size (I typically use 30GB) and keep the virtual disk as a single file, then select next
    • Name the disk file -Incus and save it in the same directory as your VM (e.g., Kali 2020.3-incus) and select finish
    • Reboot the VM

Useful links