You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu Jammy离线自动安装ISO定制后安装器崩溃,APT配置未生效求助

Ubuntu Jammy离线自动安装ISO定制后安装器崩溃,APT配置未生效求助

看起来你在定制Ubuntu Jammy的离线自动安装ISO时碰到了棘手的问题——安装器因为APT的GPG密钥验证失败崩溃,而且你尝试添加的APT配置完全没起作用,我来帮你梳理几个可能的解决方向:

一、先搞懂为什么你之前的APT配置没生效

你添加的AllowUnauthenticated配置没生效,大概率是因为时机不对:subiquity在执行apt-get update的阶段,可能还没加载到你在autoinstall里定义的APT全局配置,或者这个配置是针对安装完成后的系统,而非安装过程中使用的临时环境。

二、几个可行的解决办法

1. 用early-commands提前强制禁用APT验证(快速临时方案)

直接在autoinstall的early-commands里修改目标系统的APT配置,让后续的apt操作跳过验证。把这段加到你的autoinstall配置里:

early-commands:
  # 禁用APT仓库安全性验证(目标系统)
  - echo 'Acquire::AllowInsecureRepositories "true";' > /target/etc/apt/apt.conf.d/99allow-unauth
  - echo 'Acquire::AllowDowngradeToInsecureRepositories "true";' >> /target/etc/apt/apt.conf.d/99allow-unauth
  # 给当前live环境也加一份,避免安装过程中调用apt出错
  - echo 'Acquire::AllowInsecureRepositories "true";' > /etc/apt/apt.conf.d/99allow-unauth

这种方式能在安装流程最早期就生效,覆盖subiquity后续的apt操作。

2. 修正autoinstall的APT配置写法(更规范的配置方式)

有些版本的curtin(autoinstall底层工具)支持直接设置allow_unauthenticated布尔值,比写APT conf更直接,试试把你的apt配置改成这样:

apt:
  allow_unauthenticated: true
  conf: |
    APT {
      Get {
        AllowUnauthenticated "true";
      };
    };

直接声明allow_unauthenticated: true会让curtin在调用apt命令时自动加上--allow-unauthenticated参数,可能比纯配置文件更可靠。

3. 提前导入缺失的GPG密钥(最合规的长期方案)

禁用验证毕竟是临时手段,更稳妥的做法是把缺失的GPG密钥提前导入到定制的ISO里:

  • 先在本地获取密钥:gpg --keyserver keyserver.ubuntu.com --recv-keys XYZ(把XYZ换成你碰到的NO_PUBKEY后面的密钥ID)
  • 导出密钥文件:gpg --export XYZ > my-key.gpg
  • 把这个密钥文件放到你定制的ISO的合适位置(比如live系统的/root目录)
  • 然后在autoinstall的early-commands里添加导入命令:
    early-commands:
      - apt-key add /root/my-key.gpg
      # 同时导入到目标系统
      - cp /root/my-key.gpg /target/root/
      - chroot /target apt-key add /root/my-key.gpg
    

这样安装过程中apt就能正常验证仓库签名,不用禁用安全校验。

最后再提个小建议

如果你的ISO是离线定制的,最好检查下里面的sources.list是不是指向了离线仓库,有时候密钥问题是因为仓库源被替换成了自定义的,但密钥没同步更新导致的。

备注:内容来源于stack exchange,提问作者Ani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 15:18:11