AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-217892

user2315094's questions

Martin Hope
user2315094
Asked: 2020-04-05 00:55:56 +0800 CST

Ubuntu 18.04.4 桌面:自上次升级以来:使用以前的网络配置文件进行有线非托管

  • 3

昨晚我为 Ubuntu 18.04.4 Desktop 进行了请求的软件包升级。但是现在我无法再使用以前的网络配置文件连接到网络了。这些是升级的软件包:

在此处输入图像描述

这是NetworkManager.conf文件内容:

$ sudo nano /etc/NetworkManager/NetworkManager.conf

[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=false

[device]
wifi.scan-rand-mac-address=no     

遵循这些指示:无有线连接 - 有线非托管 ubuntu 18.04

我试图投入managed=true并/etc/NetworkManager/NetworkManager.conf 运行

sudo service network-manager restart

然后重新启动系统。
但问题仍然存在。

修改01-network-manager-all.yaml文件:

$ sudo nano /etc/netplan/01-network-manager-all.yaml
#Let NetworkManager manage all devices on this system
network:
  version: 2
  #renderer: networkd
  ethernets:
    enp3s0:
      dhcp4: no
      addresses: [192.168.1.7/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]

至

network:
  version: 2
  renderer: NetworkManager
  #renderer: networkd
  ethernets:
    enp3s0:
      dhcp4: trye
      #dhcp4: no
      #addresses: [192.168.1.7/24]
      #gateway4: 192.168.1.1
      #nameservers:
      #  addresses: [8.8.8.8,8.8.4.4]

使有线连接再次工作。

由于这次 Ubuntu 18.04 软件包升级,发生了什么?

networking upgrade wired 18.04 netplan
  • 3 个回答
  • 985 Views
Martin Hope
user2315094
Asked: 2019-10-31 01:25:53 +0800 CST

在 Ubuntu 18.04.02 服务器版中设置稳定的 Docker 引擎存储库期间:无法从“gi”导入名称“_gi”

  • 0

按照此处的指示:https : //docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-repository 我正在尝试在 Ubuntu 18.04.02 服务器版中安装 Docker 引擎。

第一次安装的步骤很顺利,但我遇到了这个错误消息:

(base) marco@pc:~$ sudo add-apt-repository \ 
> "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
> $(lsb_release -cs) \
> stable"
Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 11, in <module>
    from softwareproperties.SoftwareProperties import SoftwareProperties, 
shortcut_handler
  File "/usr/lib/python3/dist-packages/softwareproperties
/SoftwareProperties.py", line 67, in <module>
    from gi.repository import Gio
  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in 
<module>
    from . import _gi
ImportError: cannot import name '_gi' from 'gi' (/usr/lib/python3/dist-
packages/gi/__init__.py)

但是 python3 中的 import gi 工作正常:

(base) marco@pc:~$ python3
Python 3.7.3 (default, Mar 27 2019, 22:11:17) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> 

更新:

1) 将 /usr/bin/add-apt-repository 的第一行修改为 #!/usr/bin/python3.7.3

(base) marco@pc:~$ sudo add-apt-repository \
>    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
>    $(lsb_release -cs) \
>    stable"
sudo: unable to execute /usr/bin/add-apt-repository: No such file or 
directory

2)我按照此处找到的指示安装了 python 3.7.3:

https://linoxide.com/linux-how-to/install-python-ubuntu/在这里:https ://www.how2shout.com/how-to/install-python-on-ubuntu-19-04-18 -04-使用命令终端.html

