How to purge malfunctioning workshops¶
Workshops can sometimes become unresponsive, encounter errors during start or stop operations, or become orphaned if their project directory is removed prematurely.
A thorough purge involves removing the workshop’s containers, metadata, and files in a deliberate sequence.
Prerequisites¶
Before starting, ensure you have these requirements satisfied:
Identified the workshop and project you intend to purge.
Copied out any files you need from inside the workshop, as described in the next section; manual cleanup can permanently delete containers, metadata, and files.
Checked that you can run sudo and lxc for manual LXD cleanup.
Before removing a workshop¶
Removing a workshop deletes everything inside it,
along with the host directories
that Workshop allocated for its mount plugs under
~/.local/share/workshop/id/<PROJECT-ID>/<WORKSHOP>/mount/;
copy any files you need from there to another place on the host first.
Only host directories that you manage yourself survive,
such as the project directory at /project
or a directory relocated with workshop remount.
Files elsewhere in the workshop,
such as the workshop user’s home directory,
are lost.
If the workshop still runs, open a shell in it and copy the files you need into a new directory in the project:
$ workshop shell <WORKSHOP>
workshop@<WORKSHOP>:/project$ mkdir /project/workshop-recovery
workshop@<WORKSHOP>:/project$ cp -a ~/<PATH> /project/workshop-recovery/
If the workshop doesn’t start or you can’t open a shell in it, copy the files out of its LXD instance instead, as described in the next subsection.
Copy files out of a broken workshop¶
Each workshop runs as an LXD instance named <WORKSHOP>-<PROJECT-ID>
in the workshop.<USERNAME> LXD project,
where <USERNAME> is your system username or,
if the username can’t be used in an LXD project name,
your numeric user ID (id -u).
Find the instance and check whether it’s a container or a virtual machine:
$ lxc list --project workshop.<USERNAME> --columns nst
For a container, pull the files into a new directory on the host:
$ mkdir ~/workshop-recovery
$ lxc file pull --recursive --project workshop.<USERNAME> <INSTANCE>/home/workshop/<PATH> ~/workshop-recovery/
Run lxc without sudo here,
so that the copies belong to your host user;
this requires membership in the lxd group.
Symbolic links are copied as links;
lxc doesn’t follow them out of the container.
For a virtual machine, lxc file pull works only while the VM runs and its LXD agent responds. Otherwise, mount the disk of the broken VM in another VM workshop and copy the files from there. Don’t mount it on the host: anything inside the VM could have written to that disk, and the host kernel’s filesystem code isn’t built to withstand a disk that was altered on purpose. Mounting such a disk can crash the host or give an attacker control of it. A VM keeps that damage away from the host kernel, but the VM can still change the host directories it mounts read-write, including its project directory, so recover into a VM whose project directory is empty.
In a new, empty directory, create a VM workshop to recover the files with and launch it, as described in How to use virtual machines:
$ mkdir ~/vm-recovery $ workshop init <RECOVERY-WORKSHOP> --runtime lxd-vm --project ~/vm-recovery $ workshop launch <RECOVERY-WORKSHOP> --project ~/vm-recovery
Don’t add SDKs to its definition; without them, no interfaces connect the VM to the host. Find its instance name the same way as for the broken workshop.
Stop the broken VM if it’s still running:
$ lxc stop --force --project workshop.<USERNAME> <INSTANCE>
Allow its root volume to be attached to another instance, then attach it to the recovery VM:
$ lxc storage volume set --project workshop.<USERNAME> workshop virtual-machine/<INSTANCE> security.shared=true $ lxc config device add --project workshop.<USERNAME> <RECOVERY-INSTANCE> recovery disk pool=workshop source=<INSTANCE> source.type=virtual-machine
Open a shell in the recovery workshop and find the attached disk; it’s the one whose partitions have no mount points:
$ workshop shell <RECOVERY-WORKSHOP> --project ~/vm-recovery workshop@<RECOVERY-WORKSHOP>:/project$ lsblk -f NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS sda ├─sda1 ext4 1.0 cloudimg-rootfs 59134bd0-a76f-4ea0-8e4a-770b2e1eafc2 7G 19% / ├─sda14 ├─sda15 vfat FAT32 UEFI 0E9D-3FD8 98.2M 6% /boot/efi └─sda16 ext4 1.0 BOOT b4f0deba-ce7d-45dc-9999-0427f2720320 755.4M 7% /boot sdb ├─sdb1 ext4 1.0 cloudimg-rootfs 59134bd0-a76f-4ea0-8e4a-770b2e1eafc2 ├─sdb14 ├─sdb15 vfat FAT32 UEFI 0E9D-3FD8 └─sdb16 ext4 1.0 BOOT b4f0deba-ce7d-45dc-9999-0427f2720320
Mount the
cloudimg-rootfspartition of that disk read-only and copy the files you need into a new directory in the project:workshop@<RECOVERY-WORKSHOP>:/project$ sudo mkdir /mnt/recovery workshop@<RECOVERY-WORKSHOP>:/project$ sudo mount -o ro /dev/sdb1 /mnt/recovery workshop@<RECOVERY-WORKSHOP>:/project$ mkdir /project/workshop-recovery workshop@<RECOVERY-WORKSHOP>:/project$ cp -a /mnt/recovery/home/workshop/<PATH> /project/workshop-recovery/
Unmount the disk and detach it from the recovery VM:
workshop@<RECOVERY-WORKSHOP>:/project$ sudo umount /mnt/recovery workshop@<RECOVERY-WORKSHOP>:/project$ exit $ lxc config device remove --project workshop.<USERNAME> <RECOVERY-INSTANCE> recovery
The recovered files are in
~/vm-recovery/workshop-recovery/on the host.
Standard removal procedure¶
The primary command for removing a workshop is:
$ workshop remove <WORKSHOP>
This command is designed to:
Stop the workshop if it is running.
Delete the underlying LXD container.
Remove associated workshop data and cache directories.
Clean up related LXD profiles and remove device mounts.
Always attempt this command first. If it completes successfully, your workshop should be purged. You can verify the outcome by running workshop list.
If standard procedure fails¶
You may need manual intervention if:
workshop remove fails with an error.
The workshop is still listed by workshop list or workshop list --global after a remove attempt.
The workshop’s project directory had been deleted before the workshop was removed, leaving the workshop orphaned.
The workshop is in an unrecoverable error state.
The workshop’s container is still running or in an error state, preventing the standard removal flow from completing.
For an orphaned workshop, first try removing it by its former project path, which doesn’t require touching LXD. In other cases, or if that fails, manually clean up the workshop’s resources, interacting directly with LXD and the workshop’s snap data; start by finding the LXD project.
Remove an orphaned workshop¶
If a project directory is deleted before its workshops are removed,
the workshops become orphaned:
their containers and stored state remain on the host,
and the daemon reports them in the Error state
with a missing-project note:
$ workshop list --global
PROJECT WORKSHOP STATUS NOTES
~/projects/nimble nimble Error missing-project
The daemon keeps tracking the project’s original location
until its last workshop is removed,
so you can remove the workshop
by passing that location to the --project option;
the directory doesn’t need to exist:
Remove the workshop, pointing at the project’s former path as shown in the
PROJECTcolumn:$ workshop remove --project ~/projects/nimble nimble
The path must be the project’s root directory; subdirectories of a deleted project aren’t recognized.
Verify the removal:
$ workshop list --global
Note
Find LXD project¶
Workshop creates LXD projects named workshop.<USERNAME>,
where <USERNAME> is your system username.
If the username can’t be used in an LXD project name
(e.g. if it contains special characters such as @),
your numeric user ID is used instead (id -u).
You’ll also need your username for some paths.
Clean up LXD resources¶
Refer to the Explore LXD containers section in the troubleshooting guide for initial steps on listing and deleting orphaned LXD containers, e.g.:
$ sudo lxc list --all-projects | grep workshop.<USERNAME>
$ sudo lxc delete --project workshop.<USERNAME> <CONTAINER> --force
To ensure there are no backup copies of the workshop remaining,
check the workshop-snapshots.<USERNAME> project as well:
$ sudo lxc list --all-projects | grep workshop-snapshots.<USERNAME>
$ sudo lxc delete --project workshop-snapshots.<USERNAME> <CONTAINER> --force
In addition to containers, you may need to clean up associated LXD profiles.
LXD profiles¶
Workshops create an LXD profile for each SDK they use.
These profiles are named <CONTAINER>-<SDK>.
If a workshop container wasn’t cleanly removed,
its profiles might remain.
List profiles for your workshop user project:
$ sudo lxc profile list --project workshop.<USERNAME>
Inspect a specific profile:
$ sudo lxc profile show --project workshop.<USERNAME> <PROFILE>
Delete an orphaned profile. To ensure it’s not in use by other valid workshops, list all containers in the project firstly:
$ sudo lxc list --project workshop.<USERNAME>
Then, for each container that should remain, check its configuration to see which profiles it uses:
$ sudo lxc config show --project workshop.<USERNAME> <CONTAINER>
Look for the
profileskey in the output.If the
<PROFILE>you intend to delete is not listed for any relevant containers, it should be safe to remove:$ sudo lxc profile delete --project workshop.<USERNAME> <PROFILE>
To delete an orphaned profile, check the
USED BYcolumn in the output of the lxc profile list command. If the count is zero, the profile is not used by any containers and can be safely removed.
Remove leftover host directories¶
Deleting containers with lxc doesn’t remove the state
that Workshop stores for them on the host.
This state is keyed by project ID,
which is the final dash-separated segment of the container name;
for example, ec275767 for a container named nimble-ec275767.
Check these locations for leftover directories, removing them if present:
$ rm -rf ~/.local/share/workshop/id/<PROJECT-ID>
$ sudo rm -rf /var/snap/workshop/current/id/<PROJECT-ID>
$ sudo rm -rf /var/snap/workshop/common/workshop/cache/id/<PROJECT-ID>
Aggressive cleanup¶
If previous steps haven’t resolved the issue,
or if workshop list still shows remnants,
the most aggressive cleanup method is to completely purge the Workshop snap.
This executes the snap’s remove hook,
which is designed to clean up all associated data and resources.
To purge the snap and all its data, run the following command:
$ sudo snap remove workshop --purge
This will remove all workshop configurations, containers, LXD profiles, and storage pools managed by Workshop.
After the command completes, you can reinstall the snap.
Warning
Final checks¶
After performing manual cleanup steps:
Run workshop list --global to check if the malfunctioning workshop is no longer listed.
Run sudo lxc list --all-projects to ensure no unexpected LXD resources remain.
If issues persist, consider seeking community support, or reporting a bug with detailed logs and steps taken: Project and community.
See also¶
Explanation:
How-to guides:
Reference: