Ubuntu18.04 cannot enter the system after restarting, as shown in the figure after restarting
The system kernel 4.15.0-213-generic has been loading and cannot be loaded.
wrong reason
The original system is Ubuntu16.04. Use the command to upgrade to Ubuntu18.04 version. After the upgrade and restart, the remote connection cannot be connected!
Error resolution
Step 1: Enter GRUB
(Not remote, connect the screen directly to the server) After restarting , press and hold Shift to enter GRUB
Since the system kernel 4.15.0-213-generic cannot be loaded, it means that the system default kernel is 4.15.0.142-generic and select the 4.15.0.142-generic recovery mode.
After loading, enter recovery mode
Start the computer, enter the ubuntu login interface, enter your account number and password to log in.
Make sure the system kernel 4.15.0-142-generic is loaded, use the command
sudo apt-mark hold your own system kernel header/model/image
Unable to connect to the network after entering~
Step 2: Network related information settings
If the network device is found but cannot connect to the Internet, there may be several reasons:
- **IP Configuration Issues:** Make sure your network interface has the correct IP address, subnet mask, and default gateway. You can use `ifconfig` or `ip addr` to check the IP configuration information of a network interface.
- **DNS setting problem:** Make sure your DNS settings are correct. You can edit the `/etc/resolv.conf` file or configure the correct DNS server through a network management tool.
- **Network Connection Issues:** Sometimes, even if a network device appears to be normal, the connection may be affected by a physical or configuration issue. Check if your network cable or Wi-Fi connection is working properly.
- **Firewall or Router Settings:** Make sure your firewall or router is not blocking your system from accessing the Internet. Sometimes security settings may restrict network connections.
At first I thought it was because there was no network driver after the system was updated, so I checked the driver-related settings and the command was as follows
vim /etc/resolv.conf
There is no problem if the nameserver is displayed.
View network status command
ifconfig
show
- A local loopback: lo
- One network cable: enp5s0
- A docker network: docker0
At this time, in the settings, the network is displayed
Modify the IP address and DNS address (fill in the address assigned by the administrator)~
After modification, I still cannot ping the external network. At this time
After enp5s0, <NO-Carrier, > etc. are prompted, and RUNNING is not displayed.
"no carrier" means that the network interface currently has no physical connection detected. This usually means that the network cable is not connected to the network card or the other end of the network cable connection is not plugged into an active network port. In this state, the network interface cannot function or communicate properly because it does not detect an available network signal.
Because I changed the network cable port before, I just plug it back into the original port~
After solving, normal network display
At this time, the network problem is solved~ When starting to update the software, kernel-related problems occur, and apt install cannot be installed~
Step 3: Solve update errors and installation errors
First check how many cores the system has automatically updated:
sudo dpkg --get-selections|grep linux-image
You can see that there are two cores at this time, one is 142 that we fixed (hold) the core in the first step, and the other is 213
Although the first step has been written, I still want to confirm it again.
The problem when updating is as follows
E: Sub-process /usr/bin/dpkg returned an error code (1)
linux-image-4.15.0-213-generic (4.15.0-213.224) is loaded here by default...
Setting up linux-headers-4.15.0-213-generic (4.15.0-213.224)
Ubuntu canceled the kernel of sudo apt-mark hold, but later I felt that it was not a kernel problem~
sudo apt-mark unhold linux-image-4.15.0-142-generic
Solution
# Now rename the info folder
sudo mv /var/lib/dpkg/info /var/lib/dpkg/info_old
#Create a new info folder
sudo mkdir /var/lib/dpkg/info
#Update and upgrade
sudo apt-get update && sudo apt-get -f install
# After performing the previous step, it will be generated in the new info folder.
sudo mv /var/lib/dpkg/info/* /var/lib/dpkg/info_old
# Delete the newly created info folder
sudo rm -rf /var/lib/dpkg/info
# Change the name of the previous info folder back to its original name
sudo mv /var/lib/dpkg/info_old /var/lib/dpkg/info
Intercept part of the implementation diagram
第四步:解决W: APT had planned for dpkg to do more than it reported back (0 vs 3).
Affected packages: linux-headers-4.15.0-142-generic:amd64
# Automatically repair and install packages that packages depend on.
sudo apt install -f
#Reconfigure the software package "own software package name"
sudo dpkg --configure linux-headers-4.15.0-142-generic
#Configuration
sudo dpkg -C
# renew
sudo apt update && sudo apt upgrade
# Remove automatically installed unnecessary packages
sudo apt autoremove
✨Related knowledge points
GRUB
When you start your computer, it first loads the BIOS or UEFI and then looks for the boot loader on the hard drive. On computers with the Ubuntu operating system installed, a boot loader called GRUB (GRand Unified Bootloader) is usually used.
GRUB's role is to load the operating system when the computer starts. It is able to identify the different operating systems installed on the hard drive and allows the user to select which operating system to boot. GRUB determines which operating systems can be booted by reading configuration files and then hands control to the selected operating system.
In Ubuntu, GRUB can also be used to fix startup problems. If there is a problem when the system starts, you can use GRUB's command line interface to repair or temporarily change the startup parameters to boot into the system or fix system errors .
In general, GRUB is a powerful boot loader that is responsible for loading the operating system when the computer starts, and provides the ability to manage startup options and solve startup problems.
Network settings
DEVICE_NAME: The name of the interface.
dhcp4: yes or no depending on dynamic or static IP addressing
If dhcp is set to no, you need to set the ip address and gateway
- addresses: The device's IP address in prefix notation. Do not use netmask.
- gateway: Gateway IP address connected to the external network
- nameservers: DNS name server addresses
View network card related information: ip a
references
【3】Ubuntu error when using apt-get upgrade - Deep Learning 1 - Blog Park (cnblogs.com)