Using lxd-migrate to convert a physical host to a container

This is to document my first test of converting a bare metal dell laptop host Ubuntu 20.04 LTS to an LXD Host as a container.

Since LXD 5.3 prebuilt lxd-migrate binaries can be downloaded from the LXD Github releases page:

LXD-MIGRATE
Source Bare Metal Host = kumo2
Destination LXD Host = lxc1

# ./lxd-migrate
Please provide LXD server URL: https://192.168.0.10:8443
Certificate fingerprint: 56d897cc1e84e73d68b8380344633481d995b5c8c69579781ebc75da38da436f
ok (y/n)? y

1) Use a certificate token
2) Use an existing TLS authentication certificate
3) Generate a temporary TLS authentication certificate
Please pick an authentication mechanism above: 3

Your temporary certificate is:
-----BEGIN CERTIFICATE-----
GgYDVQQKExNsaW51eGNvbnRhaW5lcnMub3JnMRMwEQYDVQQDDApyb290QGt1bW8y
GgYDVQQKExNsaW51eGNvbnRhaW5lcnMub3JnMRMwEQYDVQQDDApyb290QGt1bW8y
GgYDVQQKExNsaW51eGNvbnRhaW5lcnMub3JnMRMwEQYDVQQDDApyb290QGt1bW8y
GgYDVQQKExNsaW51eGNvbnRhaW5lcnMub3JnMRMwEQYDVQQDDApyb290QGt1bW8y
GgYDVQQKExNsaW51eGNvbnRhaW5lcnMub3JnMRMwEQYDVQQDDApyb290QGt1bW8y
GgYDVQQKExNsaW51eGNvbnRhaW5lcnMub3JnMRMwEQYDVQQDDApyb290QGt1bW8y
GgYDVQQKExNsaW51eGNvbnRhaW5lcnMub3JnMRMwEQYDVQQDDApyb290QGt1bW8y
GgYDVQQKExNsaW51eGNvbnRhaW5lcnMub3JnMRMwEQYDVQQDDApyb290QGt1bW8y
GgYDVQQKExNsaW51eGNvbnRhaW5lcnMub3JnMRMwEQYDVQQDDApyb290QGt1bW8y
-----END CERTIFICATE-----

It is recommended to have this certificate be manually added to LXD through `lxc config trust add` on the target server.
Alternatively you could use a pre-defined trust password to add it remotely (use of a trust password can be a security issue).

Would you like to use a trust password? [default=no]:
Press ENTER after the certificate was added to the remote server:

Remote LXD server:
  Hostname: lxc1
  Version: 5.2

Would you like to create a container (1) or virtual-machine (2)?: 1
Name of the new instance: kumo2
Please provide the path to a root filesystem: /
Do you want to add additional filesystem mounts? [default=no]:

Instance to be created:
  Name: kumo2
  Project: default
  Type: container
  Source: /

Additional overrides can be applied at this stage:
1) Begin the migration with the above configuration
2) Override profile list
3) Set additional configuration options
4) Change instance storage pool or volume size
5) Change instance network

Please pick one of the options above [default=1]:
Instance kumo2 successfully created

Important: after booting the system, you probably need to change the configuration of the network interface on /etc/netplan/xxxxxxxxx.yaml to have the correct configuration to match the LXD host bridge interface.

Other than this, pretty cool. big thanks! to the LXD/LXC Ubuntu/Canonical team @tomp @stgraber .

Sincerely,

3 Likes