(base) marco@pc:~$ ls -al /usr/bin | grep python
lrwxrwxrwx  1 root   root          26 Mar 26  2018 dh_pypy -> ../share/dh-
python/dh_pypy
-rwxr-xr-x  1 root   root        1056 Apr 16  2018 dh_python2
lrwxrwxrwx  1 root   root          29 Mar 26  2018 dh_python3 -> ../share
/dh-python/dh_python3
lrwxrwxrwx  1 root   root          23 Oct  7 19:39 pdb2.7 -> ../lib
/python2.7/pdb.py
lrwxrwxrwx  1 root   root          23 Oct  7 14:59 pdb3.6 -> ../lib
/python3.6/pdb.py
lrwxrwxrwx  1 root   root          23 Apr  3  2019 pdb3.7 -> ../lib
/python3.7/pdb.py
lrwxrwxrwx  1 root   root          31 Jul 30 19:24 py3versions -> ../share
/python3/py3versions.py
lrwxrwxrwx  1 root   root          26 Mar 26  2018 pybuild -> ../share/dh-
python/pybuild
lrwxrwxrwx  1 root   root           9 Apr 16  2018 python -> python2.7
lrwxrwxrwx  1 root   root          16 Apr 16  2018 python-config -> 
python2.7-config
lrwxrwxrwx  1 root   root           9 Apr 16  2018 python2 -> python2.7
lrwxrwxrwx  1 root   root          16 Apr 16  2018 python2-config -> 
python2.7-config
-rwxr-xr-x  1 root   root         399 Nov 15  2017 python2-jsonschema
-rwxr-xr-x  1 root   root         154 Nov 11  2017 python2-pbr
-rwxr-xr-x  1 root   root        5901 Jul 27  2017 python2-wsdump
-rwxr-xr-x  1 root   root     3641704 Oct  7 19:39 python2.7
lrwxrwxrwx  1 root   root          33 Oct  7 19:39 python2.7-config -> 
x86_64-linux-gnu-python2.7-config
lrwxrwxrwx  1 root   root          25 Aug 11 10:46 python3 -> 
/etc/alternatives/python3
lrwxrwxrwx  1 root   root          16 Oct 25  2018 python3-config -> 
python3.6-config
-rwxr-xr-x  1 root   root         384 Feb  5  2018 python3-futurize
-rwxr-xr-x  1 root   root         388 Feb  5  2018 python3-pasteurize
-rwxr-xr-x  1 root   root         152 Nov 11  2017 python3-pbr
-rwxr-xr-x  2 root   root     4526456 Oct  7 14:59 python3.6
lrwxrwxrwx  1 root   root          33 Oct  7 14:59 python3.6-config -> 
x86_64-linux-gnu-python3.6-config
-rwxr-xr-x  2 root   root     4526456 Oct  7 14:59 python3.6m
lrwxrwxrwx  1 root   root          34 Oct  7 14:59 python3.6m-config -> 
x86_64-linux-gnu-python3.6m-config
-rwxr-xr-x  2 root   root     4906512 Apr  3  2019 python3.7
-rwxr-xr-x  2 root   root     4906512 Apr  3  2019 python3.7m
lrwxrwxrwx  1 root   root          10 Jul 30 19:24 python3m -> python3.6m
lrwxrwxrwx  1 root   root          17 Oct 25  2018 python3m-config -> 
python3.6m-config
lrwxrwxrwx  1 root   root          29 Apr 16  2018 pyversions -> ../share
/python/pyversions.py
lrwxrwxrwx  1 root   root          33 Apr 16  2018 x86_64-linux-gnu-
python-config -> x86_64-linux-gnu-python2.7-config
-rwxr-xr-x  1 root   root        2971 Oct  7 19:39 x86_64-linux-gnu-
python2.7-config
lrwxrwxrwx  1 root   root          33 Oct 25  2018 x86_64-linux-gnu-
python3-config -> x86_64-linux-gnu-python3.6-config
lrwxrwxrwx  1 root   root          34 Oct  7 14:59 x86_64-linux-gnu-
python3.6-config -> x86_64-linux-gnu-python3.6m-config
-rwxr-xr-x  1 root   root        3283 Oct  7 14:59 x86_64-linux-gnu-
python3.6m-config
lrwxrwxrwx  1 root   root          34 Oct 25  2018 x86_64-linux-gnu-
python3m-config -> x86_64-linux-gnu-python3.6m-config

(base) marco@pc:~$ which python3
/home/marco/anaconda3/bin/python3

(base) marco@pc:~$ python --version
Python 3.7.3

3)我修改了/usr/bin/add-apt-repository的第一行:

(base) marco@pc:~$ head /usr/bin/add-apt-repository
#!/usr/bin/python3.7

from __future__ import print_function

再次尝试设置稳定的 Docker-Engine 存储库:

