升级FreeBSD版本

来自艾毕思知识库
跳转至: 导航搜索

在使用某些虚拟服务器或者云服务器的时候,如果碰到服务商提供的FreeBSD操作系统版本过低,而服务器也不支持用户使用自己的操作系统安装镜像时,就需要在当前可用系统上进行手工的操作系统版本升级来满足业务系统对操作系统版本的要求。

比如我们现在的FreeBSD版本是已停止维护的10.1版本,在这个环境中安装新版本的软件基本上会失败,就像下面这种:

root@aibs:/usr/ports/databases/mysql56-server # make install clean
===> Building/installing dialog4ports as it is required for the config dialog
===>  Cleaning for dialog4ports-0.1.6
===> Skipping 'config' as NO_DIALOG is defined
/!\ ERROR: /!\

Ports Collection support for your FreeBSD version has ended, and no ports are
guaranteed to build on this system. Please upgrade to a supported release.

No support will be provided if you silence this message by defining
ALLOW_UNSUPPORTED_SYSTEM.

*** Error code 1

Stop.
make[3]: stopped in /usr/ports/ports-mgmt/dialog4ports
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/ports-mgmt/dialog4ports
===> Options unchanged
/!\ ERROR: /!\

Ports Collection support for your FreeBSD version has ended, and no ports are
guaranteed to build on this system. Please upgrade to a supported release.

No support will be provided if you silence this message by defining
ALLOW_UNSUPPORTED_SYSTEM.

*** Error code 1

Stop.
make[1]: stopped in /usr/ports/databases/mysql56-server
*** Error code 1

Stop.
make: stopped in /usr/ports/databases/mysql56-server


所以需要先将操作系统升级到当前最新的10.3版本。在终端输入:

# freebsd-version -k
10.1-RELEASE

可以看到当前操作系统版本为10.1。

使用命令# freebsd-update upgrade -r 10.3-RELEASE指定升级的目标版本10.3,回车执行升级

输出类似

Looking up update.FreeBSD.org mirrors... 4 mirrors found.
Fetching metadata signature for 10.1-RELEASE from update4.freebsd.org... done.
Fetching metadata index... done.
Inspecting system... done.

The following components of FreeBSD seem to be installed:
kernel/generic world/base world/doc world/lib32

The following components of FreeBSD do not seem to be installed:
src/src world/games

Does this look reasonable (y/n)? y

确认不安装的内容,这个和你使用的VPS当前安装组件相关,输入y确认继续,等待下载和安装。

Fetching 11008 patches.....10....20....30....40....50....60....70....80....90....100....110....120....130....140....150....160....170....180....190....

完全下载后,可能需要手动确认某些文件的升级内容,这里可以全部接受新版本内容,选择y后继续;完成所有需要确认的文件修改后,使用

# freebsd-update install

执行安装,本次安装完成以后需要重启计算机,然后再次执行安装程序来完成操作系统的升级。

# shutdown -r now

启动完成后再次登录到FreeBSD,使用

# freebsd-update install

第二次安装完成后可以使用

# freebsd-version -k

查看当前FreeBSD的版本:

root@aibs:~ # freebsd-version -k
10.3-RELEASE-p20

则成功完成了FreeBSD从10.1升级到10.3版本;然后继续需要的软件安装。