问题描述
客户使用预置镜像创建开发机,能够正常执行apt-get update
命令更新下载源,但基于该开发机保存镜像后,再使用该镜像创建新开发机后,在新开发机中无法使用apt-get update
命令更新,出现如下所示报错:
root@di-2023042XXXXXX:/# sudo apt-get update
Get:1 http://mirrors.ivolces.com/ubuntu focal InRelease [265 kB]
Err:1 http://mirrors.ivolces.com/ubuntu focal InRelease
Couldn't create temporary file /tmp/apt.conf.y0pDXH for passing config to apt-key
Get:2 http://mirrors.ivolces.com/ubuntu focal-security InRelease [114 kB]
Err:2 http://mirrors.ivolces.com/ubuntu focal-security InRelease
Couldn't create temporary file /tmp/apt.conf.emazGJ for passing config to apt-key
Get:3 http://mirrors.ivolces.com/ubuntu focal-updates InRelease [114 kB]
Err:3 http://mirrors.ivolces.com/ubuntu focal-updates InRelease
Couldn't create temporary file /tmp/apt.conf.e330LP for passing config to apt-key
Get:4 http://mirrors.ivolces.com/ubuntu focal-proposed InRelease [267 kB]
Err:4 http://mirrors.ivolces.com/ubuntu focal-proposed InRelease
Couldn't create temporary file /tmp/apt.conf.6rJNyU for passing config to apt-key
Get:5 http://mirrors.ivolces.com/ubuntu focal-backports InRelease [108 kB]
Err:5 http://mirrors.ivolces.com/ubuntu focal-backports InRelease
Couldn't create temporary file /tmp/apt.conf.WcFxX0 for passing config to apt-key
Get:6 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64 InRelease [1581 B]
Err:6 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64 InRelease
Couldn't create temporary file /tmp/apt.conf.oBokD6 for passing config to apt-key
Reading package lists... Done
W: GPG error: http://mirrors.ivolces.com/ubuntu focal InRelease: Couldn't create temporary file /tmp/apt.conf.y0pDXH for passing config to apt-key
E: The repository 'http://mirrors.ivolces.com/ubuntu focal InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.ivolces.com/ubuntu focal-security InRelease: Couldn't create temporary file /tmp/apt.conf.emazGJ for passing co
问题分析
- 根据报错信息
Couldn't create temporary file /tmp/apt.conf.y0pDXH for passing config to apt-key
可以得知,在更新源时无法创建临时文件将配置信息传递给 apt-key 。 - apt-key、apt.conf 等实际上并不是直接使用
/etc/apt/apt.conf
配置文件。而是每次执行操作时将配置文件复制到临时文件夹下,以此来进行修改等操作。而/tmp
文件目录就是用来保存临时文件的目录。 - 怀疑执行子任务时,用户对保存临时文件的目录
/tmp
无操作权限。
问题解决
- 使用 webIDE 连接开发机。
- 执行
chmod 777 /tmp
命令添加全部权限。
- 验证执行
apt-get update
可成功更新。