(base) marco@pc:~$ sudo add-apt-repository \
>    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
>    $(lsb_release -cs) \
>    stable"
Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 11, in <module>
    from softwareproperties.SoftwareProperties import SoftwareProperties, 
shortcut_handler
  File "/usr/lib/python3/dist-packages/softwareproperties
/SoftwareProperties.py", line 67, in <module>
    from gi.repository import Gio
  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in 
<module>
    from . import _gi
ImportError: cannot import name '_gi' from 'gi' (/usr/lib/python3/dist-
packages/gi/__init__.py)
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 109,
in apport_excepthook
    pr.add_proc_info(extraenv=['PYTHONPATH', 'PYTHONHOME'])
  File "/usr/lib/python3/dist-packages/apport/report.py", line 543, in 
add_proc_info
    self.add_proc_environ(pid, extraenv)
  File "/usr/lib/python3/dist-packages/apport/report.py", line 610, in 
add_proc_environ
    env = _read_file('environ', dir_fd=proc_pid_fd).replace('\n', '\\n')
  File "/usr/lib/python3/dist-packages/apport/report.py", line 73, in 
_read_file
    with open(path, 'rb', opener=lambda path, mode: os.open(path, mode, 
dir_fd=dir_fd)) as fd:
  File "/usr/lib/python3/dist-packages/apport/report.py", line 73, in 
<lambda>
    with open(path, 'rb', opener=lambda path, mode: os.open(path, mode, 
dir_fd=dir_fd)) as fd:
TypeError: argument should be integer or None, not list

Original exception was:
Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 11, in <module>
    from softwareproperties.SoftwareProperties import SoftwareProperties, 
shortcut_handler
  File "/usr/lib/python3/dist-packages/softwareproperties
/SoftwareProperties.py", line 67, in <module>
    from gi.repository import Gio
  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in 
<module>
    from . import _gi
ImportError: cannot import name '_gi' from 'gi' (/usr/lib/python3/dist-
packages/gi/__init__.py)

并尝试更新 python 替代方案:

(base) marco@pc:~$ update-alternatives --list python || update-
alternatives --list python
update-alternatives: error: no alternatives for python
update-alternatives: error: no alternatives for python

按照此处找到的指示:https ://www.how2shout.com/how-to/install-python-on-ubuntu-19-04-18-04-using-command-terminal.html

我也尝试以这种方式将python3.7.3修复为官方python:

(base) marco@pc:~$ sudo update-alternatives --config python3.7.3
update-alternatives: error: no alternatives for python3.7.3

解决了:

感谢@Smurfz87,我发现python3.7.3 版本会导致apt-repository 出现这个问题。更改 /usr/bin/add-apt-repository 的第一行以指向 3.6 版本后:#!/usr/bin/python3.6 一切正常:

(base) marco@pc:~$ sudo add-apt-repository \
>    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
>    $(lsb_release -cs) \
>    stable"
Hit:1 http://gb.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]                                                            
Get:3 http://gb.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 
kB]                                                         
Get:4 http://gb.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6
 kB]
Get:5 https://download.docker.com/linux/ubuntu bionic/stable amd64    
Packages [9594 B]
Get:6 http://gb.archive.ubuntu.com/ubuntu bionic-updates/universe i386 
Packages [985 kB]  
Get:7 http://gb.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 
Packages [1017 kB]
Hit:8 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease                                                                                                                                        
Hit:9 http://ppa.launchpad.net/certbot/certbot/ubuntu bionic InRelease                                                                                                                                     
Get:10 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 
kB]                                                                                                                               
Fetched 2328 kB in 11s (217 kB/s)                                                                                                                                                                          
Reading package lists... Done

(base) marco@pc:~$ sudo apt-get update
Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:2 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease
Hit:3 http://gb.archive.ubuntu.com/ubuntu bionic InRelease
Hit:4 http://gb.archive.ubuntu.com/ubuntu bionic-updates InRelease               
Hit:5 http://gb.archive.ubuntu.com/ubuntu bionic-backports InRelease             
Hit:6 http://ppa.launchpad.net/certbot/certbot/ubuntu bionic InRelease
Hit:7 https://download.docker.com/linux/ubuntu bionic InRelease
Reading package lists... Done

