### Start IncusOS VM Installation Source: https://linuxcontainers.org/incus-os/docs/main/getting-started/installation/virtual-incus Starts the IncusOS virtual machine to begin the installation process. This command initiates the boot sequence from the attached ISO image. ```bash incus start IncusOS ``` -------------------------------- ### Start IncusOS Installation in VM Source: https://linuxcontainers.org/incus-os/docs/main/_sources/getting-started/installation/virtual-incus.md.txt Starts the IncusOS virtual machine to begin the installation process and attaches to its console via VGA. ```bash incus start IncusOS incus console IncusOS --type=vga ``` -------------------------------- ### Start VM and connect to console Source: https://linuxcontainers.org/incus/docs/main/_sources/howto/instances_create.md.txt Starts the virtual machine and connects to its serial console, which may display an installer menu. ```bash incus start iso-vm --console ``` -------------------------------- ### Cloud-init Configuration for Installing Packages Source: https://linuxcontainers.org/incus/docs/main/_sources/cloud-init.md.txt Specify packages to be installed during instance setup using the 'packages' key. ```yaml config: cloud-init.user-data: | #cloud-config packages: - git - openssh-server ``` -------------------------------- ### Install incus-benchmark tool Source: https://linuxcontainers.org/incus/docs/main/_sources/howto/benchmark_performance.md.txt Install the `incus-benchmark` tool using Go. Ensure Go is installed and configured. ```bash go install github.com/lxc/incus/cmd/incus-benchmark@latest ``` -------------------------------- ### Start Windows VM and Open Console Source: https://linuxcontainers.org/distrobuilder/docs/latest/_sources/tutorials/use.md.txt Starts the 'win10' Incus VM and opens a VGA console, allowing for the graphical installation of Windows. ```bash incus start win10 --console=vga ``` -------------------------------- ### Start and Console into Windows VM in Incus Source: https://linuxcontainers.org/distrobuilder/docs/latest/tutorials/use Start the configured Windows VM and open a VGA console to begin the graphical installation. ```bash incus start win10 --console=vga ``` -------------------------------- ### Show information for containers matching a pattern Source: https://linuxcontainers.org/lxc/manpages/man1/lxc-info.1.html This example demonstrates how to display information for all containers whose names start with 'ubuntu'. The wildcard '*' is used for pattern matching. ```shell lxc-info -n 'ubuntu.*' ``` -------------------------------- ### instance_create_start Source: https://linuxcontainers.org/incus/docs/main/_sources/api-extensions.md.txt Adds a `start` field to `POST /1.0/instances` to automatically start an instance upon creation. ```APIDOC ## `instance_create_start` Adds a new `start` field to the `POST /1.0/instances` API which when set to `true` will have the instance automatically start upon creation. In this scenario, the creation and startup is part of a single background operation. ``` -------------------------------- ### Install distrobuilder using Go Source: https://linuxcontainers.org/distrobuilder/docs/latest/_sources/howto/install.md.txt Install distrobuilder using the Go toolchain. Ensure you have Go installed and configured. ```bash go install github.com/lxc/distrobuilder/cmd/distrobuilder@latest ``` -------------------------------- ### Start the VM instance Source: https://linuxcontainers.org/incus/docs/main/_sources/howto/instances_routed_nic_vm.md.txt Starts the 'bookworm' virtual machine instance after its network configuration has been applied. ```bash incus start bookworm ``` -------------------------------- ### Start an instance (CLI) Source: https://linuxcontainers.org/incus/docs/main/_sources/howto/instances_manage.md.txt Use this command to start a stopped instance. The --console flag can be used to immediately attach to the console upon starting. ```bash incus start ``` ```bash incus start --console ``` -------------------------------- ### Install Distrobuilder using Snap (Stable) Source: https://linuxcontainers.org/distrobuilder/news/2019_10_21_22_10.html Installs the stable version of Distrobuilder using snap. ```bash snap install distrobuilder --classic ``` -------------------------------- ### Create a project with configuration from a file Source: https://linuxcontainers.org/incus/docs/main/_sources/reference/manpages/incus/project/create.md.txt Create a project and apply configuration settings defined in a YAML file. ```bash incus project create p1 < config.yaml ``` -------------------------------- ### Start instance with VGA console attached Source: https://linuxcontainers.org/incus/docs/main/_sources/howto/instances_console.md.txt Start an instance and immediately attach to its VGA console. This is particularly useful for virtual machines to access graphical output. ```bash incus start --console=vga ``` -------------------------------- ### Start instance with console attached Source: https://linuxcontainers.org/incus/docs/main/_sources/howto/instances_console.md.txt Immediately attach to the instance's console upon starting it. This is useful for observing the boot process from the very beginning. ```bash incus start --console ``` -------------------------------- ### Python API Example: Create, Start, Stop, Destroy Container Source: https://linuxcontainers.org/lxc/documentation Provides an end-to-end example using the LXC Python bindings to create, start, query, stop, and destroy a container. It mirrors the functionality shown in the C API example. ```python #!/usr/bin/python3 import lxc import sys # Setup the container object c = lxc.Container("apicontainer") if c.defined: print("Container already exists", file=sys.stderr) sys.exit(1) # Create the container rootfs if not c.create("download", lxc.LXC_CREATE_QUIET, {"dist": "ubuntu", "release": "trusty", "arch": "i386"}): print("Failed to create the container rootfs", file=sys.stderr) sys.exit(1) # Start the container if not c.start(): print("Failed to start the container", file=sys.stderr) sys.exit(1) # Query some information print("Container state: %s" % c.state) print("Container PID: %s" % c.init_pid) # Stop the container if not c.shutdown(30): print("Failed to cleanly shutdown the container, forcing.") if not c.stop(): print("Failed to kill the container", file=sys.stderr) sys.exit(1) ``` -------------------------------- ### Launch Instance and Execute Command Source: https://linuxcontainers.org/incus/docs/main/howto/incus_alias Demonstrates launching a Debian instance and then executing a command to switch to the 'debian' user. ```bash $ incus launch images:debian/12/cloud mycontainer Launching mycontainer $ incus exec mycontainer -- su -l debian debian@mycontainer:~$ ``` -------------------------------- ### IncusOS Install Seed with Certificate Source: https://linuxcontainers.org/incus-os/docs/main/_sources/getting-started/download.md.txt Example of an IncusOS install seed configuration, including a client certificate, for trusted installation. ```yaml apply_defaults: true preseed: certificates: - name: demo type: client certificate: | -----BEGIN CERTIFICATE----- MIIB4TCCAWagAwIBAgIQVrBNb+LgEvX/aDNNOLM2iTAKBggqhkjOPQQDAzA4MRkw FwYDVQQKExBMaW51eCBDb250YWluZXJzMRswGQYDVQQDDBJnaWJtYXRAZnV0dXJm dXNpb24wHhcNMjUwNjA1MTgwODAwWhcNMzUwNjAzMTgwODAwWjA4MRkwFwYDVQQK ExBMaW51eCBDb250YWluZXJzMRswGQYDVQQDDBJnaWJtYXRAZnV0dXJmdXNpb24w djAQBgcqhkjOPQIBBgUrgQQAIgNiAAS8Tsj87gyhkR6gUoTa9dooWhwApI9MlsZS M9HkNdgLG+0d2yU3JXru4AbCD+pslsL5mnSjbmF7BhqSAT0opQtyFMfB7hrCJkVB nnebLNOqzrOVnxYqnD1HnfKo6RVmXpGjNTAzMA4GA1UdDwEB/wQEAwIFoDATBgNV HSUEDDAKBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMAoGCCqGSM49BAMDA2kAMGYC MQC/Y4nAuV09z/zeh0aN+XV+kI9WLnITFprSHREIaES3r49cTkpoV8wFCwdLjbSb NwECMQCx5H/H3hyXJen3uLbqRxTzw5jjx1M4dO4fru+VmoOKmTSmKVq3r2j449iD GrzY7EQ= -----END CERTIFICATE----- ``` -------------------------------- ### Instance creation with configuration file Source: https://linuxcontainers.org/incus/docs/main/_sources/reference/manpages/incus/launch.md.txt Create and start a container named "c2" from the "debian/12" image, applying configuration from a local file. ```bash incus launch images:debian/12 c2 < config.yaml ``` -------------------------------- ### Instance Boot Time Metrics Source: https://linuxcontainers.org/incus/news/index.html Shows how to list instances and query Incus metrics to retrieve boot time and current time for an instance. ```bash stgraber@dakara:~$ incus list a1 +------+---------+---------------------+---------------------------------------------+-----------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +------+---------+---------------------+---------------------------------------------+-----------+-----------+ | a1 | RUNNING | 172.17.0.177 (eth0) | 2602:fc62:c:1000:1266:6aff:fe2d:30e5 (eth0) | CONTAINER | 0 | +------+---------+---------------------+---------------------------------------------+-----------+-----------+ stgraber@dakara:~$ incus query /1.0/metrics | grep a1 | grep time incus_boot_time_seconds{name="a1",project="default",type="container"} 1.772214792e+09 incus_time_seconds{name="a1",project="default",type="container"} 1.772216491e+09 ``` -------------------------------- ### Run QMP commands before VM start Source: https://linuxcontainers.org/incus/docs/main/reference/instance_options Use `raw.qemu.pre-start` to provide a JSON encoded list of QMP commands to run after Incus has added all its devices but before the VM starts. ```json raw.qemu.pre-start: | [ {"execute": "qmp_command", "arguments": {}} ] ``` -------------------------------- ### Install Colima with Incus Runtime (macOS) Source: https://linuxcontainers.org/incus/docs/main/_sources/installing.md.txt Installs Colima and starts it with Incus as the runtime, enabling Incus support on macOS. ```bash brew install colima colima start --runtime incus ``` -------------------------------- ### Example lxc-start-netns Script Source: https://linuxcontainers.org/lxc/news/2018_03_27_21_03.html A sample script for the lxc.hook.start-host, demonstrating how to set up network interfaces within the container's namespace. ```shell echo "starting" > /tmp/debug ip link add host1 type veth peer name peer1 ip link set host1 master lxcbr0 ip link set host1 up ip link set peer1 netns "${LXC_PID}" ``` -------------------------------- ### Create an instance with configuration from a file Source: https://linuxcontainers.org/incus/docs/main/_sources/reference/manpages/incus/create.md.txt Creates a new instance using the 'debian/12' image and applies configuration specified in 'config.yaml'. ```bash incus create images:debian/12 u1 < config.yaml ``` -------------------------------- ### Install Incus on Alpine Linux Source: https://linuxcontainers.org/incus/docs/main/_sources/installing.md.txt Installs Incus and its client, along with VM support if needed. Enables and starts the Incus service. ```bash apk update apk add incus incus-client apk add incus-vm rc-update add incusd rc-service incusd start ``` -------------------------------- ### Attach to instance console after starting Source: https://linuxcontainers.org/incus/docs/main/_sources/reference/manpages/incus/start.md.txt This flag immediately attaches the user to the console of the instance after it has been started. This is useful for interactive setup or monitoring. ```bash incus start --console ``` -------------------------------- ### Launch Instance with Direct Network Connection Source: https://linuxcontainers.org/incus-os/docs/main/tutorials/network-direct-attach Launch a new instance and configure it to use the 'enp5s0' network for direct connection to the host's physical network. ```bash gibmat@futurfusion:~$ incus launch images:debian/13 debian-direct --network enp5s0 Launching debian-direct ``` -------------------------------- ### Install OVN host component Source: https://linuxcontainers.org/incus/docs/main/_sources/howto/network_ovn_setup.md.txt Installs the OVN host package on machines that will only run OVN controllers and enables the service to start on boot. ```bash sudo apt install ovn-host systemctl enable ovn-host ``` -------------------------------- ### Start an instance using API Source: https://linuxcontainers.org/incus/docs/main/howto/instances_manage Send a PUT request to the `/1.0/instances//state` API endpoint with the action set to 'start' to initiate an instance. ```bash incus query --request PUT /1.0/instances//state --data '{"action":"start"}' ``` -------------------------------- ### Eject CDROM and reset VM after IncusOS install Source: https://linuxcontainers.org/incus-os/docs/main/_sources/getting-started/installation/virtual-libvirt.md.txt Once the IncusOS installation is complete, eject the CDROM device and reset the virtual machine to finalize the setup. ```bash virsh change-media IncusOS sdb --eject virsh reset IncusOS ``` -------------------------------- ### Start IncusOS VM for First Boot Source: https://linuxcontainers.org/incus-os/docs/main/getting-started/installation/virtual-incus Starts the IncusOS virtual machine for its initial boot configuration after installation. The --console=vga flag attaches to the console for monitoring. ```bash incus start IncusOS --console=vga ``` -------------------------------- ### Create a storage bucket from a configuration file Source: https://linuxcontainers.org/incus/docs/main/_sources/reference/manpages/incus/storage/bucket/create.md.txt This example shows how to create a storage bucket using configuration details provided in a YAML file. ```bash incus storage bucket create p1 b01 < config.yaml ``` -------------------------------- ### Run QMP commands after VM start Source: https://linuxcontainers.org/incus/docs/main/reference/instance_options Use `raw.qemu.post-start` to provide a JSON encoded list of QMP commands to run immediately after the VM starts. ```json raw.qemu.post-start: | [ {"execute": "qmp_command", "arguments": {}} ] ``` -------------------------------- ### Cloud-init YAML configuration example Source: https://linuxcontainers.org/incus/docs/main/cloud-init Example of how to configure cloud-init user data using YAML's literal style. This is typically used for instance-specific configurations and should start with '#cloud-config'. ```yaml config: cloud-init.user-data: | #cloud-config package_upgrade: true packages: - package1 - package2 ``` -------------------------------- ### Basic instance creation Source: https://linuxcontainers.org/incus/docs/main/_sources/reference/manpages/incus/launch.md.txt Create and start a container named "c1" from the "debian/12" image. ```bash incus launch images:debian/12 c1 ``` -------------------------------- ### Container Last Used At Source: https://linuxcontainers.org/incus/docs/main/api-extensions Adds a `last_used_at` field to the `GET /1.0/containers/` endpoint. This field provides a timestamp indicating the last time the container was started. For containers that have been created but not yet started, it defaults to `1970-01-01T00:00:00Z`. ```APIDOC ## `container_last_used_at` A `last_used_at` field was added to the `GET /1.0/containers/` endpoint. It is a timestamp of the last time the container was started. If a container has been created but not started yet, `last_used_at` field will be `1970-01-01T00:00:00Z` ``` -------------------------------- ### Get Incus Client Certificate Source: https://linuxcontainers.org/incus-os/docs/main/_sources/getting-started/download.md.txt Run this command to obtain your initial trusted client certificate for IncusOS installation. ```bash incus remote get-client-certificate ``` -------------------------------- ### C API Example: Create, Start, Stop, Destroy Container Source: https://linuxcontainers.org/lxc/documentation Demonstrates the usage of the LXC C API to perform basic container operations: creation, starting, querying state, stopping, and destroying. Ensure lxccontainer.h is included and linked. ```c #include #include int main() { struct lxc_container *c; int ret = 1; /* Setup container struct */ c = lxc_container_new("apicontainer", NULL); if (!c) { fprintf(stderr, "Failed to setup lxc_container struct\n"); goto out; } if (c->is_defined(c)) { fprintf(stderr, "Container already exists\n"); goto out; } /* Create the container */ if (!c->createl(c, "download", NULL, NULL, LXC_CREATE_QUIET, "-d", "ubuntu", "-r", "trusty", "-a", "i386", NULL)) { fprintf(stderr, "Failed to create container rootfs\n"); goto out; } /* Start the container */ if (!c->start(c, 0, NULL)) { fprintf(stderr, "Failed to start the container\n"); goto out; } /* Query some information */ printf("Container state: %s\n", c->state(c)); printf("Container PID: %d\n", c->init_pid(c)); /* Stop the container */ if (!c->shutdown(c, 30)) { printf("Failed to cleanly shutdown the container, forcing.\n"); if (!c->stop(c)) { fprintf(stderr, "Failed to kill the container.\n"); goto out; } } /* Destroy the container */ if (!c->destroy(c)) { fprintf(stderr, "Failed to destroy the container.\n"); goto out; } ret = 0; out: lxc_container_put(c); return ret; } ``` -------------------------------- ### Starting a Container with Custom ID Mapping and Rootfs Source: https://linuxcontainers.org/lxc/news/2019_03_12_15_03.html This snippet demonstrates how to start a container with specific user and group ID mappings, and a custom root filesystem path. It also shows how to specify an init command. ```bash lxc-start -n -f /path/to/conf \ -s 'lxc.id_map = u 0 100000 65536' \ -s 'lxc.id_map = g 0 100000 65536' \ -s 'lxc.rootfs = /path/to/rootfs' \ -s 'lxc.init_cmd = /path/to/initcmd' ``` -------------------------------- ### BPF Filesystem Mount Example Source: https://linuxcontainers.org/incus/docs/main/_sources/explanation/bpf-tokens.md.txt This example shows how the BPF filesystem is mounted with specific delegated capabilities for commands, maps, programs, and attachments. It reflects the configuration options set for BPF delegation. ```bash $ mount -t bpf none on /sys/fs/bpf type bpf (rw,relatime,delegate_cmds=map_create:obj_get:link_create,delegate_maps=hash:array:devmap:queue:stack,delegate_progs=socket_filter:kprobe:cgroup_sysctl,delegate_attachs=any) ``` -------------------------------- ### Template Generator Example Source: https://linuxcontainers.org/distrobuilder/docs/latest/_sources/reference/generators.md.txt Creates a custom Incus template file. The 'when' key specifies when the template should be applied (create, copy, or start). ```yaml files: - generator: template name: my-template.tpl path: /etc/my-template.conf template: properties: my_variable: "some_value" when: - create - start ``` -------------------------------- ### Create and launch containers Source: https://linuxcontainers.org/incus/docs/main/_sources/howto/benchmark_performance.md.txt Use the `launch` action to both create and start containers. The `--freeze` flag can be used to measure pure launch times. ```bash incus-benchmark launch --count 10 ``` ```bash incus-benchmark launch --count 10 --freeze ``` -------------------------------- ### LXC Host Start Hook for CNI Source: https://linuxcontainers.org/lxc/news/2018_03_27_21_03.html A hook executed on the host after container setup and before init. Used here to integrate CNI network configuration. ```shell lxc.net.0.type = "empty" ``` ```shell lxc.hook.start-host = "/bin/lxc-start-netns" ``` -------------------------------- ### Complex LXC Container Configuration Source: https://linuxcontainers.org/lxc/manpages/man5/lxc.container.conf.5.html An example demonstrating a complex setup involving advanced networking, control groups, hostname, mounts, and root filesystem options. ```bash lxc.uts.name = complex lxc.net.0.type = veth lxc.net.0.flags = up lxc.net.0.link = br0 lxc.net.0.hwaddr = 4a:49:43:49:79:bf lxc.net.0.ipv4.address = 10.2.3.5/24 10.2.3.255 lxc.net.0.ipv6.address = 2003:db8:1:0:214:1234:fe0b:3597 lxc.net.0.ipv6.address = 2003:db8:1:0:214:5432:feab:3588 lxc.net.1.type = macvlan lxc.net.1.flags = up lxc.net.1.link = eth0 lxc.net.1.hwaddr = 4a:49:43:49:79:bd lxc.net.1.ipv4.address = 10.2.3.4/24 lxc.net.1.ipv4.address = 192.168.10.125/24 lxc.net.1.ipv6.address = 2003:db8:1:0:214:1234:fe0b:3596 lxc.net.2.type = phys lxc.net.2.flags = up lxc.net.2.link = dummy0 lxc.net.2.hwaddr = 4a:49:43:49:79:ff lxc.net.2.ipv4.address = 10.2.3.6/24 lxc.net.2.ipv6.address = 2003:db8:1:0:214:1234:fe0b:3297 lxc.cgroup.cpuset.cpus = 0,1 lxc.cgroup.cpu.shares = 1234 lxc.cgroup.devices.deny = a lxc.cgroup.devices.allow = c 1:3 rw lxc.cgroup.devices.allow = b 8:0 rw lxc.mount.fstab = /etc/fstab.complex lxc.mount.entry = /lib /root/myrootfs/lib none ro,bind 0 0 lxc.rootfs.path = dir:/mnt/rootfs.complex lxc.rootfs.options = idmap=container lxc.cap.drop = sys_module mknod setuid net_raw lxc.cap.drop = mac_override ``` -------------------------------- ### Create and start a virtual machine with custom disk settings Source: https://linuxcontainers.org/incus/docs/main/_sources/reference/manpages/incus/create.md.txt Creates and starts a virtual machine instance named 'v2' from the 'debian/12' image. It overrides the default disk size to 50GiB and sets the disk bus to 'nvme'. ```bash incus launch images:debian/12 v2 --vm -d root,size=50GiB -d root,io.bus=nvme ``` -------------------------------- ### Attach to IncusOS VM Console Source: https://linuxcontainers.org/incus-os/docs/main/getting-started/installation/virtual-incus Attaches to the virtual machine's console via VGA to monitor and interact with the IncusOS installer. This is typically done after starting the VM. ```bash incus console IncusOS --type=vga ``` -------------------------------- ### Create a basic project Source: https://linuxcontainers.org/incus/docs/main/_sources/howto/projects_create.md.txt Use this command to create a new project with default settings. The project name is required. ```bash incus project create my-project ``` -------------------------------- ### Start VGA Console for VM Source: https://linuxcontainers.org/incus/docs/main/howto/instances_console Use this command to initiate a VGA console connection to a virtual machine. Ensure you have a SPICE client like 'remote-viewer' or 'spicy' installed. ```bash incus console --type vga ``` -------------------------------- ### Launching an Instance with a YAML Configuration File Source: https://linuxcontainers.org/incus/docs/main/howto/instances_create Instead of using command-line flags, you can provide instance configuration details via a YAML file. This is useful for complex configurations. ```bash incus launch images:debian/12 debian-config < config.yaml ``` -------------------------------- ### Basic Cloud-init User Data Configuration Source: https://linuxcontainers.org/incus/docs/main/_sources/cloud-init.md.txt Example of a basic cloud-init user data configuration using the literal style format to include package upgrade and installation instructions. ```yaml config: cloud-init.user-data: | #cloud-config package_upgrade: true packages: - package1 - package2 ``` -------------------------------- ### Get Project Configuration Key with Property Flag Source: https://linuxcontainers.org/incus/docs/main/reference/manpages/incus/project/get This example demonstrates retrieving a project configuration key using the `--property` flag, which treats the key as a project property. ```bash incus project get -p, --property ``` -------------------------------- ### Launch Ubuntu container and install Nginx Source: https://linuxcontainers.org/incus/news/2024_09_06_23_09.html Launches an Ubuntu container and installs the Nginx web server. This is a prerequisite for setting up backends for the load-balancer. ```bash root@server01:~# incus launch images:ubuntu/24.04 c1 Launching c1 root@server01:~# incus exec c1 -- apt-get install --yes nginx Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: nginx-common Suggested packages: fcgiwrap nginx-doc ssl-cert The following NEW packages will be installed: nginx nginx-common 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 552 kB of archives. After this operation, 1596 kB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu noble/main amd64 nginx-common all 1.24.0-2ubuntu7 [31.2 kB] Get:2 http://archive.ubuntu.com/ubuntu noble/main amd64 nginx amd64 1.24.0-2ubuntu7 [521 kB] Fetched 552 kB in 1s (619 kB/s) Preconfiguring packages ... Selecting previously unselected package nginx-common. (Reading database ... 16176 files and directories currently installed.) Preparing to unpack .../nginx-common_1.24.0-2ubuntu7_all.deb ... Unpacking nginx-common (1.24.0-2ubuntu7) ... Selecting previously unselected package nginx. Preparing to unpack .../nginx_1.24.0-2ubuntu7_amd64.deb ... Unpacking nginx (1.24.0-2ubuntu7) ... Setting up nginx (1.24.0-2ubuntu7) ... Setting up nginx-common (1.24.0-2ubuntu7) ... Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service. ``` -------------------------------- ### Configure Firewall for LXC Network Bridge Source: https://linuxcontainers.org/lxc/getting-started If containers are not getting IP addresses, configure the host's firewall (ufw example) to allow traffic on the LXC network bridge (`lxcbr0`). ```bash root@host:~# ufw allow in on lxcbr0 root@host:~# ufw route allow in on lxcbr0 root@host:~# ufw route allow out on lxcbr0 ``` -------------------------------- ### Example Instance Placement Scriptlet Source: https://linuxcontainers.org/incus/docs/main/explanation/clustering Demonstrates a basic instance placement scriptlet in Starlark, including logging and conditional logic for instance placement. ```starlark def instance_placement(request, candidate_members): # Example of logging info, this will appear in Incus' log. log_info("instance placement started: ", request) # Example of applying logic based on the instance request. if request.name == "foo": # Example of logging an error, this will appear in Incus' log. log_error("Invalid name supplied: ", request.name) fail("Invalid name") # Exit with an error to reject instance placement. # Place the instance on the first candidate server provided. set_target(candidate_members[0].server_name) return # Return empty to allow instance placement to proceed. ``` -------------------------------- ### Troubleshoot systemd Startup Failure Source: https://linuxcontainers.org/incus/docs/main/_sources/howto/instances_troubleshoot.md.txt This example demonstrates diagnosing a systemd startup failure in an unprivileged container. It shows how to view the console log, identify missing /sys and /proc mounts, and temporarily change the init system to /bin/bash for further investigation. ```bash incus console --show-log systemd Console log: Failed to insert module 'autofs4' Failed to insert module 'unix' Failed to mount sysfs at /sys: Operation not permitted Failed to mount proc at /proc: Operation not permitted [!!!!!!] Failed to mount API filesystems, freezing. ``` ```bash incus config set systemd raw.lxc 'lxc.init.cmd = /bin/bash' ``` ```bash incus start systemd ``` ```bash incus console --show-log systemd Console log: [root@systemd /]# ``` ```bash incus exec systemd -- bash [root@systemd ~]# ls [root@systemd ~]# mount mount: failed to read mtab: No such file or directory [root@systemd ~]# cd / [root@systemd /]# ls /proc/ sys [root@systemd /]# exit ``` -------------------------------- ### Deactivate a network link using increased capabilities Source: https://linuxcontainers.org/lxc/manpages/man1/lxc-attach.1.html Deactivate a network link within a container when the container lacks the NET_ADMIN capability. This example uses the -e option for increased capabilities, assuming the 'ip' tool is installed. ```bash lxc-attach -n container -e -- /sbin/ip link delete eth1 ``` -------------------------------- ### Install lxc-to-incus Tool Source: https://linuxcontainers.org/incus/docs/main/_sources/howto/migrate_from_lxc.md.txt Install the `lxc-to-incus` tool using `go install`. Ensure you have Go installed. ```bash go install github.com/lxc/incus/cmd/lxc-to-incus@latest ``` -------------------------------- ### Start migrated instances and verify Source: https://linuxcontainers.org/incus-os/docs/main/_sources/tutorials/storage-import-unencrypted-incus-pool.md.txt Starts all instances that have been migrated to the new encrypted storage pool and then lists them to verify their running state and network configuration. This confirms the successful migration and accessibility of instances. ```bash gibmat@futurfusion:~$ for instance in $(incus list --columns n --format compact,noheader); do incus start $instance; done gibmat@futurfusion:~$ incus list +-------------+---------+-----------------------+------------------------------------------------+-----------------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +-------------+---------+-----------------------+------------------------------------------------+-----------------+-----------+ | debian13 | RUNNING | 10.119.172.82 (eth0) | fd42:d040:6b43:6e18:1266:6aff:fe87:2cc (eth0) | CONTAINER | 0 | +-------------+---------+-----------------------+------------------------------------------------+-----------------+-----------+ | debian13-vm | RUNNING | 10.119.172.185 (eth0) | fd42:d040:6b43:6e18:1266:6aff:fe63:ab3c (eth0) | VIRTUAL-MACHINE | 0 | +-------------+---------+-----------------------+------------------------------------------------+-----------------+-----------+ ``` -------------------------------- ### Display Instance Startup Time with 'incus info' Source: https://linuxcontainers.org/incus/news/2024_05_07_21_05.html Shows how to use 'incus info' to retrieve the startup timestamp of an instance. The 'StartedAt' field is displayed. ```bash stgraber@dakara:~$ incus info speedtest | grep Started Started: 2024/04/29 11:03 EDT ``` -------------------------------- ### Launch a virtual machine Source: https://linuxcontainers.org/incus/docs/main/_sources/howto/instances_create.md.txt Create a virtual machine instance using a specified image. The `--vm` flag is essential for VM creation. ```bash incus launch images:debian/12 debian-vm --vm ``` -------------------------------- ### Enable and Start Incus Service on Alpine Linux Source: https://linuxcontainers.org/incus/docs/main/installing Enable the Incus service to start on boot and start it immediately. ```shell rc-update add incusd rc-service incusd start ``` -------------------------------- ### Install Incus on Gentoo Source: https://linuxcontainers.org/incus/docs/main/_sources/installing.md.txt Installs Incus and its dependencies from the Gentoo main repository. Also installs QEMU for VM support. ```bash emerge -av app-containers/incus emerge -av app-emulation/qemu ``` -------------------------------- ### startl Source: https://linuxcontainers.org/lxc/apidoc/structlxc__container.html Starts an LXC container using a variadic list of arguments for the init process. This is an alternative to the `start` function for passing init arguments. ```APIDOC ## startl bool(* lxc_container::startl) (struct lxc_container *c, int useinit, ...) ### Description Start the container (list variant). ### Parameters - **c** (struct lxc_container *) - Container. - **useinit** (int) - Use lxcinit rather than `/sbin/init`. - **...** - Command-line to pass to init (must end in `NULL`). ### Returns `true` on success, else `false`. ### Note Identical to start except that that the init arguments are specified via a list rather than an array of pointers. ``` -------------------------------- ### Enable and Start LINSTOR Controller Service Source: https://linuxcontainers.org/incus/docs/main/howto/storage_linstor_setup Enables the LINSTOR controller service to start automatically on boot and starts it immediately. ```bash sudo systemctl enable --now linstor-controller ``` -------------------------------- ### Example Logging Configuration Source: https://linuxcontainers.org/incus/docs/main/server_config Demonstrates how to configure logging to Loki and syslog targets. Includes settings for addresses, authentication, and log types. ```yaml logging.loki01.target.type: loki logging.loki01.target.address: https://loki01.int.example.net logging.loki01.target.username: foo logging.loki01.target.password: bar logging.loki01.types: lifecycle,network-acl logging.loki01.lifecycle.types: instance logging.syslog01.target.type: syslog logging.syslog01.target.address: syslog01.int.example.net logging.syslog01.target.facility: security logging.syslog01.types: logging logging.syslog01.logging.level: warning ``` -------------------------------- ### Create Container with Autostart Configuration Source: https://linuxcontainers.org/lxc/getting-started Copy the default LXC configuration, add the autostart setting, and use this new configuration file with `lxc-create` for new containers. ```bash root@host:~# cp /etc/lxc/default.conf /etc/lxc/autostart.conf root@host:~# echo "lxc.start.auto = 1" >>/etc/lxc/autostart.conf root@host:~# lxc-create --name containera --config /etc/lxc/autostart.conf --template download -- --dist alpine --release 3.19 --arch amd64 ``` -------------------------------- ### Enable and Start LINSTOR Satellite Service Source: https://linuxcontainers.org/incus/docs/main/howto/storage_linstor_setup Enables the LINSTOR satellite service to start automatically on boot and starts it immediately. ```bash sudo systemctl enable --now linstor-satellite ``` -------------------------------- ### Install Incus Agent on macOS Source: https://linuxcontainers.org/incus/docs/main/_sources/howto/instances_create.md.txt Install the Incus agent on macOS by mounting a 9p share and running the installation script as root. ```shell mount_9p config cd /Volumes/config ./install.sh ```