通过SSH升级ubuntu系统

最近想在实验室服务器里装一个软件,但是这个软件莫名其妙的只支持ubuntu 14。无奈,只能折腾着通过SSH来从12升级到14了。现在就把整个流程总结一下。

本文参考了这篇博客,以及这个askubuntu的回答

更新源

要升级系统,靠谱的更新源是必不可少的。因为有些源没法用来升级ubuntu 14(比如清华源),有些源则非常慢,还可能出错(比如默认源)。

我升级用的是163源,我这边速度大概是150-200K每秒。安装包1G,大概要下载一两个小时吧。163源如下:

deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse

大家用的时候,先保存一下原来源的副本:

sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup

然后在通过vim,把原来的源删掉,替换成163源即可:

sudo vim /etc/apt/sources.list

由于我用的是教育网,平常装软件的时候还是清华源比较快,也顺带列在下面了:

自动选择ipv4或ipv6
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse

IPv4-Only 地址
deb http://mirrors.4.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.4.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.4.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.4.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse
deb http://mirrors.4.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.4.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.4.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.4.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.4.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.4.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse

IPv6-Only 地址
deb http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/ trusty main multiverse restricted universe
deb http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main multiverse restricted universe
deb http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main multiverse restricted universe
deb http://mirrors.6.tuna.tsinghua.edu.cn//ubuntu/ trusty-security main multiverse restricted universe
deb http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main multiverse restricted universe
deb-src http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/ trusty main multiverse restricted universe
deb-src http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main multiverse restricted universe
deb-src http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main multiverse restricted universe
deb-src http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main multiverse restricted universe
deb-src http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main multiverse restricted universe

第一块是可以自动判断你用的是ipv4还是ipv6。如果你知道自己用的是什么的话,就从下面的里面选吧。

我用自动选择的版本会出错,不知道为什么。用ipv4版本的话,至少会有1M每秒的速度。

升级Ubuntu

一定要用下面的命令升级:

sudo do-release-upgrade

因为这条命令会帮你处理好一切。

首先,它会自动开启一个screen。所以,当你和服务器的SSH连接断开后,更新并不会停止。你可以重新通过SSH连接到服务器,然后通过:

sudo screen -x

来返回之前的更新进程。其中,-x参数的意思是,回到之前的screen。注意,这里一定要加sudo,因为之前开screen的用户是sudo

另外,它还会新开一个SSH守护进程来监听1022端口。所以,当你无法通过正常的方式以SSH连接到服务器的话,可以使用下面的命令:

ssh user@server -p 1022

进行连接。然后再通过sudo screen -x回到之前的更新进程。

上面两个恢复方式我都亲自测试过,大家可以放心使用。

你可能感兴趣的:(ubuntu)