(base) marco@pc:~$ sudo apt-get install docker-ce docker-ce-cli 
containerd.io
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  aufs-tools cgroupfs-mount pigz
The following NEW packages will be installed
  aufs-tools cgroupfs-mount containerd.io docker-ce docker-ce-cli pigz
0 to upgrade, 6 to newly install, 0 to remove and 0 not to upgrade.
Need to get 85.6 MB of archives.
After this operation, 384 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

马可

python3 docker 18.04
  • 1 个回答
  • 875 Views
Martin Hope
user2315094
Asked: 2019-07-26 03:21:06 +0800 CST

从今天早上开始 Ubuntu 18:04 网络无法访问

  • 2

今天早上,我的 Ubuntu 18.04 服务器版中的网络不再工作了:

marco@pc01:$ sudo lshw -class network
  *-network DISABLED
      description: Ethernet interface
      product: RTL8111/8168/8411 PCI Express 
        Gigabit Ethernet Controller
  *-network DISABLED
      description: Wireles interface
      product: AR9227 Wireless Network Adapter
  *-network:0
       description: Ethernet interface
       physical id: 2
       logical name : docker0
  *-network:1
       description: Ethernet interface
       physical id: 3

须藤纳米 /etc/nework/interfaces :

iface eth0 inet static
    address 192.168.1.7
    netmask 255.255.255.0
    network 192.168.1.1 
    broadcast 192.168.0.255
    post-up iptables-restore <  
      /etc/iptables.up.rules
    gateway 192.168.1.1
    dns-nameservers 192.168.0.5 8.8.8.8

marco@pc01:$ sudo service network-manager restart
 Failed to restart network-manager.service: Unit network-manager.service 
  not found

即使使用 sudo /etc/init.d/networking restart:

marco@pc01:$ sudo /etc/init.d/networking restart
[ok] Restarting networking (via systemctl):
 networking.service

marco@pc01:$ ping 192.168.1.4
 connect: Network is unreachable

我该怎么做才能使网络再次可用?期待您的帮助马可

1°更新:

marco@pc01:$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKOWN group
       default qlen 1000
   inet 27.0.0.1/8 scope host lo
     valid_lft forever preferred_lft forever
   inet6 ::1/128 scope host
     valid_lft forever preferred_lft forever
2: enp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group 
       default qlen 1000
     link/ether 78:24:af:43:ef:5c brd ff:ff:ff:ff:ff:ff
3: wlp5s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group 
       default qlen 1000
     link/ether c0:4a:00:09:0e:80 brd ff:ff:ff:ff:ff:ff  
4: b3-4f9fe03b1a66: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc 
       noqueue state DOWN group default
     link/ether 02:42:64:29:65:73 brd ff:ff:ff:ff:ff:ff
     inet 172.22.0.1/16 brd 172.22.255.255 scope global br-4f9fe03b1a66
       valid_lft forever preferred_lft forever
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue 
      state DOWN group default
    link/Ether 02:42:01:ea:90:66 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scoper global docker0
      valid_lft forever preferred_lft forever

2°U日期:

一个)

marco@pc01:$ ifconfig eth0 up eth0: ERROR while getting interface flags: 
  eth0: ERROR while getting interface flgs: No such device
  eth0: Host name lookup failure

marco@pc01:$ ifconfig
br-4f9feo3b1a66: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
    inet 192.22.0.1 netmask 255.255.0.0 broadcast 172.22.255.255
    ether 02:42:4d:c4:bd:62 txqueuelen 0 (Ethernet) 
    RX packets 0 bytes 0 (0.0B)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

docker0: flags=4099<,UP,BROADCAST,MULTICAST> mtue 1500
    inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
    ether 02:42:24:b9:3b:59 txqueuelen 0 (Ethernet)
    RX packets 0 bytes 0 (0.0 B)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 0 bytes 0 (0.0 B)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

l0: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
    inet 127.0.0.1 netmask 255.0.0.0
    inet6 ::1 prefoxlen 128 scopeid 0x10<host>
    loop txqueuelen 1000 (Local Loopback)
    RX packets 258 bytes 32343 (32.3 KB) 
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 258 bytes 32343 (32.3 KB)  
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

二)

/etc/network/interfaces:

  auto lo
  iface lo inet loopback

3°更新:

