使用sudo apt-get dist-upgrade后,终端卡住了。

我试图通过sudo apt-get dist-upgrade来更新我的Ubuntu 16.04,但现在终端卡住了(终端1)。
我让它运行了整整一天(超过24小时),只有一次暂停操作系统。
我已经尝试了一些互联网上的提示(例如here),但不幸的是没有效果。
我在互联网上找到的一些代码片段,我无法使用它们,因为Ubuntu说它被另一个进程锁定了(终端2)。
有人知道可能发生了什么吗?或者我应该怎么做才能解决这个问题?因为我不知道是否失败或成功,或者它是否仍在运行,因为我已经尝试输入一些"enter"键,但没有任何反应,终端上也没有新的一行,它卡住了。
提前谢谢。
终端1
$ sudo apt-get dist-upgrade 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
  linux-headers-4.4.0-148 linux-headers-4.4.0-148-generic
  linux-image-4.4.0-148-generic linux-modules-4.4.0-148-generic
  linux-modules-extra-4.4.0-148-generic linux-tools-4.4.0-148
  linux-tools-4.4.0-148-generic
The following packages will be upgraded:
  linux-generic linux-headers-generic linux-image-generic linux-tools-virtual
4 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 69,1 MB of archives.
After this operation, 314 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-modules-4.4.0-148-generic amd64 4.4.0-148.174 [12,0 MB]
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-image-4.4.0-148-generic amd64 4.4.0-148.174 [6.925 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-modules-extra-4.4.0-148-generic amd64 4.4.0-148.174 [36,6 MB]
Get:4 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-generic amd64 4.4.0.148.156 [1.784 B]
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-image-generic amd64 4.4.0.148.156 [2.750 B]
Get:6 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-4.4.0-148 all 4.4.0-148.174 [9.982 kB]
Get:7 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-4.4.0-148-generic amd64 4.4.0-148.174 [810 kB]
Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-generic amd64 4.4.0.148.156 [2.582 B]
Get:9 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-tools-4.4.0-148 amd64 4.4.0-148.174 [2.850 kB]
Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-tools-4.4.0-148-generic amd64 4.4.0-148.174 [2.598 B]
Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-tools-virtual amd64 4.4.0.148.156 [2.610 B]
Fetched 69,1 MB in 2min 11s (526 kB/s)                                         
Selecting previously unselected package linux-modules-4.4.0-148-generic.
(Reading database ... 302549 files and directories currently installed.)
Preparing to unpack .../linux-modules-4.4.0-148-generic_4.4.0-148.174_amd64.deb ...
Unpacking linux-modules-4.4.0-148-generic (4.4.0-148.174) ...
Selecting previously unselected package linux-image-4.4.0-148-generic.
Preparing to unpack .../linux-image-4.4.0-148-generic_4.4.0-148.174_amd64.deb ...
Unpacking linux-image-4.4.0-148-generic (4.4.0-148.174) ...
Selecting previously unselected package linux-modules-extra-4.4.0-148-generic.
Preparing to unpack .../linux-modules-extra-4.4.0-148-generic_4.4.0-148.174_amd64.deb ...
Unpacking linux-modules-extra-4.4.0-148-generic (4.4.0-148.174) ...
Preparing to unpack .../linux-generic_4.4.0.148.156_amd64.deb ...
Unpacking linux-generic (4.4.0.148.156) over (4.4.0.146.154) ...
Preparing to unpack .../linux-image-generic_4.4.0.148.156_amd64.deb ...
Unpacking linux-image-generic (4.4.0.148.156) over (4.4.0.146.154) ...
Selecting previously unselected package linux-headers-4.4.0-148.
Preparing to unpack .../linux-headers-4.4.0-148_4.4.0-148.174_all.deb ...
Unpacking linux-headers-4.4.0-148 (4.4.0-148.174) ...
Selecting previously unselected package linux-headers-4.4.0-148-generic.
Preparing to unpack .../linux-headers-4.4.0-148-generic_4.4.0-148.174_amd64.deb ...
Unpacking linux-headers-4.4.0-148-generic (4.4.0-148.174) ...
Preparing to unpack .../linux-headers-generic_4.4.0.148.156_amd64.deb ...
Unpacking linux-headers-generic (4.4.0.148.156) over (4.4.0.146.154) ...
Selecting previously unselected package linux-tools-4.4.0-148.
Preparing to unpack .../linux-tools-4.4.0-148_4.4.0-148.174_amd64.deb ...
Unpacking linux-tools-4.4.0-148 (4.4.0-148.174) ...
Selecting previously unselected package linux-tools-4.4.0-148-generic.
Preparing to unpack .../linux-tools-4.4.0-148-generic_4.4.0-148.174_amd64.deb ...
Unpacking linux-tools-4.4.0-148-generic (4.4.0-148.174) ...
Preparing to unpack .../linux-tools-virtual_4.4.0.148.156_amd64.deb ...
Unpacking linux-tools-virtual (4.4.0.148.156) over (4.4.0.146.154) ...
Setting up linux-modules-4.4.0-148-generic (4.4.0-148.174) ...
Setting up linux-image-4.4.0-148-generic (4.4.0-148.174) ...
I: /vmlinuz.old is now a symlink to boot/vmlinuz-4.4.0-146-generic
I: /initrd.img.old is now a symlink to boot/initrd.img-4.4.0-146-generic
I: /vmlinuz is now a symlink to boot/vmlinuz-4.4.0-148-generic
I: /initrd.img is now a symlink to boot/initrd.img-4.4.0-148-generic
Setting up linux-modules-extra-4.4.0-148-generic (4.4.0-148.174) ...
Setting up linux-image-generic (4.4.0.148.156) ...
Setting up linux-headers-4.4.0-148 (4.4.0-148.174) ...
Setting up linux-headers-4.4.0-148-generic (4.4.0-148.174) ...

2号航站楼

$ sudo dpkg --configure --pending
dpkg: error: dpkg frontend is locked by another process

$ sudo dpkg --configure -a
dpkg: error: dpkg frontend is locked by another process

$ sudo apt -f install
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
3个回答

我想分享一下我解决问题的步骤。
首先,我需要手动关闭终端。然后,我必须删除锁定文件:
sudo rm /var/lib/dpkg/lock

之后,我能够执行以下命令:
sudo dpkg --configure --pending

sudo dpkg --configure -a

sudo apt install -f

感谢Linux组的成员们帮助我解决了这个问题,也感谢其他尝试帮助我的人。

几乎和这个情况一模一样:Ubuntu 18.04 stuck at upgrading linux-header
那里的被接受的答案有5个赞(现在是6个),如下所示。

简而言之:禁用安全启动。

大约一个月前,我也遇到了同样的问题。对我来说,解决方案是禁用安全启动。自从我安装了Ubuntu 18.04以来,我一直禁用了安全启动,并且升级过程中没有出现任何问题。然而,大约一个月前,我更新了BIOS,这导致安全启动重新启用(当时我并不知道)。升级过程中的冻结让我很沮丧,最后我发现问题所在是因为我的VirtualBox安装也无法正常工作。解决VirtualBox的方法是禁用安全启动,这也修复了我的linux-headers-<version>-generic升级问题。

如问题中所述,升级过程会在此处冻结:

...
Setting up linux-headers-4.15.0-38-generic (4.15.0-38.41) ...

禁用安全启动后,我得到以下结果:
...
Setting up linux-headers-4.15.0-38-generic (4.15.0-38.41) ...
/etc/kernel/header_postinst.d/dkms:
Secure Boot not enabled on this system.
...
done

另一种更简单的升级Ubuntu版本的方法是通过以下命令:
do-release-upgrade