使用 Ubuntu Server 16.04 禁用 LXD 的默认安装

使用 Ubuntu Server 16.04 禁用 LXD 的默认安装

自 Ubuntu 16.04 起,LXD 已成为 ubuntu-server 元包中的依赖项。因此升级和新安装都将安装 LXD。

这是一个非常烦人的行为。有什么办法可以禁用此行为吗?并非每台生产机器都需要启动容器服务。

答案1

lxd推荐ubuntu-server

root@c7:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04 LTS
Release:    16.04
Codename:   xenial

root@c7:~# apt-cache depends ubuntu-server|grep lxd
  Recommends: lxd

root@c7:~# apt-cache depends ubuntu-server|grep Recommends
  Recommends: lxd
  Recommends: snapd

您可以使用

apt install --no-install-recommends ubuntu-server

避免安装lxdsnapd

apt remove --purge lxd snapd

删除这些而不删除 ubuntu-server

root@c7:~# apt remove --purge lxd snapd
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  lxd* snapd*
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 37.4 MB disk space will be freed.
Do you want to continue? [Y/n] 
(Reading database ... 25405 files and directories currently installed.)
Removing lxd (2.0.0-0ubuntu4) ...
Warning: Stopping lxd.service, but it can still be activated by:
  lxd.socket
Purging configuration files for lxd (2.0.0-0ubuntu4) ...
Failed to stop lxd.service: Unit lxd.service not loaded.
dpkg: warning: while removing lxd, directory '/var/lib/lxd' not empty so not removed
Removing snapd (2.0.3) ...
Purging configuration files for snapd (2.0.3) ...
Processing triggers for man-db (2.7.5-1) ...

答案2

我认为您只是想禁用相关服务,而不是卸载它们。由于它们只是另一种服务,我们可以使用 systemctl 禁用它们

sudo systemctl disable lxd
sudo systemctl disable snapd

如果有一天你想开始它们。

sudo systemctl start lxd
sudo systemctl start snapd

就这么简单。

相关内容