我修改了 /etc/network/interfaces 文件如下:

iface enp3s0 inet static
    address 192.168.1.7
    netmask 255.255.255.0
    network 192.168.1.1 
    broadcast 192.168.0.255
    post-up iptables-restore <  
      /etc/iptables.up.rules
    gateway 192.168.1.1
    dns-nameservers 192.168.0.5 8.8.8.8

但是还是没有网络。

4°更新:

  marco@pc01:$ uname -r
  4.15.0-55-generic

  marco@pc01:$ ls -al /etc/netplan
  total 20
  drwxr-xr-x 2 root root 4096 Jul 25 18:37
  drwxr-xr-x 128 root root 12288 Jul 25 12:51
  -rw-r--r-- 1 root root 616 Jul 25 18:37 30-cloun-init.yaml

   etc/netplan/50-cloud-init.yaml    :

     network:
         renderer: NetworkManager/ networkd
         ethernets:
           enp3s0:
               addresses: [192.168.1.7/24]
               gateway4: 192.168.1.1
               nameservers:
                   addresses: [8.8.8.8,8.8.4.4]
               dhcp4: no
         version: 2

 marco@pc01:$ sudo netplan apply
 sudo: netplan: command not found

对于 sudo llshw -c network :见上文

5° 更新:dpkg -l netplan的结果

marco@pc01:$ dpkg -l *netplan*
Desired=Unknown/Install/Remove/Purge/Hold
  Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-
       pend
    Err?=(none)/Reinst-required (Status,Err: uppercase=bad)

    Name              Version       Architecture  Description
    in netplan.io      <none>          amd64      (no description 
                                                   available)

6° 更新:sudo lshw -c network

marco@pc01:$ sudo lshw -c network
  *-network DISABLED
      description : Ethernet interface
      product: RTL811178168/8411 PCI Express Gigabit Ethernet Controller
      vendor: Realtek Semiconductor CO., Ltd.
      physical id: 0
      bus info: pci@000:03:00.0
      logical name: enp3s0
      version: 11
      serial: 78:24:af:43:ef:5c
      size: 100 Mbit/s
      capacity: 1Gbit/s
      width: 64 bits
      clock: 33 Mhz
      capabilities: pm msi pciexpress msix vpd bus_master cap_list 
                    ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 
                    1000bt 1000bt-fd autonegotiation
      configuration: autonegotiaion=on broadcast=yes driver=r8169 
                     driverversion=2.3LK-NAPI duplex=full latency=0 
                     link=no multcast=yes port=MII speed=100Mbit/s 
      resources: irq:18 ioport:d000(size=256) memory:f7200000-f7200fff 
                 memory:f2100000-f2103fff
   *-network DISABLED
      description: Wireless interface
      product: AR9227 Wireless NEtwork Adapter
      vendor: Qualcomm Atheros
      physical id: 0
      bus info: pci@0000:05:00.0
      logical name: wlp5s0
      version: 01
      serial: c0:4a:00:09:0e:80
      width: 32 bits
      clock: 66MHz
      capabilities: pm bus_master cap_list ethernet physical wireless
      configuration: broadcast=yes driver=ath9k driverversion=3.15.0-55-
                     generic firmware=N/A latency=168 link=no 
                     multicast=yes wireless=IEEE 802.11
      resources: irq:19 memory:f7100000-f10ffff
   *-network:0
      description: Ethernet interface
      physical id: 2
      logical name: docker0
      serial: 02:42:62:12:98:6e
      capabilities: ethernet physical
      configuration: broadcast=yes driver=bridge driverversion=2.3 
                     firmware=N/A ip=172.17.0.1 link=no multicast=yes
   *-network:1
       description: Ethernet interface
       physical id:3
       logical name: br-4f9fe03b1a66
       serial: 01:42:fc:9e:92:1c
       capabilities: ethernet physical
       consiguration: broadcast=yes driver=bridge driverversion=2.3 
                      firmware=N/A ip=172.22.0.1 link=no multicast=yes

7°更新:

