vm安装ubuntu后,update报错问题解决

vm安装ubuntu后,update报错问题解决

环境

  1. 使用镜像Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-91-generic x86_64)

  2. 使用虚拟机VMware WorkStation Pro 12

  3. 系统环境windows 10

出错时操作

  1. 初次安装完成后 立即执行sudo apt update 并正确输入root密码

  2. 回显信息如下

    Ign:1 cdrom://Ubuntu-Server 16.04.3 LTS _Xenial Xerus_ - Release amd64 (20170801) xenial InReleaseErr:2 cdrom://Ubuntu-Server 16.04.3 LTS _Xenial Xerus_ - Release amd64 (20170801) xenial Release Please use apt-cdrom to make this CD-ROM recognized by APT. apt-get update cannot be used to add new CD-ROMsHit:3 http://security.ubuntu.com/ubuntu xenial-security InReleaseHit:4 http://us.archive.ubuntu.com/ubuntu xenial InReleaseHit:5 http://us.archive.ubuntu.com/ubuntu xenial-updates InReleaseHit:6 http://us.archive.ubuntu.com/ubuntu xenial-backports InReleaseReading package lists... DoneE: The repository 'cdrom://Ubuntu-Server 16.04.3 LTS _Xenial Xerus_ - Release amd64 (20170801) xenial Release' does not have a Release file.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.

问题分析

由上述回显信息可以得知,apt update之后,命令首先访问cdrom,这个cdrom就是安装镜像时的光盘。在apt update命令执行时,命令将首先访问/etc/apt/sources.list文件,依次访问文件中列出的源,以更新信息,这时候,既然命令执行后显示访问的时cdrom,说明文件中第一个源项是本地的cdrom,但是其访问的cdrom实际并不存在(或者是名称不符,或者是安装完成后vm自动弹出该cdrom)导致命令无法获得源信息,因此报错

题解

  1. 用sudo权限和任意文本编辑器打开/etc/apt/sources.list文件
    这里我用vim打开 命令如下

    sudo vim /etc/apt/sources.list
  2. 然后使用#注释掉以 deb cdrom 打头的所有行(行首已有#的不需要再注释)
    我的文件中注释的是如下行

    # deb cdrom:[Ubuntu-Server 16.04.3 LTS _Xenial Xerus_ - Release amd64 (20170801)]/ xenial main restricted

    需要注意,实际情况中后半部分可能不同,但一定是deb cdrom打头 ,把这打头的所有行都注释准没错,但不建议直接删除,避免无法预知的错误出现后无法恢复

免责声明:本网信息来自于互联网,目的在于传递更多信息,并不代表本网赞同其观点。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,并请自行核实相关内容。本站不承担此类作品侵权行为的直接责任及连带责任。如若本网有任何内容侵犯您的权益,请及时联系我们,本站将会在24小时内处理完毕。
相关文章
返回顶部