Initializing LXD Using a Preseed File

15 minutes
  • 3 Learning Objectives

About this Hands-on Lab

When configuring multiple LXD hosts, either to work alongside a remote or as isolated environments, it saves time to bypass the prompt and instead use a preseed file for LXD configuration. In this lab, we generate our preseed file, then create two identical dev environments using our newly-created file.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Generate the Preseed File
  1. Configure LXD on the first host:

    lxd init
    Would you like to use LXD 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 (btrfs, ceph, dir, lvm, zfs) [default=zfs]:
    Create a new ZFS pool? (yes/no) [default=yes]:
    Would you like to use an existing block device? (yes/no) [default=no]: yes
    Path to the existing block device: /dev/nvme1n1
    Would you like to connect to a MAAS server? (yes/no) [default=no]:
    Would you like to create a new local network bridge? (yes/no) [default=yes]:
    What should the new bridge be called? [default=lxdbr0]:
    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 LXD to be available over the network? (yes/no) [default=no]: yes
    Address to bind LXD to (not including port) [default=all]:
    Port to bind LXD to [default=8443]:
    Trust password for new clients:
    Would you like stale cached images to be updated automatically? (yes/no) [default=yes]
    Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: yes
  1. Copy the provided preseed output and save it to a file in the home directory called preseed.yaml:
vim preseed.yaml

  core.https_address: '[::]:8443'
  core.trust_password: pinehead
- config:
    ipv4.address: auto
    ipv6.address: auto
  description: ""
  managed: false
  name: lxdbr0
  type: ""
- config:
    source: /dev/nvme1n1
  description: ""
  name: default
  driver: zfs
- config: {}
  description: ""
      name: eth0
      nictype: bridged
      parent: lxdbr0
      type: nic
      path: /
      pool: default
      type: disk
  name: default
cluster: null
Configure the Second Server
  1. Copy over the preseed file:

    scp cloud_user@ preseed.yaml
  2. Configure LXD:

    cat preseed.yaml | lxd init --preseed
Configure the Third Server

Repeat the steps from the second server, or try with a single command:

scp cloud_user@ preseed.yaml | cat preseed.yaml | lxd init --preseed

Additional Resources

Your company has recently decided to begin an initiative to lift-and-shift a number of legacy applications into resource-light Linux containers. Before any major changes are made, however, you and your team need working LXD-configured development environments from which to work. Set up LXD on your own host, then use the created preseed file to configure two additional LXD hosts in two commands or fewer.

The appropriate version of LXD is already installed on the hosts.

Use the following notes when configuring the initial host:

  • Do not enable clustering
  • Create a ZFS block on /dev/nvme1n1
  • Configure a network
  • Make LXD available over the network

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?