VPSをいくつか契約しています。システムのアップグレードは手動で行っています。
でも数日PCに触れないことなんかもあり最近の情勢からすると不安。ということでシステムの自動アップグレードを設定しました。
今回の対象はDebian trixie amd64環境。これまではapticronを動かしてパッケージの更新とダウンロードは自動化していました。
以前はcron-aptを使っていましたが、今回 unattended-upgradesを試してみました.
unattended-upgrades を導入
aptでunattended-upgradesを導入して設定します。
$ sudo apt install unattended-upgrades (1) $ sudo dpkg-reconfigure unattended-upgrades (2) Package configuration ┌───────────────────┤ Configuring unattended-upgrades ├───────────────────┐ │ │ │ Applying updates on a frequent basis is an important part of keeping │ │ systems secure. By default, updates need to be applied manually using │ │ package management tools. Alternatively, you can choose to have this │ │ system automatically download and install important updates. │ │ │ │ Automatically download and install stable updates? │ │ │ │ <Yes> <No> │ │ │ └─────────────────────────────────────────────────────────────────────────┘ Replacing config file /etc/apt/apt.conf.d/20auto-upgrades with new version $ cat /etc/apt/apt.conf.d/20auto-upgrades APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1";
unattended-upgradesパッケージを導入
dpkg-reconfigure で
<Yes>を選択