Two disks: 
  1° disk: 
    /dev/sda1 1M BIOS boot 
    /dev/sda2 1G Linux filesystem /dev/sda3 232G Linux filesystem 
     with sudo fsck -f : everything ok ;
  2° disk: 
    /dev/sdb1 1M BIOS boot 
    /dev/sdb2 232G Linux filesystem

    sudo fsck -f /dev/sdb1
    fsck from util-linux 2.31.1
    e2fsck 1.44.1 (24-Mar-2018)
    ext2fs_open2: Bad magic number in super-block
    fsck.ext2: Supeblock invalid, trying backup blocks...
    fsck.ext2: Bad magic number in super-block whule trying to open 
               /dev/sdb1
      The superblock could not be read or does not describe a valid 
ext2/ext3/ext4 filesystem (and not swap or ufs or something else), then 
the superblock is corrupt, and you might try running e2fsck with an
alternate superblock:
  e2fsck -b 8193 <device>
or
  e2fsck -b 32768 <device>

即使 /dev/sdb1 可能包含损坏的超级块,我可以安装 netplan 吗?

8°更新:

ubuntu@ubuntu:$ sudo fsck -f /dev/sda2
fsck fromutil-linux 2.31.1
e2fsck 1.44.1 (24-Mar-2018)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda2: 309/65536 files (2.9% non-contiguous), 48744/262144 blocks

ubuntu@ubuntu:$ sudo fsck -f /dev/sdb2
fsck from util-linux 2.31.1

9° 更新:修改 /etc/netplan/01-network-manager-all.yaml 后:

ubuntu@ubuntu:/etc/netplan$ sudo netplan --debug generate
DEBUG:command generate: running ['/lib/netplan/generate']
** (generate:4715): DEBUG: 15:57:43.284: Processing input file 
                    /etc/netplan/01-network-manager-all.yaml..
** (generate:4715): DEBUG: 15:57:43.285: starting new processing pass
                    to 1
** (generate:4715): DEBUG: 15:57:43.285: Configuration is valid
** (generate:4715): DEBUG: 15:57:43.285: Generating output files..
** (generate:4715): DEBUG: 15:57:43.285: NetworkManager: definition 
                    enp3s0 is not for us (backend 1) 
networking network-monitoring 18.04
  • 2 个回答
  • 11282 Views
Martin Hope
user2315094
Asked: 2018-09-03 01:36:45 +0800 CST

如何在 Ubuntu 18.04.01 LTS 中正确将 gcc7.3 升级到 gcc8?

  • 3

在我的 Ubuntu 18.04 LTS 中:

marco@PC:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic

我有 gcc 7.3.0 版:

marco@PC:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu    
7.3.0-21ubuntu1~16.04' --with-bugurl=file:///usr/share/doc/gcc-
7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++
--prefix=/usr --with-gcc-major-version-only --program-suffix=-7 
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-
id --libexecdir=/usr/lib --without-included-gettext --enable-
threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-
clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-
default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-
verify --enable-libmpx --enable-plugin --with-system-zlib --with-target-
system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror 
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none 
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu 
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu 7.3.0-21ubuntu1~16.04)

我想安装 gcc-8:

marco@PC:~$ sudo apt-get install gcc-8
[sudo] password for marco:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc-8 : Depends: cpp-8 (= 8.1.0-1ubuntu1) but it is not going to be   
installed
         Depends: gcc-8-base (= 8.1.0-1ubuntu1) but 8.1.0-5ubuntu1~16.04 
is to be installed
         Depends: libgcc-8-dev (= 8.1.0-1ubuntu1) but it is not going to 
be installed
E: Unable to correct problems, you have held broken packages.

按照此处找到的提示询问Ubuntu:无法纠正问题,您持有损坏的软件包

marco@PC:~$ sudo apt-get update
[sudo] password for marco:
Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:2 http://cz.archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Get:4 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Hit:5 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease
Fetched 88.7 kB in 1s (107 kB/s)
Reading package lists... Done
marco@PC:~$ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
marco@PC:~$ dpkg --get-selections | grep hold
marco@PC:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
marco@PC:~$ sudo apt-get update
Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:2 http://cz.archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Get:4 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Hit:5 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease
Fetched 88.7 kB in 1s (123 kB/s)
Reading package lists... Done

然后,我按照建议检查了使用的 PPA 存储库:

