Skip to Content
ドキュメント運用システム管理ソフトウェアソースとアップデート戦略

ソフトウェアソースとアップデート戦略

Warning

26.10: rc 状態の OpenSSH パッケージを一括パージしないでください。 置換パッケージはまだ古い構成を使用している可能性があり、パージすると SSH が壊れる可能性があります。 26.10 既知の問題 を確認し、リモート メンテナンスの前に回復アクセスを保持します。

ソフトウェア ソースを適切に構成し、適切な更新戦略を確立することは、システムのセキュリティと安定性にとって重要です。この記事では、Ubuntu 26.04 でソフトウェア ソースを構成する方法とさまざまな更新戦略について説明します。

ソフトウェアソースの基本

Ubuntu 26.04 ソース形式

Ubuntu 24.04 以降、APT ソース構成では新しい DEB822 形式が使用され、構成ファイルは /etc/apt/sources.list.d/ubuntu.sources にあります。

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

典型的な内容:

Types: deb deb-src URIs: http://archive.ubuntu.com/ubuntu Suites: resolute resolute-updates resolute-backports Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

ソースコンポーネントの説明

成分説明
mainCanonical によって正式にサポートされているオープンソース ソフトウェア
restricted公式サポート付きの独自ドライバー
universeコミュニティが管理するオープンソース ソフトウェア
multiverse著作権または法的制限によってソフトウェアが制限される

スイートの説明

スイート説明
resoluteベースリリースリポジトリ
resolute-updates推奨されるアップデート
resolute-backports新しいソフトウェア バージョンをバックポートしました
resolute-securityセキュリティアップデート

ミラーへの切り替え

# Back up the original configuration sudo cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak # Edit the source configuration sudo nano /etc/apt/sources.list.d/ubuntu.sources

URIs をミラーに置き換えます。

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

ミラーを選択するときは、地理的にもネットワーク的にも近いものを選択してください。学術ネットワーク ユーザーは清華または USTC ミラーを好む場合がありますが、クラウド サーバー ユーザーは最高の速度を得るためにプロバイダーの内部ミラーを使用する必要があります。

一般的なミラー:

鏡URL
アリババクラウドhttps://mirrors.aliyun.com/ubuntu
清華大学https://mirrors.tuna.tsinghua.edu.cn/ubuntu
USTChttps://mirrors.ustc.edu.cn/ubuntu
ファーウェイクラウドhttps://mirrors.huaweicloud.com/ubuntu
テンセントクラウドhttps://mirrors.cloud.tencent.com/ubuntu

切り替え後、インデックスを更新します。

sudo apt update
Warning

PPA はサードパーティが個人的に管理するソフトウェア ソースであり、そのパッケージは Canonical によってレビューされていません。信頼できない PPA を追加すると、セキュリティ リスクが生じたり、依存関係の競合が発生したりする可能性があります。既知のプロジェクトからの PPA のみを追加し、システム バージョンをアップグレードする前にすべての PPA を無効にしてください。

PPA管理

PPA (パーソナル パッケージ アーカイブ) を使用すると、サードパーティの開発者がソフトウェア パッケージを配布できます。

PPA の追加

# Add a PPA sudo add-apt-repository ppa:graphics-drivers/ppa # Update the index after adding sudo apt update # Install software from the PPA; choose the version reported by ubuntu-drivers devices sudo apt install nvidia-driver-XXX

PPA の削除

# Remove a PPA sudo add-apt-repository --remove ppa:graphics-drivers/ppa # Update the index sudo apt update

サードパーティのソースを手動で追加する

例として Docker 公式ソースを使用します。

# Download the GPG key curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg # Add the repository (DEB822 format) # Note: Docker's official repository may not yet publish the resolute suite. # If apt update reports a missing Release file, temporarily fall back to noble. sudo tee /etc/apt/sources.list.d/docker.sources << 'EOF' Types: deb URIs: https://download.docker.com/linux/ubuntu Suites: resolute Components: stable Signed-By: /usr/share/keyrings/docker-archive-keyring.gpg EOF # Update and install sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io

構成されたソースのリスト

# View all source files ls /etc/apt/sources.list.d/ # View all sources used by APT apt policy # Check which source a package comes from apt policy nginx

