357 字
2 分钟
Ubuntu 优化
2023-02-03

cloud-init#

二选一,禁用或移除。

禁用#

sudo touch /etc/cloud/cloud-init.disabled

删除该文件就可以恢复。

移除#

sudo apt purge cloud-init -y
sudo rm -rf /etc/cloud && sudo rm -rf /var/lib/cloud/

snap#

原文链接

删除#

删掉所有的已经安装的 Snap 软件。#

snap list 用于查看已经安装的 Snap 软件,通过脚本全部删除:

for p in $(snap list | awk '{print $1}'); do
  sudo snap remove $p
done

一般需要执行两次(桌面版三次),提示如下则正确执行:

snap "Name" is not installed
core20 removed
snapd removed

再次执行,提示如下,表明已经删除干净:

No snaps are installed yet. Try 'snap install hello-world'.

删除 Snap 的 Core 文件。#

sudo systemctl stop snapd
sudo systemctl disable --now snapd.socket

for m in /snap/core/*; do
   sudo umount $m
done

删除 Snap 的管理工具。#

sudo apt autoremove --purge snapd

删除 Snap 的目录。#

rm -rf ~/snap
sudo rm -rf /snap
sudo rm -rf /var/snap
sudo rm -rf /var/lib/snapd
sudo rm -rf /var/cache/snapd

配置 APT 参数:禁止 apt 安装 snapd。#

正确配置(参看 apt_preferences):

sudo sh -c "cat > /etc/apt/preferences.d/no-snapd.pref" << EOL
Package: snapd
Pin: release a=*
Pin-Priority: -10
EOL
a -> Archive
c -> Component
o -> Origin
l -> Label
n -> Architecture

验证效果:可以查询到该包,但是无法安装。

$ apt list snapd
Listing... Done
snapd/jammy-updates 2.56.2+22.04ubuntu1 amd64
N: There is 1 additional version. Please use the '-a' switch to see it

$ sudo apt install snapd
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package snapd is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'snapd' has no installation candidate
Ubuntu 优化
https://blog.lpkt.cn/posts/ubuntu-opt/
作者
lollipopkit
发布于
2023-02-03
许可协议
CC BY-NC-SA 4.0