marco@PC:~$ apt-cache policy gcc-8 cpp-8 libgcc-8-dev
gcc-8:
  Installed: (none)
  Candidate: 8.1.0-1ubuntu1
  Version table:
     8.1.0-1ubuntu1 500
        500 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu    
bionic/main amd64 Packages
     8-20180414-1ubuntu2 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64  
Packages
cpp-8:
  Installed: (none)
  Candidate: 8.1.0-1ubuntu1
  Version table:
     8.1.0-1ubuntu1 500
        500 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu  
bionic/main amd64 Packages
     8-20180414-1ubuntu2 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64   
Packages
libgcc-8-dev:
  Installed: (none)
  Candidate: 8.1.0-1ubuntu1
  Version table:
     8.1.0-1ubuntu1 500
        500 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu 
bionic/main amd64 Packages
     8-20180414-1ubuntu2 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64      
        Packages

然后我删除了 PPA ubuntu-toolchain-r/test :

sudo add-apt-repository --remove ppa:ubuntu-toolchain-r/test
 Toolchain test builds; see https://wiki.ubuntu.com/ToolChain
 More info: https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
Press [ENTER] to continue or Ctrl-c to cancel removing it.

但问题依然存在:

marco@PC:~$ sudo apt-get install gcc-8
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc-8 : Depends: cpp-8 (= 8-20180414-1ubuntu2) but it is not going to be 
installed
         Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.1.0-5ubuntu1~16.04  
is to be installed
         Depends: libgcc-8-dev (= 8-20180414-1ubuntu2) but it is not going to 
be installed
E: Unable to correct problems, you have held broken packages.

marco@PC:~$ sudo apt-get install cpp-8
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 cpp-8 : Depends: gcc-8-base (= 8.1.0-1ubuntu1) but 8.1.0-5ubuntu1~16.04 
 is to be installed
E: Unable to correct problems, you have held broken packages.

marco@PC:~$ sudo apt-get install gcc-8-base
Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc-8-base is already the newest version (8.1.0-5ubuntu1~16.04).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

marco@PC:~$ sudo apt-get install libgcc-8-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libgcc-8-dev : Depends: gcc-8-base (= 8.1.0-1ubuntu1) but   
8.1.0-5ubuntu1~16.04 is to be installed
                Depends: libasan5 (>= 8.1.0-1ubuntu1) but it is not going
 to be installed
                Depends: libubsan1 (>= 8.1.0-1ubuntu1) but it is not 
 going to be installed
E: Unable to correct problems, you have held broken packages.

marco@PC:~$ sudo apt-get install libasan5
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libasan5 : Depends: gcc-8-base (= 8.1.0-1ubuntu1) but   
 8.1.0-5ubuntu1~16.04 is to be installed
E: Unable to correct problems, you have held broken packages.

marco@PC:~$ sudo apt-get install libubsan1
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libubsan1 : Depends: gcc-8-base (= 8.1.0-1ubuntu1) but     
 8.1.0-5ubuntu1~16.04 is to be installed
E: Unable to correct problems, you have held broken packages.

所以......似乎为了安装 gcc-8 我必须安装其他依赖于其他包的包,这些包依赖于已经正确安装的 gcc-8-base。

它说“破损的包裹”......那么如何解决这个问题?期待您的善意提示和帮助。马可

更新:

marco@PC:~$ sudo apt-get install ppa-purge
Reading package lists... Done
Building dependency tree
Reading state information... Done
ppa-purge is already the newest version (0.2.8+bzr63).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

marco@PC:~$ sudo ppa-purge ppa:ubuntu-toolchain-r/test
Updating packages lists
PPA to be removed: ubuntu-toolchain-r test
Warning:  Could not find package list for PPA: ubuntu-toolchain-r test

marco@PC:~$ sudo apt-get update
Hit:1 http://cz.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:5 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease
Reading package lists... Done

marco@PC:~$ sudo apt install gcc-8-base gcc-8 cpp-8 libgcc-8-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc-8-base is already the newest version (8.1.0-5ubuntu1~16.04).
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 cpp-8 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.1.0-5ubuntu1~16.04  
 is to be installed
 gcc-8 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.1.0-5ubuntu1~16.04
 is to be installed
 libgcc-8-dev : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but    
 8.1.0-5ubuntu1~16.04 is to be installed
                 Depends: libasan5 (>= 8-20180414-1ubuntu2) but it is not
                  going to be installed
                 Depends: libubsan1 (>= 8-20180414-1ubuntu2) but it is not 
                  going to be installed
 E: Unable to correct problems, you have held broken packages.