APT 更新管理

基本的な更新コマンド

# Update the package index sudo apt update # Upgrade installed packages sudo apt upgrade # Smart upgrade (may install or remove dependencies) sudo apt full-upgrade # View upgradable packages without actually upgrading apt list --upgradable # Upgrade a specific package sudo apt install --only-upgrade nginx

更新履歴の表示

# View APT operation history cat /var/log/apt/history.log # View compressed history logs zless /var/log/apt/history.log.1.gz # View dpkg operation log cat /var/log/dpkg.log

パッケージの固定

特定のパッケージが更新されないようにするには:

# Hold a package version sudo apt-mark hold package-name # Unhold a package sudo apt-mark unhold package-name # View all held packages apt-mark showhold

無人アップグレードの自動更新

インストールとアクティベーション

# Install (usually pre-installed on Ubuntu 26.04) sudo apt install unattended-upgrades # Enable automatic updates sudo dpkg-reconfigure -plow unattended-upgrades

自動更新の構成

メイン構成ファイルを編集します。

sudo nano /etc/apt/apt.conf.d/50unattended-upgrades

主要な構成オプション:

Unattended-Upgrade::Allowed-Origins { "${distro_id}:${distro_codename}"; "${distro_id}:${distro_codename}-security"; "${distro_id}:${distro_codename}-updates"; // "${distro_id}:${distro_codename}-proposed"; // "${distro_id}:${distro_codename}-backports"; }; // Blacklist packages from auto-updating Unattended-Upgrade::Package-Blacklist { "linux-image*"; "linux-headers*"; "nginx"; }; // Automatically remove no-longer-needed dependencies Unattended-Upgrade::Remove-Unused-Dependencies "true"; // Automatically remove no-longer-needed kernels Unattended-Upgrade::Remove-Unused-Kernel-Packages "true"; // Automatically reboot if necessary Unattended-Upgrade::Automatic-Reboot "true"; Unattended-Upgrade::Automatic-Reboot-Time "03:00"; // Email notifications Unattended-Upgrade::Mail "admin@example.com"; Unattended-Upgrade::MailReport "on-change";

更新頻度を構成します。

sudo nano /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1"; APT::Periodic::Download-Upgradeable-Packages "1"; APT::Periodic::AutocleanInterval "7";

自動更新のテスト

# Dry run (does not actually install) sudo unattended-upgrade --dry-run --debug # Run automatic updates immediately sudo unattended-upgrade -v # View automatic update logs cat /var/log/unattended-upgrades/unattended-upgrades.log

更新戦略の推奨事項

デスクトップユーザー

# Recommended: auto-install security updates, manually install feature updates # /etc/apt/apt.conf.d/20auto-upgrades APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1"; APT::Periodic::Download-Upgradeable-Packages "1"; APT::Periodic::AutocleanInterval "7";

定期的にアップデートを確認し、手動でインストールします。

sudo apt update && apt list --upgradable sudo apt upgrade

サーバー環境

運用サーバーの場合は、次のことをお勧めします。

  1. セキュリティ更新プログラムのみを自動インストールします。他の更新を手動で処理します。
  2. 計画的なアップデートのメンテナンス期間を設定します。
  3. 本番環境に適用する前に、ステージング環境でテストします。
  4. 電子メール通知を有効にして、更新情報を常に入手してください。
# Recommended server configuration # /etc/apt/apt.conf.d/50unattended-upgrades Unattended-Upgrade::Allowed-Origins { "${distro_id}:${distro_codename}-security"; }; Unattended-Upgrade::Automatic-Reboot "false"; Unattended-Upgrade::Mail "admin@example.com";

バージョンアップ

新しい Ubuntu バージョンへのアップグレード

# Ensure the current system is fully updated sudo apt update && sudo apt full-upgrade # Check if a new version is available do-release-upgrade -c # Perform the version upgrade sudo do-release-upgrade

アップデート後のクリーンアップ

# Clean the downloaded deb package cache sudo apt clean # Remove no-longer-needed dependencies sudo apt autoremove # Clean residual configuration files dpkg -l | awk '$1 == "rc" {print $2}'