Removed LXD but there is still a network bridge remains

In Ubuntu 20.04 LXD comes as a snap package.

I ran the following as root

snap remove --purge lxd
reboot now

After that ip addr still shows lxcbr0 present. Where does the bridge get created and how do I remove it?

lxcbr0 doesn’t come from LXD but from LXC.

You likely have a lxc-utils package installed too for some reason.

1 Like

There is more than just a bridge left after I “purged” LXD. The amount of leftovers reminds me the days I tried to uninstall programs in Windows. I ran a few searches and found really a lot. I understand that some references may not be possible to remove (e.g. group names, dpkg information, container data) others are definitely littering the disk.

$ grep -r -m 3 'lx[cd]' /etc
/etc/init.d/lxcfs:# Provides:             lxcfs
/etc/init.d/lxcfs:DAEMON=/usr/bin/lxcfs
/etc/init.d/lxcfs:NAME=lxcfs
/etc/dnsmasq.d-available/lxc:# WARNING: changes to this file will get lost if lxc is removed.
/etc/dnsmasq.d-available/lxc:except-interface=lxcbr0
/etc/default/lxc-net:# This file is auto-generated by lxc.postinst if it does not
/etc/default/lxc-net:# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your
/etc/default/lxc-net:# If you change the LXC_BRIDGE to something other than lxcbr0, then
/etc/default/libvirt-guests:# example: URIS='default xen:///system vbox+tcp://host/system lxc:///system'
/etc/default/lxc:USE_LXC_BRIDGE="false"  # overridden in lxc-net
/etc/default/lxc:[ ! -f /etc/default/lxc-net ] || . /etc/default/lxc-net
/etc/apparmor.d/lxc-containers:# listed under /etc/apparmor.d/lxc get loaded at boot.  Please do
/etc/apparmor.d/lxc-containers:#include <lxc>
/etc/apparmor.d/usr.lib.snapd.snap-confine.real:    # silence noisy denials breaks nested lxd. Until the cause is determined,
/etc/apparmor.d/abstractions/libvirt-lxc:  # generated by: lxc-generate-aa-rules.py container-rules.base
/etc/apparmor.d/abstractions/lxc/start-container:  mount -> /usr/lib*/*/lxc/{**,},
/etc/apparmor.d/abstractions/lxc/start-container:  mount -> /usr/lib*/lxc/{**,},
/etc/apparmor.d/abstractions/lxc/start-container:  mount -> /usr/lib/x86_64-linux-gnu/lxc/{,**},
/etc/apparmor.d/abstractions/lxc/container-base:  #   signal (receive) peer=/usr/bin/lxc-start,
/etc/apparmor.d/abstractions/lxc/container-base:  mount options=(rw,bind) /dev/.lxc?*{,/**},
/etc/apparmor.d/abstractions/lxc/container-base:  mount options=(rw,move) /dev/.lxc?*{,/**},
/etc/apparmor.d/libvirt/TEMPLATE.lxc:  #include <abstractions/libvirt-lxc>
/etc/apparmor.d/lxc/lxc-default-with-mounting:# Do not load this file.  Rather, load /etc/apparmor.d/lxc-containers, which
/etc/apparmor.d/lxc/lxc-default-with-mounting:# will source all profiles under /etc/apparmor.d/lxc
/etc/apparmor.d/lxc/lxc-default-with-mounting:profile lxc-container-default-with-mounting flags=(attach_disconnected,mediate_deleted) {
/etc/apparmor.d/lxc/lxc-default:# Do not load this file.  Rather, load /etc/apparmor.d/lxc-containers, which
/etc/apparmor.d/lxc/lxc-default:# will source all profiles under /etc/apparmor.d/lxc
/etc/apparmor.d/lxc/lxc-default:profile lxc-container-default flags=(attach_disconnected,mediate_deleted) {
/etc/apparmor.d/lxc/lxc-default-with-nesting:# Do not load this file.  Rather, load /etc/apparmor.d/lxc-containers, which
/etc/apparmor.d/lxc/lxc-default-with-nesting:# will source all profiles under /etc/apparmor.d/lxc
/etc/apparmor.d/lxc/lxc-default-with-nesting:profile lxc-container-default-with-nesting flags=(attach_disconnected,mediate_deleted) {
/etc/apparmor.d/lxc/lxc-default-cgns:# Do not load this file.  Rather, load /etc/apparmor.d/lxc-containers, which
/etc/apparmor.d/lxc/lxc-default-cgns:# will source all profiles under /etc/apparmor.d/lxc
/etc/apparmor.d/lxc/lxc-default-cgns:profile lxc-container-default-cgns flags=(attach_disconnected,mediate_deleted) {
/etc/apparmor.d/usr.bin.lxc-start:/usr/bin/lxc-start flags=(attach_disconnected) {
/etc/apparmor.d/usr.bin.lxc-start:  #include <abstractions/lxc/start-container>
/etc/libvirt/lxc.conf:# By default, log messages generated by the lxc controller go to the
/etc/libvirt/lxc.conf:# from all lxc controllers along with libvirtd's log outputs. In this
/etc/libvirt/lxc.conf:# case, the lxc controller will honor either LIBVIRT_LOG_OUTPUTS or
/etc/gshadow-:lxd:!::yc
/etc/gshadow-:lxc-dnsmasq:!::
/etc/lxc/default.conf:lxc.net.0.type = veth
/etc/lxc/default.conf:lxc.net.0.link = lxcbr0
/etc/lxc/default.conf:lxc.net.0.flags = up
/etc/cloud/cloud.cfg: - lxd
/etc/cloud/cloud.cfg:     groups: [adm, audio, cdrom, dialout, dip, floppy, lxd, netdev, plugdev, sudo, video]
/etc/logrotate.d/libvirtd.lxc:/var/log/libvirt/lxc/*.log {


$ find /var/ -iname '*lx[cd]*'
/var/cache/lxc
/var/cache/apparmor/26b63962.0/lxc-containers
/var/cache/apparmor/26b63962.0/usr.bin.lxc-start
/var/log/libvirt/lxc
/var/log/lxc
/var/lib/misc/dnsmasq.lxcbr0.leases
/var/lib/lxc
/var/lib/snapd/seed/snaps/lxd_14804.snap
/var/lib/snapd/seed/assertions/lxd_14804.assert
/var/lib/snapd/sequence/lxd.json
/var/lib/cloud/instances/82a6dc93-bcf1-4d84-84ac-a2602376ad36/sem/config_lxd
/var/lib/systemd/deb-systemd-helper-enabled/lxd-agent.service.dsh-also
/var/lib/systemd/deb-systemd-helper-enabled/lxc-net.service.dsh-also
/var/lib/systemd/deb-systemd-helper-enabled/lxcfs.service.dsh-also
/var/lib/systemd/deb-systemd-helper-enabled/lxc.service.dsh-also
/var/lib/systemd/deb-systemd-helper-enabled/multi-user.target.wants/lxc-net.service
/var/lib/systemd/deb-systemd-helper-enabled/multi-user.target.wants/lxcfs.service
/var/lib/systemd/deb-systemd-helper-enabled/multi-user.target.wants/lxd-agent-9p.service
/var/lib/systemd/deb-systemd-helper-enabled/multi-user.target.wants/lxc.service
/var/lib/systemd/deb-systemd-helper-enabled/multi-user.target.wants/lxd-agent.service
/var/lib/systemd/deb-systemd-helper-enabled/lxd-agent-9p.service.dsh-also
/var/lib/lxcfs


$ find /lib/ -iname '*lx[cd]*'
/lib/x86_64-linux-gnu/libvirt-lxc.so.0
/lib/x86_64-linux-gnu/gstreamer-1.0/libgstflxdec.so
/lib/x86_64-linux-gnu/liblxc.so.1
/lib/x86_64-linux-gnu/liblxc.so.1.7.0
/lib/x86_64-linux-gnu/lxc
/lib/x86_64-linux-gnu/lxc/lxc-containers
/lib/x86_64-linux-gnu/lxc/lxc-net
/lib/x86_64-linux-gnu/lxc/lxc-monitord
/lib/x86_64-linux-gnu/lxc/lxc-user-nic
/lib/x86_64-linux-gnu/lxc/lxc-apparmor-load
/lib/x86_64-linux-gnu/libvirt-lxc.so.0.6000.0
/lib/x86_64-linux-gnu/lxcfs
/lib/x86_64-linux-gnu/lxcfs/liblxcfs.so
/lib/libvirt/libvirt_lxc
/lib/python3/dist-packages/libvirtmod_lxc.cpython-38-x86_64-linux-gnu.so
/lib/python3/dist-packages/libvirt_lxc.py
/lib/python3/dist-packages/cloudinit/config/cc_lxd.py
/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_lxd.cpython-38.pyc
/lib/python3/dist-packages/__pycache__/libvirt_lxc.cpython-38.pyc
/lib/systemd/system/lxc-net.service
/lib/systemd/system/lxcfs.service
/lib/systemd/system/lxd-agent-9p.service
/lib/systemd/system/lxc@.service
/lib/systemd/system/lxc.service
/lib/systemd/system/lxd-agent.service
/lib/modules/5.4.0-37-generic/kernel/drivers/leds/leds-mlxcpld.ko
/lib/modules/5.4.0-37-generic/kernel/drivers/i2c/muxes/i2c-mux-mlxcpld.ko
/lib/modules/5.4.0-37-generic/kernel/drivers/i2c/busses/i2c-mlxcpld.ko
/lib/modules/5.4.0-33-generic/kernel/drivers/leds/leds-mlxcpld.ko
/lib/modules/5.4.0-33-generic/kernel/drivers/i2c/muxes/i2c-mux-mlxcpld.ko
/lib/modules/5.4.0-33-generic/kernel/drivers/i2c/busses/i2c-mlxcpld.ko

None of those files come from LXD.

The LXD snap is just snap remove lxd and nothing will be left behind.

The stuff you list above comes from traditional LXC which is what you’d get if you installed lxc-utils or lxc.

Doing apt remove --purge liblxc1 lxcfs is usually enough to pull the entire dependency chain and get them all out.

1 Like

Thank you for the prompt response!! You are correct. That package (for some reason) was indeed installed. Turns out I blamed LXD for no reason.

I wonder if any of the packages I have installed (circled on the screenshot) are needed to run and administer LXD should I reinstall LXD snap?

Nope, all that you need to manage and run LXD is the LXD snap itself, all of those other packages just cause confusion at this point :slight_smile:

1 Like