ubuntu制作apt本地源
时间: 2023-09-03 22:15:53 浏览: 147
要在Ubuntu上制作apt本地源,请按照以下步骤进行操作:
1.安装apt-mirror工具
```bash
sudo apt-get update
sudo apt-get install apt-mirror
```
2.创建一个目录来存储本地源文件
```bash
sudo mkdir /var/spool/apt-mirror
```
3.编辑apt-mirror的配置文件
```bash
sudo nano /etc/apt/mirror.list
```
在文件中添加以下内容:
```bash
############# config ##################
#
# set base_path /var/spool/apt-mirror
#
# set mirror_path $base_path/mirror
# set skel_path $base_path/skel
# set var_path $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch <running host architecture>
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads 20
set _tilde 0
#
############# end config ##############
deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse
# Clean up
clean http://archive.ubuntu.com/ubuntu
clean http://security.ubuntu.com/ubuntu
```
在这个文件中,你可以指定你要下载的Ubuntu版本和你的Ubuntu源的URL。
4.运行apt-mirror工具
```bash
sudo apt-mirror
```
该命令将下载所有指定的软件包和依赖项,并将它们存储在/var/spool/apt-mirror目录下。
5.设置本地源
```bash
sudo nano /etc/apt/sources.list
```
在文件中添加以下行:
```bash
deb file:/var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb-src file:/var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb file:/var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src file:/var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb file:/var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src file:/var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb file:/var/spool/apt-mirror/mirror/security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb-src file:/var/spool/apt-mirror/mirror/security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
```
6.更新本地源
```bash
sudo apt-get update
```
现在你已经成功地在Ubuntu上制作了apt本地源。你可以在不需要连接到互联网的情况下使用这些本地源来安装软件包和更新系统。
阅读全文