メール通知を有効にする
$ sudo vi /etc/apt/apt.conf.d/50unattended-upgrades
$ sudo git -C /etc diff /etc/apt/apt.conf.d/50unattended-upgrades
diff --git a/apt/apt.conf.d/50unattended-upgrades b/apt/apt.conf.d/50unattended-upgrades
index 26f84e133..007af9182 100644
--- a/apt/apt.conf.d/50unattended-upgrades
+++ b/apt/apt.conf.d/50unattended-upgrades
@@ -92,13 +92,13 @@ Unattended-Upgrade::Package-Blacklist {
// If empty or unset then no email is sent, make sure that you
// have a working mail setup on your system. A package that provides
// 'mailx' must be installed. E.g. "user@example.com"
-//Unattended-Upgrade::Mail "";
+Unattended-Upgrade::Mail "user@example.com"; (1)
// Set this value to one of:
// "always", "only-on-error" or "on-change"
// If this is not set, then any legacy MailOnlyOnError (boolean) value
// is used to chose between "only-on-error" and "on-change"
-//Unattended-Upgrade::MailReport "on-change";
+Unattended-Upgrade::MailReport "always"; (2)
// Remove unused automatically installed kernel-related packages
// (kernel images, kernel headers and kernel version locked tools).
$ sudo unattended-upgrade --dry-run --debug (3)
$ sudo unattended-upgrade --debug通知を送るメールアドレス
実行舞に通知。しばらく動かしたら
on-changeに変更予定動作確認
$ sudo apt remove apticron
しばらく動かして見て問題なければ別のVPSにも反映しようと思います。
環境
$ dpkg-query -W unattended-upgrades unattended-upgrades 2.12 $ lsb_release -dr Description: Debian GNU/Linux 13 (trixie) Release: 13 $ arch x86_64
追記
数日動かして今のところいい感じ。と思ったらKernel updateで再起動が必要になりこれどうしようになっています。live patch……?
というだけじゃあれなので、届いたメールを貼っておきます。
今のところ正常パターンしかないのですが、再起動が必要なときにはSubjectに `[reboot required] ` が付くようです。
実行時のメール
Subject: unattended-upgrades result for example.com: SUCCESS
From: root@example.comUnattended upgrade result: No packages found that can be upgraded
unattended and no pending auto-removalsUnattended-upgrades log:
Checking if system is running on battery is skipped. Please install powermg=
mt-base package to check power status and skip installing updates when the =
system is running on battery.
Starting unattended upgrades script
Allowed origins are: origin=3DDebian,codename=3Dtrixie,label=3DDebian, orig=
in=3DDebian,codename=3Dtrixie,label=3DDebian-Security, origin=3DDebian,code=
name=3Dtrixie-security,label=3DDebian-Security
Initial blacklist:=20
Initial whitelist (not strict):=20
No packages found that can be upgraded unattended and no pending auto-remov=
als
Subject: unattended-upgrades result for example.com: SUCCESS
From: root@example.comUnattended upgrade result: All upgrades installed
Warning: A reboot is required to complete this upgrade, or a previous one.
Packages that were upgraded:
libnss3 vim vim-common vim-runtime vim-tiny xxdPackage installation log:
Log started: 2026-11-02 06:50:53
apt-listchanges: Reading changelogs…
apt-listchanges: Reading changelogs…
Preparing to unpack …/vim_2%3a9.1.1230-2+deb13u1_amd64.deb …
Unpacking vim (2:9.1.1230-2+deb13u1) over (2:9.1.1230-2) …
Preparing to unpack …/vim-common_2%3a9.1.1230-2+deb13u1_all.deb …
Unpacking vim-common (2:9.1.1230-2+deb13u1) over (2:9.1.1230-2) …
Preparing to unpack …/vim-tiny_2%3a9.1.1230-2+deb13u1_amd64.deb …
Unpacking vim-tiny (2:9.1.1230-2+deb13u1) over (2:9.1.1230-2) …
Preparing to unpack …/vim-runtime_2%3a9.1.1230-2+deb13u1_all.deb …
Unpacking vim-runtime (2:9.1.1230-2+deb13u1) over (2:9.1.1230-2) …
Preparing to unpack …/xxd_2%3a9.1.1230-2+deb13u1_amd64.deb …
Unpacking xxd (2:9.1.1230-2+deb13u1) over (2:9.1.1230-2) …
Setting up xxd (2:9.1.1230-2+deb13u1) …
Setting up vim-common (2:9.1.1230-2+deb13u1) …
Setting up vim-runtime (2:9.1.1230-2+deb13u1) …
Setting up vim (2:9.1.1230-2+deb13u1) …
Setting up vim-tiny (2:9.1.1230-2+deb13u1) …
Processing triggers for mailcap (3.74) …
Processing triggers for hicolor-icon-theme (0.18-2) …
Processing triggers for man-db (2.13.1-1) …
Log ended: 2026-11-02 06:51:09Log started: 2026-11-02 06:51:11
apt-listchanges: Reading changelogs…
apt-listchanges: Reading changelogs…
Preparing to unpack …/libnss3_2%3a3.110-1+deb13u5_amd64.deb …
Unpacking libnss3:amd64 (2:3.110-1+deb13u5) over (2:3.110-1+deb13u4) …
Setting up libnss3:amd64 (2:3.110-1+deb13u5) …
Processing triggers for libc-bin (2.41-12+deb13u4) …
Log ended: 2026-11-02 06:51:17Unattended-upgrades log:
Checking if system is running on battery is skipped. Please install powermgmt-base package to check power status and skip installing updates when the system is running on battery.
Starting unattended upgrades script
Allowed origins are: origin=Debian,codename=trixie,label=Debian, origin=Debian,codename=trixie,label=Debian-Security, origin=Debian,codename=trixie-security,label=Debian-Security
Initial blacklist:
Initial whitelist (not strict):
Packages that will be upgraded: libnss3 vim vim-common vim-runtime vim-tiny xxd
Writing dpkg log to /var/log/unattended-upgrades/unattended-upgrades-dpkg.log
All upgrades installed
Subject: [reboot required] unattended-upgrades result for example.com: SUCCESS
From: root@example.comUnattended upgrade result: All upgrades installed
Warning: A reboot is required to complete this upgrade, or a previous one.
Packages that were upgraded:
linux-image-amd64 linux-libc-devPackages that were auto-removed:
linux-image-6.12.113+deb13-amd64Package installation log:
Log started: 2026-11-03 06:16:00
apt-listchanges: Reading changelogs…
apt-listchanges: Reading changelogs…
Selecting previously unselected package linux-image-6.12.115+deb13.1-amd64.
Preparing to unpack …/linux-image-6.12.115+deb13.1-amd64_6.12.115-2_amd64=
.deb …
Unpacking linux-image-6.12.115+deb13.1-amd64 (6.12.115-2) …
Preparing to unpack …/linux-image-amd64_6.12.115-2_amd64.deb …
Unpacking linux-image-amd64 (6.12.115-2) over (6.12.113-1) …
Setting up linux-image-6.12.115+deb13.1-amd64 (6.12.115-2) …
I: /vmlinuz.old is now a symlink to boot/vmlinuz-6.12.113+deb13-amd64
I: /initrd.img.old is now a symlink to boot/initrd.img-6.12.113+deb13-amd64
I: /vmlinuz is now a symlink to boot/vmlinuz-6.12.115+deb13.1-amd64
I: /initrd.img is now a symlink to boot/initrd.img-6.12.115+deb13.1-amd64
/etc/kernel/postinst.d/dkms:
dkms: WARNING: Linux headers are missing, which may explain the above failu=
res.
please install the linux-headers-6.12.115+deb13.1-amd64 package to fi=
x this.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-6.12.115+deb13.1-amd64
/etc/kernel/postinst.d/zz-update-grub:
Generating grub configuration file …
Found linux image: /boot/vmlinuz-6.12.115+deb13.1-amd64
Found initrd image: /boot/initrd.img-6.12.115+deb13.1-amd64
Found linux image: /boot/vmlinuz-6.12.113+deb13-amd64
Found initrd image: /boot/initrd.img-6.12.113+deb13-amd64
Found linux image: /boot/vmlinuz-6.1.0-42-amd64
Found initrd image: /boot/initrd.img-6.1.0-42-amd64
Warning: os-prober will not be executed to detect other bootable partitions=
.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings …
done
Setting up linux-image-amd64 (6.12.115-2) …
Log ended: 2026-11-03 06:16:35Log started: 2026-11-03 06:16:37
apt-listchanges: Reading changelogs…
apt-listchanges: Reading changelogs…
Preparing to unpack …/linux-libc-dev_6.12.115-2_all.deb …
Unpacking linux-libc-dev (6.12.115-2) over (6.12.113-1) …
Setting up linux-libc-dev (6.12.115-2) …
Log ended: 2026-11-03 06:16:43Log started: 2026-11-03 06:16:45
Removing linux-image-6.12.113+deb13-amd64 (6.12.113-1) …
I: /vmlinuz.old is now a symlink to boot/vmlinuz-6.1.0-42-amd64
I: /initrd.img.old is now a symlink to boot/initrd.img-6.1.0-42-amd64
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-6.12.113+deb13-amd64
/etc/kernel/postrm.d/zz-update-grub:
Generating grub configuration file …
Found linux image: /boot/vmlinuz-6.12.115+deb13.1-amd64
Found initrd image: /boot/initrd.img-6.12.115+deb13.1-amd64
Found linux image: /boot/vmlinuz-6.1.0-42-amd64
Found initrd image: /boot/initrd.img-6.1.0-42-amd64
Warning: os-prober will not be executed to detect other bootable partitions=
.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings …
done
Log ended: 2026-11-03 06:16:51Unattended-upgrades log:
Checking if system is running on battery is skipped. Please install powermg=
mt-base package to check power status and skip installing updates when the =
system is running on battery.
Starting unattended upgrades script
Allowed origins are: origin=3DDebian,codename=3Dtrixie,label=3DDebian, orig=
in=3DDebian,codename=3Dtrixie,label=3DDebian-Security, origin=3DDebian,code=
name=3Dtrixie-security,label=3DDebian-Security
Initial blacklist:=20
Initial whitelist (not strict):=20
Packages that will be upgraded: linux-image-amd64 linux-libc-dev
Writing dpkg log to /var/log/unattended-upgrades/unattended-upgrades-dpkg.l=
og
All upgrades installed
Packages that were successfully auto-removed: linux-image-6.12.113+deb13-am=
d64
Packages that are kept back:=20
タイマー
[Unit] Description=Daily apt download activities [Timer] OnCalendar=*-*-* 6,18:00 RandomizedDelaySec=12h Persistent=true [Install] WantedBy=timers.target
[Unit] Description=Daily apt upgrade and clean activities After=apt-daily.timer [Timer] OnCalendar=*-*-* 6:00 RandomizedDelaySec=60m Persistent=true [Install] WantedBy=timers.target
Reposts