阿里云ECS服务器由Ubuntu 14升级到Ubuntu 16的方法
由Ubuntu 14升级到Ubuntu 16,正常情况下简单执行如下命令即可:
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade
$ sudo do-release-upgrade
如果使用的是阿里云的ECS服务器,且系统盘原来安装的是Ubuntu12,现在的Ubuntu 14是由原来的12升级而来的,那么在执行do-release-upgrade命令时可能会产生如下错误:
Calculating the changes
Could not calculate the upgrade
An unresolvable problem occurred while calculating theupgrade.
This can be caused by:
* Upgrading to a pre-release version of Ubuntu
* Running the current pre-release version of Ubuntu
* Unofficial software packages not provided by Ubuntu
If none of this applies, then please report this bugusing the
command 'ubuntu-bug ubuntu-release-upgrader-core' in aterminal.
Restoring original system state
Aborting
Reading package lists... Done
Building dependency tree
Reading state information... Done
Building data structures... Done
=== Command detached from window (Sun May 21 15:33:442017) ===
这个错误是什么意思呢?执行如下命令,查看出错日志:
$ cat /var/log/dist-upgrade/main.log | grep failed
可以看到如下内容:
901 DEBUG failed to SystemUnLock() (E:Not locked)
116 ERROR Dist-upgrade failed: 'The essential package 'mount'is marked for removal.'
118 DEBUG failed to SystemUnLock() (E:Not locked)
这说明mount这个包被锁定了,被锁定的原因是服务器安装的初始系统ubuntu 12.04 LTS上阿里云设定的锁定,如果服务器的系统是先从ubuntu12.04 LTS升级到ubuntu 14.04 LTS,那么这个设置被保留在了系统里面。
执行如下命令,查看包管理策略:
$ apt-cache policy
可以看到如下信息:
Pinned packages:
mount -> 2.20.1-1ubuntu3
linux-image-3.2.0-29-generic -> (not found)
信息显示,mount被锁定到了版本2.20.1上,导致无法升级替换。
此时可通过执行如下命令移除锁定策略:
$ sudo mv /etc/apt/preferences.d/etc/apt/preferences.d.old
接下来继续执行升级命令:
sudo do-release-upgrade
一路回车,什么都不填,一切都不更改,大约20-30分钟之后,系统提示重启。
重启完成后,清理无用的安装包:
$ sudo apt-get autoremove
至此完成Ubuntu服务器从14到16的升级。