安装 aptitude 后,我按照 aptitude 指示的建议进行操作。现在我有这种情况:

marco@PC:~$ sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path            Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc-7   700       auto mode
  1            /usr/bin/gcc-7   700       manual mode
  2            /usr/bin/gcc-8   80        manual mode


 marco@PC:~$ g++ -std=c++17 HelloWorld.cpp -oHelloWorld
marco@PC:~$ ./HelloWorld
Hello World!

如果我选择使用 gcc-8 :

marco@PC:~$ sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path            Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc-7   700       auto mode
  1            /usr/bin/gcc-7   700       manual mode
  2            /usr/bin/gcc-8   80        manual mode

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/gcc-8 to provide /usr/bin/gcc (gcc) in 
manual mode
update-alternatives: warning: skip creation of /usr/bin/g++ because 
associated file /usr/bin/g++-8 (of link group gcc) doesn't exist


marco@PC:~$ sudo aptitude install g++-8
The following NEW packages will be installed:
  g++-8 libstdc++-8-dev{a}
0 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 9,623 kB of archives. After unpacking 43.7 MB will be used.
Do you want to continue? [Y/n/?] Y
Get: 1 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 libstdc++-8-
dev amd64 8-20180414-1ubuntu2 [1,536 kB]
Get: 2 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 g++-8 amd64 
8-20180414-1ubuntu2 [8,088 kB]
Fetched 9,623 kB in 1s (7,165 kB/s)
Selecting previously unselected package libstdc++-8-dev:amd64.
(Reading database ... 92421 files and directories currently installed.)
Preparing to unpack .../libstdc++-8-dev_8-20180414-1ubuntu2_amd64.deb ...
Unpacking libstdc++-8-dev:amd64 (8-20180414-1ubuntu2) ...
Selecting previously unselected package g++-8.
Preparing to unpack .../g++-8_8-20180414-1ubuntu2_amd64.deb ...
Unpacking g++-8 (8-20180414-1ubuntu2) ...
Setting up libstdc++-8-dev:amd64 (8-20180414-1ubuntu2) ...
Setting up g++-8 (8-20180414-1ubuntu2) ...
Processing triggers for man-db (2.8.3-2) ...


marco@PC:~$ sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path            Priority   Status
------------------------------------------------------------
  0            /usr/bin/gcc-7   700       auto mode
  1            /usr/bin/gcc-7   700       manual mode
* 2            /usr/bin/gcc-8   80        manual mode

Press <enter> to keep the current choice[*], or type selection number:
update-alternatives: warning: forcing reinstallation of alternative /usr/bin
/gcc-8 because link group gcc is broken

现在,重新启动后,它似乎工作:

marco@PC:~$ sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

      Selection    Path            Priority   Status
------------------------------------------------------------
  0            /usr/bin/gcc-7   700       auto mode
  1            /usr/bin/gcc-7   700       manual mode
* 2            /usr/bin/gcc-8   80        manual mode

Press <enter> to keep the current choice[*], or type selection number:
marco@PC:~$ g++ -std=c++17 HelloWorld.cpp -oHelloWorld
marco@PC:~$ ./HelloWorld
Hello World!

marco@PC:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu   
8-20180414-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs  
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr   
--with-gcc-major-version-only --with-as=/usr/bin/x86_64-linux-gnu-as --with- 
ld=/usr/bin/x86_64-linux-gnu-ld --program-suffix=-8 --program-prefix=x86_64-  
linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib  
--without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-
nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-
libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-
object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-
default-pie --with-system-zlib --with-target-system-zlib --enable-objc-
gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-
abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-
tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver
 --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu 
--target=x86_64-linux-gnu

Thread model: posix
gcc version 8.0.1 20180414 (experimental) [trunk revision 259383] (Ubuntu 
8-20180414-1ubuntu2)
server upgrade gcc 18.04
  • 1 个回答
  • 5032 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve