笔记:ubuntu22.04重启后无法启动网络

安装ubuntu-22.04-live-server-amd64.iso后,这是一个默认没有界面的ubuntu系统,配置好静态IP后,安装了新内核。

附安装新内核过程中需要的一些库:

先apt-cache search 5.15.0-76 内核相关的包。

apt-get download libssl1.1

apt-get download crda

 apt-get download wireless-crda 

apt-get download iw

apt-get download linux-image-5.15.0-76-generic  linux-headers-5.15.0-76-generic  linux-modules-5.15.0-76-generic  linux-modules-extra-5.15.0-76-generic 

以上是从另一台ubuntu20上下载的,因为当前这个ubuntu server22.04的source源中搜索不到其他内核包。如果改变source,可能导致开发库所依赖的动态库版本不匹配。

需要ubuntu图形界面安装:apt install ubuntu-desktop

如果要开启root登录:

vim打开以下的/etc/pam.d/gdm-autologin及gdb-password中分别注释大约第3行,或者使用以下命令进行注释。

sudo sed -i "s/.*root quiet_success$/#&/" /etc/pam.d/gdm-autologin
sudo sed -i "s/.*root quiet_success$/#&/" /etc/pam.d/gdm-password

现在重点问题来了,在安装新内核重启后,没有网络,且重启过程中卡在“A start job is running for wait for network to be Configured”很久,登录界面后,右上角以及setting中的network设置中,都看不到网络设置,只有proxy等无关的东西。  ip a命令查询网卡存在,但是ifup ens33尝试启动不了,也没有报错。

解决方法:

   先查看系统上有哪些网络服务:

sudo systemctl status systemd-networkd
sudo systemctl status NetworkManager
sudo service networking status
sudo service network-manager status
 

我的节点内容如下所示:

root@love:~# systemctl status systemd-networkd
● systemd-networkd.service - Network Configuration
     Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2024-01-08 11:51:18 UTC; 1h 20min ago
TriggeredBy: ● systemd-networkd.socket
       Docs: man:systemd-networkd.service(8)
   Main PID: 6913 (systemd-network)
     Status: "Processing requests..."
      Tasks: 1 (limit: 4516)
     Memory: 1.5M
        CPU: 174ms
     CGroup: /system.slice/systemd-networkd.service
             └─6913 /lib/systemd/systemd-networkd

Jan 08 11:51:18 love systemd[1]: Starting Network Configuration...
Jan 08 11:51:18 love systemd-networkd[6913]: ens33: Link UP
Jan 08 11:51:18 love systemd-networkd[6913]: ens33: Gained carrier
Jan 08 11:51:18 love systemd-networkd[6913]: lo: Link UP
Jan 08 11:51:18 love systemd-networkd[6913]: lo: Gained carrier
Jan 08 11:51:18 love systemd-networkd[6913]: ens33: Gained IPv6LL
Jan 08 11:51:18 love systemd-networkd[6913]: Enumeration completed
Jan 08 11:51:18 love systemd[1]: Started Network Configuration.
root@love:~# systemctl status NetworkManager
● NetworkManager.service - Network Manager
     Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2024-01-08 13:07:53 UTC; 4min 13s ago
       Docs: man:NetworkManager(8)
   Main PID: 59083 (NetworkManager)
      Tasks: 3 (limit: 4516)
     Memory: 2.8M
        CPU: 98ms
     CGroup: /system.slice/NetworkManager.service
             └─59083 /usr/sbin/NetworkManager --no-daemon

Jan 08 13:07:53 love NetworkManager[59083]:   [1704719273.6713] ifupdown:       interface-parser: sou>
Jan 08 13:07:53 love NetworkManager[59083]:   [1704719273.6714] ifupdown: interfaces file /etc/networ>
Jan 08 13:07:53 love NetworkManager[59083]:   [1704719273.6714] ifupdown:       interface-parser: fin>
Jan 08 13:07:53 love NetworkManager[59083]:   [1704719273.6737] dhcp-init: Using DHCP client 'interna>
Jan 08 13:07:53 love NetworkManager[59083]:   [1704719273.6737] device (lo): carrier: link connected
Jan 08 13:07:53 love NetworkManager[59083]:   [1704719273.6762] manager: (lo): new Generic device (/o>
Jan 08 13:07:53 love NetworkManager[59083]:   [1704719273.6861] device (ens33): carrier: link connect>
Jan 08 13:07:53 love NetworkManager[59083]:   [1704719273.6868] manager: (ens33): new Ethernet device>
Jan 08 13:07:53 love NetworkManager[59083]:   [1704719273.6876] failed to open /run/network/ifstate
Jan 08 13:07:53 love NetworkManager[59083]:   [1704719273.6940] manager: startup complete

root@love:~# service networking status
○ networking.service
     Loaded: masked (Reason: Unit networking.service is masked.)
     Active: inactive (dead)

Jan 08 12:32:41 love systemd[1]: /lib/systemd/system/networking.service:12: Unknown key name 'ExecRestart' >
Jan 08 12:32:41 love systemd[1]: /lib/systemd/system/networking.service:12: Unknown key name 'ExecRestart' >
root@love:~# service network-manager status
Unit network-manager.service could not be found.

可以看到,systemd-networkd和NetworkManager同时存在,这时候禁用掉systemd-networkd服务即可。

sudo systemctl stop systemd-networkd
sudo systemctl disable systemd-networkd

root@love:~# systemctl stop systemd-networkd
Warning: Stopping systemd-networkd.service, but it can still be activated by:
  systemd-networkd.socket

gpt解释:
这个警告提示 systemd-networkd 服务停止后,仍然可以通过 systemd-networkd.socket 激活。systemd-networkd.socket 是 systemd-networkd 服务的 socket 单元,负责根据需要启动 systemd-networkd 服务。

想着也用不到的,想尝试卸载上面的服务,先看看它属于哪个安装包:

root@love:~# systemctl show -p FragmentPath systemd-networkd
FragmentPath=/lib/systemd/system/systemd-networkd.service
root@love:~# dpkg -S /lib/systemd/system/systemd-networkd.service
systemd: /lib/systemd/system/systemd-networkd.service

可以看到这个服务属于systemd包里的,那就不敢卸载了,留着吧。

做完这些操作,systemctl restart NetworkManager应该可以启动网络,因为我是在重启之前就做了上面这些操作,所以如果不行你就再重启一次。

你可能感兴趣的:(笔记,ubuntu22,ubuntu,网络)