Categories
Uncategorized

How to create LXD instance from snapshot

Create LXD instance from a specific snapshot.

Stop vm-example-source instance.

$ sudo lxc stop vm-example-source

Create snaphot starting-point for vm-example-source instance.

$ sudo lxc snapshot vm-example-source starting-point

Inspect vm-example-source instance.

$ sudo lxc info  vm-example-source
Name: vm-example-source
Location: none
Remote: unix://
Architecture: x86_64
Created: 2020/07/28 21:27 UTC
Status: Stopped
Type: container
Profiles: default, kubernetes
Snapshots:
  starting-point (taken at 2020/07/29 08:12 UTC) (stateless)

Start vm-example-source instance as snapshot was successfully created.

$ sudo lxc start vm-example-source

Create vm-example-target instance using starting-point snaphot from vm-example-source instance.

$ sudo lxc copy vm-example-source/starting-point vm-example-target

Inspect vm-example-target instance.

$ sudo lxc info vm-example-target
Name: vm-example-target
Location: none
Remote: unix://
Architecture: x86_64
Created: 2020/07/29 08:18 UTC
Status: Stopped
Type: container
Profiles: default, kubernetes

Start vm-example-target instance.

ansible@kraken:~$ sudo lxc start vm-example-target

List both instances.

ansible@kraken:~$ sudo lxc list kubernetes-example
+---------------------------+---------+----------------------+------+-----------+-----------+
|           NAME            |  STATE  |         IPV4         | IPV6 |   TYPE    | SNAPSHOTS |
+---------------------------+---------+----------------------+------+-----------+-----------+
| vm-example-source         | RUNNING | 172.17.0.1 (docker0) |      | CONTAINER | 1         |
|                           |         | 172.16.40.38 (eth0)  |      |           |           |
+---------------------------+---------+----------------------+------+-----------+-----------+
| vm-example-target         | RUNNING | 172.17.0.1 (docker0) |      | CONTAINER | 0         |
|                           |         | 172.16.40.115 (eth0) |      |           |           |
+---------------------------+---------+----------------------+------+-----------+-----------+

This technique is very useful for bug finding or testing.