ubuntu18.04 本地源制作

本文详细介绍了在Ubuntu18.04中如何配置本地源,包括创建目录、拷贝deb文件、生成索引文件及Release文件、生成签名等步骤。同时,提供了针对apt版本低于1.5的无签名本地源生成方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Ubuntu 18.04中的apt-get版本为1.6.8。 如果你使用的ubuntu版本较低,apt版本低于1.5,可使用简单的方法配置本地源。简单方法见第二部分。

第一部分,ubuntu18.04上制作本地源

步骤有:

一 创建目录:mkdir repository

 

二 拷贝deb文件到目录 cp /path/to/*.deb repository/

 

三 进入目录生成索引文件及Release文件

cd repository

apt-ftparchive packages . > Packages

apt-ftparchive release . > Release

 

四 生成签名

gpg --clearsign -o InRelease Release

如果这一步报如下错误:

root@serverdeb:/media/debs# gpg --clearsign -o InRelease Release
gpg: no default secret key: Unusable secret key
gpg: Release: clear-sign failed: Unusable secret key

 

说明需要生成gpg签名,步骤如下:

1. gpg --gen-key

对于生成签名,详细见如下:https://blog.csdn.net/qdujunjie/article/details/48291017

如果生成签名卡住(原因详见:https://www.cnblogs.com/styshoo/p/6415939.html),执行如下命令:rng -r /dev/urandom    /// 前提是安装:apt-get install rng-tools

2. gpg -a --export pub_id | apt-key add -

root@server10:/media/debs# apt-get update
Get:1 file:/media/debs  InRelease [1912 B]
Get:1 file:/media/debs  InRelease [1912 B]
Err:1 file:/media/debs  InRelease                                              
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5789843F6B61B0B4
Hit:2 http://apt.postgresql.org/pub/repos/apt xenial-pgdg InRelease            
Reading package lists... Done                        

gpg -a --export 5789843F6B61B0B4 | apt-key add -     ///其中pub key可用gpg --list-keys查到

 

五 gpg -abs -o Release.gpg Release

 

最后执行apt-get update的输出如下 :

root@server10:/media/debs# apt-get update
Get:1 file:/media/debs  InRelease [1912 B]
Get:1 file:/media/debs  InRelease [1912 B]
Get:2 file:/media/debs  Packages [74.1 kB]                                      
Hit:3 http://apt.postgresql.org/pub/repos/apt xenial-pgdg InRelease             
Reading package lists... Done
 
=======================================
第二部分 无签名本地源制作
apt 版本低于1.5,无须签名的本地源生成方法:
原文:https://blog.csdn.net/zp2006011242/article/details/79040172
1、在可以上网的ubuntu设备上,对想要离线安装的组件进行预处理。

(1)清理apt的下载缓存区。

sudo rm -rf /var/cache/apt/archives/*

(2)下载所需要的组件

sudo apt-get -d install <包名>

(3)创建一个目录,将下载的包拷贝到该目录下

cp -r /var/cache/apt/archives  /yout-path

(4)修改目录权限

 chmod 777 -R /your-path

(5)建立deb包的依赖关系

    sudo touch /your-path/Packages.gz
    sudo dpkg-scanpackages /your-path/ /dev/null  | gzip > /your-path/Packages.gz

(6)将所有下载的文件和生成的gz文件拷贝到离线的ubuntu机器上,将/etc/apt/sources.list原有内容注释掉,新增:

deb file:///var/debs/ /

(7)执行sudo apt-get update,之后就可以直接使用apt-get install 包名 来安装了
如果上面的步骤中报错说
The repository 'file:/media debs/ Release' does not have a Release file.
 可用apt-get update --allow-insecure-repositories,这个时侯错误就会变成警告,也能正常安装软件。
 
=========================
FYI:

1. 为何apt-get 1.5版本后需要签名
man apt-secure
Starting with version 0.6, APT contains code that does signature checking of the Release file for all repositories. This ensures that data like packages in the archive can't be
       modified by people who have no access to the Release file signing key. Starting with version 1.1 APT requires repositories to provide recent authentication information for
       unimpeded usage of the repository. Since version 1.5 changes in the information contained in the Release file about the repository need to be confirmed before APT continues to
       apply updates from this repository.
 
2. 签名的方法出处
man apt-secure
其中REPOSITORY CONFIGURATION中
If you want to provide archive signatures in an archive under your maintenance you have to:

       ·   Create a toplevel Release file, if it does not exist already. You can do this by running apt-ftparchive release (provided in apt-utils).

       ·   Sign it. You can do this by running gpg --clearsign -o InRelease Release and gpg -abs -o Release.gpg Release.

       ·   Publish the key fingerprint, so that your users will know what key they need to import in order to authenticate the files in the archive. It is best to ship your key in its
           own keyring package like Ubuntu does with ubuntu-keyring to be able to distribute updates and key transitions automatically later.

       ·   Provide instructions on how to add your archive and key. If your users can't acquire your key securely the chain of trust described above is broken. How you can help users
           add your key depends on your archive and target audience ranging from having your keyring package included in another archive users already have configured (like the default
           repositories of their distribution) to leveraging the web of trust.

       Whenever the contents of the archive change (new packages are added or removed) the archive maintainer has to follow the first two steps outlined above.

转载于:https://www.cnblogs.com/longchang/p/11088411.html

### 如何使用U盘制作Ubuntu 18.04系统的启动盘 #### 准备工作 在开始制作启动盘前,需准备以下工具和资源: - Ubuntu 18.04 的 ISO 镜像文件。可以从官方或可信的镜像站点下载该文件[^3]。 - 一台运行 Windows 或 Linux 系统的计算机。 - 一个容量至少为 4GB 的 U 盘。 #### 使用 UltraISO 制作启动盘 UltraISO 是一款功能强大的光盘映像处理软件,也可以用于制作启动盘。以下是具体操作方法: 1. **下载并安装 UltraISO** 访问官方网站或其他可靠渠道下载 UltraISO 软件,并完成安装[^2]。 2. **加载 ISO 文件到 UltraISO** 打开 UltraISO 后,在菜单栏中选择 `文件` -> `打开`,定位至已下载的 Ubuntu 18.04 ISO 文件并加载它。 3. **进入写入硬盘映像模式** 在菜单栏中依次点击 `启动` -> `写入硬盘映像`,弹出写入选项窗口。 4. **配置写入参数** - 在 “硬盘驱动器” 中选择目标 U 盘设备。 - 将写入方式设置为 USB-HDD+。 - 如果需要自定义引导扇区,可以选择 syslinux 并确认其路径正确无误。 - 单击“写入”,等待过程结束即可。 #### 使用 Rufus 工具(推荐) Rufus 是另一款简单易用的免费工具,尤其适合于 Windows 用户。以下是详细步骤: 1. **获取 Rufus** 前往 Rufus 官方网站下载最新版本的应用程序。 2. **插入 U 盘并启动 Rufus** 插上空白 U 盘后运行 Rufus 应用程序,无需额外安装。 3. **设定基本选项** - 设备部分会自动检测当前连接的 U 盘。 - 在分区方案下拉框里选中默认值或者按照提示调整。 - 对于文件系统建议保留 FAT32 格式以便兼容更多硬件环境。 4. **导入 ISO 映像** 点击界面上的小图标按钮浏览本地存储位置找到预先保存下来的 ubuntu .iso 文件上传进去。 5. **执行创建流程** 检查所有设置均符合预期之后按下「START」键正式开始刻录进程直到显示完成消息为止。 ```bash # 示例命令行验证启动盘是否可用(仅限Linux) sudo dd if=/dev/sdX of=~/ubuntu1804.img bs=4M status=progress && sync ``` 以上两种方法均可有效实现基于 U 盘的 Ubuntu 18.04 启动介质构建任务,请依据个人偏好挑选合适的方式实践尝试吧!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值