Important: This script can mess up your system and screw up everytying you did with LXD. Use at your own risk!
The Python script in this repo can delete all LXD profiles, containers, networks, and images on a machine. It is basically an extension of Ilhaan Rasheed's Script to delete containers and images. And this extension basically is, that everything can be deleted for all projects.
Resetting lxd entirely (e.g. using --delete-all
is the equivalent to running the following command for each container for each project:
lxc --project=<project_name> stop <container_name> # for all running containers
lxc --project=<project_name> delete <container_name>
lxc --project=<project_name> image delete <image_fingerprint>
lxc --project=<project_name> profile delete <profile_name>
lxc --project=<project_name> network delete <network_name> # for all lxd managed networks
This script has been tested on Ubuntu 22.10 with a snap
installed LXD version of 5.7.
- Python3
- Ability to run
lxc
withoutsudo
- Clone this repo and
cd
into the cloned directory. - Make sure you have execute permissions on
lxd_reset_all.py
. You can set this for the current user by running:chmod u+x lxd_reset_all.py
- View available options:
./lxd_reset_all.py --help
- Reset everything:
./lxd_reset_all.py --reset-all
- Delete containers:
./lxd_reset_all.py -c
- Delete images:
./lxd_reset_all.py -i
- Delete profiles:
./lxd_reset_all.py -p
- Delete networks:
./lxd_reset_all.py -n
- Exclude a project:
./lxd_reset_all.py --reset-all -e myproject
- Exclude more projects:
./lxd_reset_all.py -c -e myproject1 myproject2
- Exclude more projects:
Alternatively, you can run this script without cloning the repo using curl
. For example, the following command runs the script and displays it's help message:
curl -s https://raw.githubusercontent.com/tmerten/lxd-delete-all/master/lxd_delete_all.py | python3 - -h