ubuntu 26.04 尝鲜 仅对于宿主机的调整

前言

  • 使用新一代长期支持版 ubuntu, 代替了原来的 unraid, 作为nas用

时区校准

1
timedatectl set-timezone Asia/Shanghai

SSH 安全增强

  • 禁止 Root 密码登录, 修改默认端口, 防止被暴力破解
  • 详情看博客 https://ssd.us.kg/2025/10/28/Ubuntu免密码root登录ssh的公私钥方案/

安装 docker 看官网

https://docs.docker.com/engine/install/ubuntu/

安装 portainer

https://docs.portainer.io/start/install-ce/server/docker/linux
/opt/containers/portainer/docker-compose.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
services:
portainer:
container_name: portainer
image: portainer/portainer-ce:sts
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
ports:
- 9443:9443
- 9000:9000
- 8000:8000 # Remove if you do not intend to use Edge Agents

volumes:
portainer_data:
name: portainer_data

networks:
default:
name: portainer_network

镜像源切换

/etc/apt/sources.list.d/ubuntu.sources

1
2
3
4
5
6
7
8
9
10
11
12
Types: deb
URIs: https://mirrors.aliyun.com/ubuntu/
Suites: resolute resolute-updates resolute-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

Types: deb
URIs: https://mirrors.aliyun.com/ubuntu/
Suites: resolute-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

/etc/apt/sources.list.d/docker.sources

1
2
3
4
5
6
7
Types: deb
URIs: https://mirrors.aliyun.com/docker-ce/linux/ubuntu
Suites: resolute
Components: stable
Architectures: amd64
Signed-By: /etc/apt/keyrings/docker.asc

电源管理(不间断电源)

1
apt install apcupsd

/etc/apcupsd/apcupsd.conf

1
2
3
UPSCABLE usb
UPSTYPE usb
DEVICE

/etc/apcupsd/apcupsd.conf

1
2
3
4
5
BATTERYLEVEL 20: 电量剩余 20% 时就关机(默认 5% 容易让电池过放)。

MINUTES 10: 预计续航还剩 10 分钟时就关机(默认 3 分钟对某些运行大量容器的 NAS 来说有点紧)。

TIMEOUT 300: 如果你想设置“断电 5 分钟后无论电量多少直接关机”, 就设置这个参数。设置为 0 则禁用。
1
2
3
4
5
6
# 重启服务
systemctl restart apcupsd
# 检查并开启自启
systemctl enable apcupsd
# 验证状态
systemctl status apcupsd

定期快照

  • swap 要单独分子卷
1
2
apt install snapper
snapper -c root create-config /

/etc/snapper/configs/root

1
2
3
4
5
6
7
8
9
# 限制保留“每小时”快照的数量
TIMELINE_LIMIT_HOURLY="10"
# 限制保留“每天”快照的数量
TIMELINE_LIMIT_DAILY="7"
# 限制保留“每月”快照的数量
TIMELINE_LIMIT_MONTHLY="0"

# 同时也建议开启空间配额清理(防止磁盘满)
EMPTY_PRE_POST_CLEANUP="yes"

其他

  • docker 只用 compose 方便迁移
  • 只用卷, 多用具名卷, 必要共享卷, 少用匿名卷

ubuntu 26.04 尝鲜 仅对于宿主机的调整
http://pure-white-ice-cream.github.io/2026/05/08/ubuntu 26.04 尝鲜 仅对于宿主机的调整/
作者
纯白色冰淇淋
发布于
2026年5月8日
许可协议