因需要把Ubuntu 16.04版本在内网情况下升级到Ubuntu 18.04版本,所以需要Ubuntu 18.04版本升级镜像下载到本地,并搭建本地服务,用于Ubuntu操作系统升级使用。
先介绍一下Ubuntu版本信息。https://help.ubuntu.com/
Ubuntu每一个发布的版本都会有一个对应的英文名称,而我们搭建镜像源下载镜像数据的时候一定要按照需要的版本,下载对应英文的版本镜像数据。
镜像数据可以直接从官网网站直接拉取,但是因国内网络问题,推荐使用代理,比如清华、阿里云、网易、腾讯等几家大厂的镜像源。
搭建拉取镜像源服务:(因本人使用的Ubuntu服务器进行镜像源拉取,所以仅说明该环境下拉取流程)
1.安装apache2
sudo apt-get install apache2
2.安装apt-mirror
sudo apt-get install apt-mirror
3.修改apt-mirror配置文件
sudo vi /etc/apt/mirror.list
参考以下配置文件:
############# config ##################
# 以下注释的内容都是默认配置,如果需要自定义,取消注释修改即可
set base_path /var/spool/apt-mirror
#
# 镜像文件下载地址
# set mirror_path $base_path/mirror
# 临时索引下载文件目录,也就是存放软件仓库的dists目录下的文件(默认即可)
# set skel_path $base_path/skel
# 配置日志(默认即可)
# set var_path $base_path/var
# clean脚本位置
# set cleanscript $var_path/clean.sh
# 架构配置,i386/amd64,默认的话会下载跟本机相同的架构的源
set defaultarch amd64
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
# 下载线程数
set nthreads 20
set _tilde 0
#
############# end config ##############
#下载的18.04版本镜像源 bionic,如果其他版本,可将bionic英文替换到对应版本英文名称即可
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
4.开始同步
sudo apt-miiror
5.将镜像文件挂载到apache2服务下
sudo ln -s /var/spool/apt-mirror/mirror/mirrors.tuna.tsinghua.edu.cn/ubuntu /var/www/html/ubuntu
需要升级Ubuntu系统配置:
1.编辑/etc/apt/sources.list,推荐在修改前进行文件备份,并注意在不同版本的Ubuntu系统中修改的文件可能不同,经验证Ubuntu 16.04版本中使用/etc/apt/sources.list文件
#
# deb cdrom:[Ubuntu-Server 16.04.4 LTS _Xenial Xerus_ - Release amd64 (20180228)]/ xenial main restricted
#deb cdrom:[Ubuntu-Server 16.04.4 LTS _Xenial Xerus_ - Release amd64 (20180228)]/ xenial main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb [arch=amd64] http://192.168.0.11:80/ubuntu/ bionic main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb [arch=amd64] http://192.168.0.11:80/ubuntu/ bionic-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb [arch=amd64] http://192.168.0.11:80/ubuntu/ bionic universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial universe
deb [arch=amd64] http://192.168.0.11:80/ubuntu/ bionic-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb [arch=amd64] http://192.168.0.11:80/ubuntu/ bionic multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
deb [arch=amd64] http://192.168.0.11:80/ubuntu/ bionic-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb [arch=amd64] http://192.168.0.11:80/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu xenial partner
# deb-src http://archive.canonical.com/ubuntu xenial partner
deb [arch=amd64] http://192.168.0.11:80/ubuntu bionic-security main restricted
# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
deb [arch=amd64] http://192.168.0.11:80/ubuntu bionic-security universe
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
deb [arch=amd64] http://192.168.0.11:80/ubuntu bionic-security multiverse
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse
2.系统升级命令
sudo apt update && sudo apt -y dist-upgrade
接下来按照提示操作就可
另可能有的需要将镜像源导出来在Windows 上使用IIS搭建本地镜像源服务,
可以直接使用IIS搭建,但需要注意以下镜像内容
1.IIS站点对应的缓冲池设置正确,使用framework4.0
2.修改网站配置文件夹权限,可供外部访问可读
3.IIS网站中双击“目录浏览”,将选中所有项,并"应用
4.IIS网站中双击“请求筛选”,点击“编辑功能设置”,勾选所有内容后,点击“确定”
5.添加以下几项文件可访问权限。
可直接在web.config中添加
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="true" showFlags="Date, Time, Size, Extension, LongDate" />
<staticContent>
<mimeMap fileExtension="." mimeType="text/plain" />
<mimeMap fileExtension=".*" mimeType="application/octet-stream" />
<mimeMap fileExtension=".deb" mimeType="application/octet-stream" />
</staticContent>
<security>
<requestFiltering allowDoubleEscaping="true">
<requestLimits maxQueryString="40800" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
或可以通过请求筛选中添加
. text/plain
.* application/octet-stream
.deb application/octet-stream