[关闭]
@zhongdao 2019-09-23T10:27:08.000000Z 字数 25487 阅读 1789

InstallCDCustomization 安装/定制(中英对照)

未分类


InstallCDCustomization 安装 / 定制

Introduction 引言

The process of customizing or "remastering" Ubuntu installation CDs is not especially complex, but it is a little tedious and finicky.

自定义或“ remastering” Ubuntu 安装 cd 的过程并不是特别复杂,但是有点繁琐和挑剔。

The Ubuntu installation CD (since Ubuntu 6.06, the 'alternative install' or 'server' CD) has three main parts: a boot-loader (ISOLINUX on AMD64/x86 systems, yaboot on PowerPC) and its configuration (which starts everything up); debian-installer (also known as d-i, which in this case is really a specialized miniature Ubuntu system); and a Debian-style repository structure, which is what takes up disk space in the directories "pool" and "dists". Building a new CD may involve modifications to all three parts.

Ubuntu 安装光盘(自 Ubuntu 6.06以来,‘ alternative install'或‘ server'CD)有三个主要部分:

This page shows a simple recipe for customizing the CD. It assumes that you copy the contents of the installation CD to /opt/cd-image/ on your local system and create a couple of other dirs in /opt/. Modify as needed.

这个页面展示了一个自定义 CD 的简单配方。 它假设您将安装 CD 的内容复制到本地系统上的 / opt / CD-image / ,并在 / opt / 中创建两个其他目录。 根据需要进行修改。

IconsPage/note.png You might speed up the development cycle by using a virtual Ubuntu session, for example, using VirtualBox. You can then use the .ISO file to test rather than burning a CD. If you do, please note that you need to perform ALL operations described here on the GUEST system. Note that with VirtualBox, during an installation (Host key)-F4 will display the installation output and (Host key)-F1 will return you to the general status screen. Note that the host key is set to the right Ctrl key by default.

您可以通过使用虚拟 Ubuntu 会话来加快开发周期,例如,使用 VirtualBox。 然后,你可以使用。 测试 ISO 文件而不是烧录 CD。 如果需要,请注意您需要在 GUEST 系统上执行这里描述的所有操作。 请注意,使用 VirtualBox,在安装过程中(主机键)-F4将显示安装输出,(主机键)-F1将返回常规状态屏幕。 注意,默认情况下,主机键被设置为正确的 Ctrl 键。

IconsPage/note.png This guide is for the 'Alternative Install' or 'Server Install' CDs. There is a page referring to customization of the Desktop (Live) CD, and another guide on how to create a Live CD without using an existing CD at all.

本指南适用于“替代安装”或“服务器安装”光盘。 这里有一个页面提到了桌面(Live) CD 的定制,还有一个页面提到了如何不使用现有 CD 创建 Live CD。

Although the 'Server Install' images are supposed to fit on usual CD media, you may as well use DVD or BD (Blu-ray) media. In the following text, read "CD" as "CD, DVD, or BD".

虽然“服务器安装”映像应该适合在通常的 CD 媒体,你也可以使用 DVD 或 BD (蓝光)媒体。 在下面的文本中,将“ CD”读作“ CD、 DVD 或 BD”。

At least since release 12.04, the images also work from USB stick or other hard-disk-like storage devices. USB stick on amd64 UEFI works since 14.04.

至少从12.04版本发布以来,这些图像还可以在 u 盘或其他类似硬盘的存储设备上工作。 Amd64 UEFI 上的 usb 盘自14.04开始工作。

Get the ISO 获取 ISO

下面是你可以使用的原始图片列表:

Type类型 **Ubuntu 14.04 LTS**14.04 LTS **Ubuntu 16.04 LTS**16.04 LTS **Ubuntu 18.04 LTS**18.04 LTS **Ubuntu 18.10**18.10
Alternate交替 n/a不知道 n/a不知道 n/a不知道 n/a不知道
Server伺服器 i386|amd64386 | amd64 i386|amd64386 | amd64 amd64 amd64

随着时间的推移,一些将会消失或被取代。 但是 releases.ubuntu.com 将会继续显示一个可用的版本目录列表,包括一些服务器。 里面有 iso 图像。

Copy the CD to your hard drive 把 CD 拷贝到你的硬盘上

将整个安装 CD 复制到硬盘上的某个目录中。 本指南将假设您的 CD 映像位于 / opt / CD-image / 中,但是您可以将其放置在任何您喜欢的位置。 它将占用大约1gb 的硬盘空间。

If you have an ISO file, you can mount it and copy files out of it without burning it to CD:

如果你有一个 ISO 文件,你可以挂载它并拷贝文件,而不需要烧录到 CD:

  1. mount -o loop /path/to/iso /some/mountpoint

Use "Gmount-iso" program for a GUI method of mounting iso files. You can also try "ISO Master" to access the iso file directly without mounting.

使用“ Gmount-iso”程序安装 iso 文件的 GUI 方法。 您也可以尝试“ isomaster”来直接访问 ISO 文件,而无需挂载。

You can use rsync to copy the CD:

你可以使用 rsync 来复制 CD:

  1. rsync -av /cdrom/ /opt/cd-image

或者只是

  1. mkdir -p /opt/cd-image
  2. cp -rT /cdrom /opt/cd-image

注意: mkdir 的-p 选项将创建不存在的 leadin 目录。 在这个示例中,如果 / opt 不存在,则创建它。

Be sure to catch the folder .disk - if you try and copy /cdrom/*, it will ignore the .disk folder, as Bash expands the * to mean "everything it can see".

一定要抓住这个文件夹。 Disk-如果尝试复制 / cdrom / * ,它会忽略。 磁盘文件夹,当 Bash 将 * 扩展为“它可以看到的所有东西”时。

If you use a filemanager program like Nautilus, be sure to launch it with "gksu nautilus" and mark "Show Hidden Files" from "View" menu or you miss some important files. After the copy is done, change file ownership from "root" if you don't plan to do the rest of the work with sudo.

如果你使用像 Nautilus 这样的文件管理器程序,一定要用“ gksu Nautilus”和“ View”菜单中的“ Show Hidden Files”来启动它,否则你会错过一些重要的文件。 复制完成后,如果您不打算使用 sudo 完成剩下的工作,那么可以从“ root”更改文件所有权。

Modify installer behaviour using a Preseed file 使用 preeed 文件修改安装程序的行为

当 CD 启动时,将启动 Linux 内核并启动安装任务。 安装程序的默认行为可以通过使用“ preeed”文件来修改,该文件将 d-i 的答案提供给 debconf 或其他上下文中通常提出的问题。 如果您查看安装 CD 中的 preeed 文件夹,您将看到某些选项(例如“ server”、“ expert”、“ oem”)已经为它们分配了预设文件。 安装指南中有一个关于预置的详细附录。

Suppose you are installing Ubuntu on a bunch of identical computers, and you already know the answers to certain questions (what country and time zone you're in, what keyboard you have, how the network should be configured, how you want to partition the hard disk, etc). You can "preseed" the answers to these questions in a very simple configuration file. There're several ways to setup the boot-loader configuration.

假设你正在一堆相同的计算机上安装 Ubuntu,而且你已经知道某些问题的答案(你在哪个国家和时区,你有什么键盘,网络应该如何配置,你想如何分区硬盘,等等)。 您可以在一个非常简单的配置文件中“预设”这些问题的答案。 有几种方法可以设置引导加载程序配置。

Changing isolinux.cfg to identify your preseed

我们将创建一个名为“ firewall.seed”的预播放文件,该文件将存放在 CD-ROM 的 / preeed 文件夹中。 我们通过修改位于 isolinux / isolinux 中的引导加载程序配置文件来告诉 d-i 在哪里可以找到这个文件。 Cfg (或者在8.10或更高版本中,isolinux / text。 Cfg) ,以便在内核命令行上传递适当的参数。 在 / opt / cd-image / isolinux / isolinux.cfg 中,添加一个新节,标记如下:

  1. LABEL firewall
  2. menu label ^Firewall installation
  3. kernel /install/vmlinuz
  4. append preseed/file=/cdrom/preseed/firewall.seed debian-installer/locale=en_NZ console-setup/layoutcode=us initrd=/install/initrd.gz ramdisk_size=16384 root=/dev/ram rw quiet --

If you want to set the default selected menu item to your custom seed, change the DEFAULT line to read 'DEFAULT firewall'.

如果要将默认选择的菜单项设置为自定义种子,请将 DEFAULT 行更改为“ DEFAULT firewall”。

For totally automatic installation with a predefined language (in this example, Estonian), you need to add some more parameters:

要使用预定义的语言(在本例中是爱沙尼亚语)完全自动安装,您需要添加一些更多的参数:

  1. LABEL firewall
  2. menu label ^Firewall installation (Estonian)
  3. kernel /install/vmlinuz
  4. append file=/cdrom/preseed/firewall.seed debian-installer/locale=et_EE console-setup/layoutcode=et localechooser/translation/warn-light=true localechooser/translation/warn-severe=true initrd=/install/initrd.gz ramdisk_size=16384 root=/dev/ram rw quiet
  5. --

To make the installer autochoose the default option and start installing after a timeout, add this line to isolinux/isolinux.cfg (in all versions).

要使安装程序自动选择默认选项并在超时后开始安装,请将此行添加到 isolinux / isolinux。 Cfg (在所有版本中)。

  1. timeout 10

超时值以十分之一秒为单位,因此超时值10等于一秒。

You must specify a locale and keyboard on the command line, as these questions are asked before the seed is loaded. You can also set DEBCONF_PRIORITY here to ensure you don't see any unnecessary debconf questions.

您必须在命令行上指定区域设置和键盘,因为在加载种子之前会询问这些问题。 你也可以在这里设置 DEBCONF 的优先级,以确保你不会看到任何不必要的借款保留问题。

(On Ubuntu 6.06 and older, use kbd-chooser/method=us rather than console-setup/layoutcode=us.)

(在 Ubuntu 6.06及以上版本中,使用 kbd-chooser / method us 而不是控制台-setup / layoutcode us.)

Changing grub.cfg to identify your preseed

我们将创建一个名为“ custom.seed”的预播放文件,该文件将存放在 CD-ROM 的 / preeed 文件夹中。 我们通过修改 boot / grub / grub 中的引导加载程序配置文件来告诉 d-i 在哪里可以找到这个文件。 在内核命令行上传递适当的参数。 在 / opt / cd-image / boot / grub / grub 中。 Cfg,添加一个标记如下的新部分:

  1. menuentry "Install Ubuntu Server custom" {
  2. set gfxpayload=keep
  3. linux /install/vmlinuz file=/cdrom/preseed/custom.seed debian-installer/locale=en_US console-setup/layoutcode=us quiet ---
  4. initrd /install/initrd.gz
  5. }

Writing the preseed file 编写预播放文件

一个提前播放的文件每行有4个字段:

  1. identity of the program which will pick up this command 接收这个命令的程序的身份
  2. name of the variable whose value will be passed 值将被传递的变量的名称
  3. variable type 变量类型
  4. value of variable 变量值

It looks something like this (from the default ubuntu-server.seed on the 16.04 CD):

它看起来是这样的(从默认的 ubuntu-server。 16.04 CD 上的种子) :

  1. # Suggest LVM by default.
  2. d-i partman-auto/init_automatically_partition string some_device_lvm
  3. d-i partman-auto/init_automatically_partition seen false
  4. # Install the Ubuntu Server seed.
  5. tasksel tasksel/force-tasks string server
  6. # Only install basic language packs. Let tasksel ask about tasks.
  7. d-i pkgsel/language-pack-patterns string
  8. # No language support packages.
  9. d-i pkgsel/install-language-support boolean false
  10. # Only ask the UTC question if there are other operating systems installed.
  11. d-i clock-setup/utc-auto boolean true
  12. # Verbose output and no boot splash screen.
  13. d-i debian-installer/quiet boolean false
  14. d-i debian-installer/splash boolean false
  15. # Install the debconf oem-config frontend (if in OEM mode).
  16. d-i oem-config-udeb/frontend string debconf
  17. # Wait for two seconds in grub
  18. d-i grub-installer/timeout string 2
  19. # Add the network and tasks oem-config steps by default.
  20. oem-config oem-config/steps multiselect language, timezone, keyboard, user, network, tasks

IconsPage/important.png d-i expects there to be exactly one tab or space between variable type and variable value (any other space is seen as being part of the value)

D-i 期望在变量 type 和变量值之间只有一个制表符或空格(任何其他空格都被视为值的一部分)

The easiest way to create a preseed file is to start with an example and modify it:

创建一个 preeed 文件最简单的方法是从一个例子开始并修改它:

  1. The Ubuntu installation guide (16.04) has examples of many common preseed directives. (Bear in mind that you may need to modify some to work on older versions.)

    Ubuntu 安装指南(16.04)有许多常见的预设定指令示例。 (请记住,您可能需要修改一些以适用于旧版本。)

  2. You could check out Debian's wiki page on preseeding the installer - 6.06 and higher are aligned with Etch and newer versions of the Debian installer, although there are some important differences that apply to preseeding.

    您可以查看 Debian 的 wiki 页面,关于 preeding 的安装程序-6.06和更高版本与 Etch 和 Debian 安装程序的新版本保持一致,尽管有一些重要的区别适用于 preeding。

  3. If you can't find the option you're looking for you can generate a comprehensive preseed file based on your own install time choices by using debconf-get-selections

    如果找不到所需的选项,可以使用 deconf-get-selections 根据自己的安装时间选择生成一个全面的预设文件

debconf-get-selections usage:

获取选择的使用:

  1. sudo apt-get install debconf-utils # It is part of the debconf-utils package.
  2. debconf-get-selections --installer > somefile.txt
  3. debconf-get-selections >> somefile.txt

这将输出您在整个安装过程中选择的所有 debconf 选项的列表; 您可以从中选择选项并将它们放到您的 preeed 文件中。

IconsPage/warning.png debconf-get-selections prints 2 spaces between variable type and variable value. You need to change this to one space before putting the line in a preseed file.

在变量类型和变量值之间打印两个空格。 在将该行放入一个提前播放的文件之前,需要将其更改为一个空格。(4列中的最后2列之间的空格)

Installing extra packages in your preseed file 在您的预播放文件中安装额外的包

Base-config 自 Ubuntu 6.06以来就已经从 Ubuntu Debian安装程式中移除了。

In Ubuntu 6.06 and older:

在 Ubuntu 6.06及以上版本中:

  1. d-i pkgsel/install-pattern string ~t^ubuntu-standard$|~n^openssh-server$

在 Ubuntu 8.04及更新版本中: (软件包可以用逗号和 / 或空格分隔,并用反斜杠继续到另一行) :

  1. d-i pkgsel/include string gstreamer0.10-plugins-base \
  2. gstreamer0.10-plugins-good \
  3. gstreamer0.10-plugins-ugly \
  4. gstreamer0.10-plugins-bad

安装程序不能安装那些依赖于通常在已安装的系统中运行的服务,但是不能在 Debian 安装程序的环境中运行的软件包。 其中一个例子是在安装时创建或修改数据库,并要求运行 postgresql 或 mysql 服务器的包。 在这种情况下,您需要使用 postinst 脚本,在 / target chroot 中启动必要的数据库服务器,然后调用“ apt-install”(如果在 chroot 环境之外)或 apt-get (在 chroot 中)。

Installing language support 安装语言支持

使用不同的机制来安装其他语言。 预先准备好安装程序以专家模式提出的详细的现场问题。 请参阅 / usr / share / i18n / SUPPORTED 的第一列了解您可以在这里使用的语言环境名称。 例如,要添加对孟加拉语和泰米尔语的支持,可以这样写:

  1. d-i localechooser/supported-locales multiselect bn_IN, ta_IN

Running a Final Script 最后运行脚本

You can run a script in the final part of the installation. The following example runs a script that has been copied onto the installation CD in the setup/install folder. This script runs in the target environment, thus can run scripts in any language (e.g. Python or Perl) that has been installed on the target system.

您可以在安装的最后部分运行脚本。 下面的示例运行一个已复制到安装 / 安装文件夹中的安装 CD 上的脚本。 这个脚本在目标环境中运行,因此可以用目标系统上安装的任何语言(例如 Python 或 Perl)运行脚本。

  1. d-i preseed/late_command string chroot /target bash /cdrom/setup/install/settings.sh

上面的命令可能在8.10或更高版本上不起作用; 要将脚本复制到目标并执行它,请尝试以下操作:

  1. d-i preseed/late_command string cp /cdrom/finisher/finisher.sh /target/root/; chroot /target chmod +x /root/finisher.sh; chroot /target bash /root/finisher.sh

通常,通过 late 命令从 seed 文件运行的脚本不能与用户交互。 如果你需要互动,通常有三种选择:

IconsPage/warning.png A preseed script run via late_command that attempts to run "chroot /target apt-get ..." (or similar) may run into problems (e.g. file descriptor 3 not found in the postinst stage of some packages, dash being one example). This is caused by your script inheriting environment variables from the already running installer. To solve this, clear the environment variables in your script before calling apt-get:

通过 late 命令运行的 preeed 脚本试图运行“ chroot / target apt-get... ”(或类似的命令)可能会遇到问题(例如,在某些软件包的 postinst 阶段中没有找到文件描述符3,dash 就是其中一个例子)。 这是由于您的脚本从已经运行的安装程序继承环境变量造成的。 要解决这个问题,请在调用 apt-get 之前清除脚本中的环境变量:

  1. unset DEBCONF_REDIR
  2. unset DEBCONF_FRONTEND
  3. unset DEBIAN_HAS_FRONTEND
  4. unset DEBIAN_FRONTEND

Modify pool structure to include more packages 修改池结构以包含更多的包

可能构建自己的安装 CD 的主要动机是修改安装了哪些包; 特别是您可能希望向 CD 添加一些包。

The easiest way to do this is to build an 'extras' repository structure, containing only your extra .debs, and merge these into the CD file hierarchy before rebuilding the .ISO image. This guide will step you through how to do this.

最简单的方法是构建一个‘extras'存储库结构,只包含您的额外内容。 方法,并将它们合并到 CD 文件层次结构中。 Iso 图像。 本指南将指导你如何做到这一点。

This requires you to generate the Packages files that defines what files are in your repository; the Release file that indexes your Packages files, and the signed Release.gpg file, approving the repository as being official.

这需要您生成定义存储库中有哪些文件的 Packages 文件; 为包文件建立索引的 Release 文件,以及签名的 Release.gpg 文件,这些文件都认可存储库是正式的。

Create an "Extras" component 创建一个“ Extras”组件

下面的示例引用了 Ubuntu 16.04(“ xenial”)。 在适当的地方替换你的版本。

Create directories for your new component (substituting your version where appropriate):

为您的新组件创建目录(适当地替换您的版本) :

  1. cd /opt/cd-image
  2. mkdir -p pool/extras/

把你想要的所有额外的. debs 放到 CD 里,放到pool / 临时演员里。

On the scripts page there is a useful script that will strip out all of the packages from your CD image that are not currently installed. You will need to run apt-ftparchive (below) to generate the Packages file.

在脚本页面上有一个有用的脚本,它将从 CD 映像中删除当前没有安装的所有包。 您需要运行 apt-ftparchive (如下所示)来生成 Packages 文件。

Generating a new ubuntu-keyring .deb to sign your CD生成一个新的 ubuntu-keyring. deb 来为您的 CD 签名

为了签署发布文件,我们需要使用 GPG。 然后,安装系统将根据 ubuntu-keyring 包中的公钥检查签名。 您没有与 ubuntu-keyring 中的一个密钥匹配的私钥,因此我们需要构建一个自定义版本的 ubuntu-keyring 包。 如果您还没有 gnupg 包,那么就安装它。

To create a signing key, enter gpg --gen-key. Accept the defaults, (for this use, it is probably OK to use "No expiry"). For your Real Name and E-mail address, you might like to use something like "XXX Signing Key" and "packages@xxx.example.org". Enter an appropriate passphrase.

要创建签名密钥,请输入 gpg -- gen-key。 接受默认值,(对于这种用法,可以使用“无失效”)。 对于您的真实姓名和电子邮件地址,您可能希望使用“ XXX 签名键”和“ packages@XXX. example. org”之类的内容。 输入适当的密码。

In another directory (I use /opt/build/), we will download the source for the ubuntu-keyring package, unpack it, add our own GPG key, and rebuild the package. These steps import the 2 Ubuntu public signing keys into your main keyring, then exports them, along with your own public signing key, into a replacement keyring. "YOURKEYID" should be replaced with the 8-digit hexadecimal code that gpg tells you when you do the --list-keys command. "Signing Key Name" is what you used in the previous step, when running gpg --gen-key.

在另一个目录(我使用 / opt / build /)中,我们将下载 ubuntu-keyring 包的源代码,解压缩它,添加我们自己的 GPG 密钥,然后重新构建包。 这些步骤将2个 Ubuntu 公共签名密钥导入到您的主密钥环中,然后将它们连同您自己的公共签名密钥导出到一个替换密钥环中。 “ YOURKEYID”应该替换为 gpg 告诉您何时执行 -- list-keys 命令的8位十六进制代码。 “签名密钥名称”是您在上一步中运行 gpg -- gen-Key 时使用的名称。

To clarify, below is an example 'gpg --list-keys' response. In this example, "YOURKEYID" immediately follows the '/' on the line beginning with 'pub' (which in this example is '437D05B5'.)

为了澄清,下面是一个例子“ gpg -- list-keys”响应。 在这个例子中,“ YOURKEYID”紧跟在以“ pub”开头的行中的“ / ”之后(在这个例子中是“437D05B5”)

  1. gpg --list-keys
  2. pub 1024D/437D05B5 2006-09-08
  3. uid XXX Signing Key <packages@xxx.example.org>
  4. sub 2048g/79164387 2006-09-08

如果您更改了包的版本号(例如使用 dch) ,那么请确保您选择的版本号不包含“-”字符: 如果包包含了“-”字符,那么您将从“本机”格式转换包,您将不得不执行一些额外的步骤。 使用版本号比较简单,如“2012.05.19 + custom1” ,将首选的本地部件放在“ + ”字符后面。

Here is an example, which you will need to customize to suit your own setup:

下面是一个例子,你需要自定义来适应你自己的设置:

IconsPage/important.png The following example references Ubuntu 16.04 ("xenial"). Substitute your version where appropriate.

下面的示例引用了 Ubuntu 16.04(“ xenial”)。 在适当的地方替换你的版本。

  1. cd /opt/build
  2. sudo apt-get install fakeroot # requires the fakeroot package which may not be installed on your system.
  3. apt-get source ubuntu-keyring
  4. cd ubuntu-keyring-2012.05.19/keyrings
  5. gpg --import < ubuntu-archive-keyring.gpg
  6. gpg --list-keys "Signing Key Name"
  7. gpg --export FBB75451 437D05B5 C0B21F32 EFE21092 YOURKEYID > ubuntu-archive-keyring.gpg
  8. cd .. # you are now on ubuntu-keyring-2012.05.19
  9. dpkg-buildpackage -rfakeroot -m"Your Name <your.email@your.host>" -kYOURKEYID
  10. cd .. # you are now on the directory where you started, in the example, /opt/build
  11. cp ubuntu-keyring*deb /opt/cd-image/pool/main/u/ubuntu-keyring

你最终会得到一个用于安装程序的 udeb 文件和一个。 系统的 deb 文件。 这两个文件都需要复制到 CD 的主要组件中,因为 CD 不会检查 extras 目录。

Generate a new filesystem.squashfs with the updated ubuntu-archive-keyring.gpg

为了避免在安装过程中可能出现的问题,我们需要通过更新 ubuntu-archive-keyring 来重新生成 filestem.squashfs。 我们刚刚出口的 gpg。 被替换的途径有三种:

Furthermore, filesystem.size also needs to be updated:

此外,filesystem.size 也需要更新:

  1. cd new-squashfs-root
  2. du -sx --block-size=1 ./ | cut -f1 > /opt/cd-image/install/filesystem.size

Building the repository with apt-ftparchive 使用 apt-ftparchive 构建存储库

Apt-ftparchave 构建安装程序所需的软件包和 Packages.gz 文件。 为了使用 apt-ftparchive,我们需要为它提供一些配置和一些索引文件。

IconsPage/important.png If you will be adding .deb files to pool/universe (eg. customizing xubuntu) you will also need to wget extra.universe and universe files.

如果你要添加。 Deb 文件到 pool / universe (例如。 定制 xubuntu)你还需要 wget extra.universe 和 universe 文件。

We will put the index files in /opt/indices:

我们将把索引文件放入 / opt / 索引:

  1. mkdir -p /opt/indices /opt/apt-ftparchive
  2. cd /opt/indices/
  3. DIST=xenial
  4. for SUFFIX in extra.main main main.debian-installer restricted restricted.debian-installer; do
  5. wget http://archive.ubuntu.com/ubuntu/indices/override.$DIST.$SUFFIX
  6. done

创建 apt-ftparchave-deb 文件。 / conf,apt-ftparchave-udeb. Conf,apt-ftparchave-extras. 在目录(/ opt / apt-ftparchive)中使用 / opt / CD-image / 替换 CD 映像目录的路径,如果索引文件不同,则使用 / opt / indexes / 替换索引文件的位置。

IconsPage/important.png The .conf files shown here are sufficient if you are ONLY making changes to .deb files under pool/main and pool/restricted. If you are adding security updates to a Xubuntu customized CD, though, you will be updating .deb files under pool/universe also, so you will need to add lines to apt-ftparchive-deb.conf for universe, similar to the lines shown for main. You will also need to run extraoverride.pl for universe as well as for main - see below.

这个。 这里显示的 conf 文件已经足够了,如果你只是修改。 在 pool / main 和 pool / restricted 下的 deb 文件。 如果你正在为 Xubuntu 定制的 CD 添加安全更新,你将会更新。 也可以在 pool / universe 下添加 deb 文件,所以需要添加 apt-ftparchive-deb 行。 对于 universe,类似于 main 的代码行。 你还需要为 universe 和 main 运行 extraoverride.pl -参见下面。

/opt/apt-ftparchive/apt-ftparchive-deb.conf:

/ opt / apt-ftparchave / apt-ftparchave-deb. 配音:

The ExtraOverride component above is needed to add the Task: line to main packages, referenced from the preseed file with ~t. This is not supplied - but can be extracted from the existing main Packages file with the simple perl script below.

需要使用上面的 ExtraOverride 组件将 Task: line 添加到主包,该组件从带有 ~ t 任务名称的 preeed 文件中引用。 这是不提供-但可以提取现有的主包文件与简单的 perl 脚本下面。

  1. \#!/usr/bin/env perl
  2. # extraoverride.pl
  3. # generate ExtraOverride file
  4. # use as follows :-
  5. # extraoverride.pl < /opt/cd-image/dists/xenial/main/binary-amd64/Packages >> /opt/indices/override.xenial.extra.main
  6. while (<>) {
  7. chomp;
  8. next if /^ /;
  9. if (/^$/ && defined($task)) {
  10. print "$package Task $task\n";
  11. undef $package;
  12. undef $task;
  13. }
  14. ($key, $value) = split /: /, $_, 2;
  15. if ($key eq 'Package') {
  16. $package = $value;
  17. }
  18. if ($key eq 'Task') {
  19. $task = $value;
  20. }
  21. }

IconsPage/note.png If customizing Xubuntu, and adding new .deb files to pool/universe, run this script for the universe repository also.

如果定制 Xubuntu,并添加新的。 把 deb 文件放到 pool / universe 中,同时运行这个 universe 仓库的脚本。

IconsPage/note.png The ExtraOverride process can be optional to skip it.

可以选择是否跳过 ExtraOverride 进程。

/opt/apt-ftparchive/apt-ftparchive-udeb.conf:

/ opt / apt-ftparchave / apt-ftparchave-udeb. 配音:

  1. Dir {
  2. ArchiveDir "/opt/cd-image/";
  3. };
  4. TreeDefault {
  5. Directory "pool/";
  6. };
  7. BinDirectory "pool/main" {
  8. Packages "dists/xenial/main/debian-installer/binary-amd64/Packages";
  9. BinOverride "/opt/indices/override.xenial.main.debian-installer";
  10. };
  11. BinDirectory "pool/restricted" {
  12. Packages "dists/xenial/restricted/debian-installer/binary-amd64/Packages";
  13. BinOverride "/opt/indices/override.xenial.restricted.debian-installer";
  14. };
  15. Default {
  16. Packages {
  17. Extensions ".udeb";
  18. Compress ". gzip";
  19. };
  20. };
  21. Contents {
  22. Compress "gzip";
  23. };

/opt/apt-ftparchive/apt-ftparchive-extras.conf:

/ opt / apt-ftparchave / apt-ftparchave-extras. 配音:

  1. Dir {
  2. ArchiveDir "/opt/cd-image/";
  3. };
  4. TreeDefault {
  5. Directory "pool/";
  6. };
  7. BinDirectory "pool/extras" {
  8. Packages "dists/xenial/extras/binary-amd64/Packages";
  9. };
  10. Default {
  11. Packages {
  12. Extensions ".deb";
  13. Compress ". gzip";
  14. };
  15. };
  16. Contents {
  17. Compress "gzip";
  18. };

IconsPage/important.png You need to build the Packages file in dists/xenial/extras/binary-amd64/Packages using dpkg-scanpackages. See here for an explanation.

您需要使用 dpkg-scanpackages 在 dists / xenial / extras / binary-amd64 / Packages 中构建 Packages 文件。 请看这里的解释。

IconsPage/important.png The following example of creating Packages references Ubuntu 16.04 ("xenial"). Substitute your version where appropriate. Use apt-ftparchive to finish above step.

以下创建软件包的示例引用了 Ubuntu 16.04(“ xenial”)。 在适当的地方替换你的版本。 使用 apt-ftparchive 完成上面的步骤。

  1. cd /opt/cd-image
  2. apt-ftparchive packages pool/extras > dists/stable/extras/binary-amd64/Packages
  3. gzip -c dists/stable/extras/binary-amd64/Packages | tee dists/stable/extras/binary-amd64/Packages.gz > /dev/null

/ opt / apt-ftparchave / release. conf

This is the configuration file for apt-ftparchive. Change to suit your distribution version:

这是 apt-ftparchive 的配置文件。 更改以适应您的发行版本:

  1. APT::FTPArchive::Release::Origin "Ubuntu";
  2. APT::FTPArchive::Release::Label "Ubuntu";
  3. APT::FTPArchive::Release::Suite "xenial";
  4. APT::FTPArchive::Release::Version "16.04";
  5. APT::FTPArchive::Release::Codename "xenial";
  6. APT::FTPArchive::Release::Architectures "amd64";
  7. APT::FTPArchive::Release::Components "main restricted extras";
  8. APT::FTPArchive::Release::Description "Ubuntu 16.04 LTS";

To build the repository, sign it, and update the MD5SUM file, you can use a script like this:

要构建存储库、签名并更新 MD5SUM 文件,您可以使用下面的脚本:

  1. BUILD=/opt/cd-image
  2. APTCONF=/opt/apt-ftparchive/release.conf
  3. DISTNAME=xenial
  4. pushd $BUILD
  5. apt-ftparchive -c $APTCONF generate /opt/apt-ftparchive/apt-ftparchive-deb.conf
  6. apt-ftparchive -c $APTCONF generate /opt/apt-ftparchive/apt-ftparchive-udeb.conf
  7. apt-ftparchive -c $APTCONF generate /opt/apt-ftparchive/apt-ftparchive-extras.conf
  8. apt-ftparchive -c $APTCONF release $BUILD/dists/$DISTNAME > $BUILD/dists/$DISTNAME/Release
  9. gpg --default-key "YOURKEYID" --output $BUILD/dists/$DISTNAME/Release.gpg -ba $BUILD/dists/$DISTNAME/Release
  10. find . -type f -print0 | xargs -0 md5sum > md5sum.txt
  11. popd

“ YOURKEYID”是您之前放入自己编译的 keyring 包中的密钥 id。

Preparing the bootable medium 准备可引导的媒介

此时,您已经有了一个目录,可以将其收集到。 Iso 文件,然后烧录成 CD 或复制到 u 盘。

Building the ISO image 建立 ISO 映像

X86和 AMD64

  1. IMAGE=custom.iso
  2. BUILD=/opt/cd-image/
  3. mkisofs -r -V "Custom Ubuntu Install CD" \
  4. -cache-inodes \
  5. -J -l -b isolinux/isolinux.bin \
  6. -c isolinux/boot.cat -no-emul-boot \
  7. -boot-load-size 4 -boot-info-table \
  8. -o $IMAGE $BUILD

X86和 AMD64同源杂交

The original i386 and amd64 ISOs have a Master Boot Record (MBR) which makes them bootable from USB stick via legacy BIOS firmware.

原来的 i386和 amd64 ISOs 有一个可以通过传统 BIOS 固件从 u 盘启动的主引导记录。

  1. # The MBR x86 machine code bytes from the original ISO are known to match
  2. # the isolinux.bin file inside that ISO. So copy them to a file in /tmp/.
  3. OLD_IMAGE=/path/to/iso
  4. MBR_FILE=/tmp/ubuntu_isohybrid_mbr.img
  5. dd if="$OLD_IMAGE" bs=1 count=446 of="$MBR_FILE"
  6. IMAGE=custom.iso
  7. BUILD=/opt/cd-image/
  8. xorriso -as mkisofs -r -V "Custom Ubuntu Install CD" \
  9. -cache-inodes -J -l \
  10. -isohybrid-mbr "$MBR_FILE" \
  11. -partition_offset 16 \
  12. -c isolinux/boot.cat \
  13. -b isolinux/isolinux.bin \
  14. -no-emul-boot -boot-load-size 4 -boot-info-table \
  15. -o "$IMAGE" \
  16. "$BUILD"
  17. "$BUILD"
  18. rm "$MBR_FILE"

Amd64与 UEFI 同源杂交

Additionally to the MBR for legacy BIOS, the amd64 ISOs since 14.04 can boot from CD and from USB stick via the modern UEFI firmware. Its entry point is marked for USB stick by the MBR partition entry 2, which points to the data content of file /boot/grub/efi.img. Together with UEFI bootability from CD this is achieved by the additional options from -eltorito-alt-boot to -isohybrid-gpt-basdat.

除了用于传统 BIOS 的 MBR 之外,amd64 ISOs 自14.04以来可以通过现代 UEFI 固件从 CD 和 USB 启动。 它的入口点通过 MBR 分区条目2标记为 USB 棒,该分区条目指向 file / boot / grub / efi 的数据内容。 Img. 与 UEFI 可从 CD 启动一起,这是通过从-eltorito-alt-boot 到-isohybrid-gpt-basdat 的附加选项实现的。

  1. OLD_IMAGE=/path/to/iso
  2. MBR_FILE=/tmp/ubuntu_isohybrid_mbr.img
  3. dd if="$OLD_IMAGE" bs=1 count=446 of="$MBR_FILE"
  4. IMAGE=custom.iso
  5. BUILD=/opt/cd-image/
  6. xorriso -as mkisofs -r -V "Custom Ubuntu Install CD" \
  7. -cache-inodes -J -l \
  8. -isohybrid-mbr "$MBR_FILE" \
  9. -c isolinux/boot.cat \
  10. -b isolinux/isolinux.bin \
  11. -no-emul-boot -boot-load-size 4 -boot-info-table \
  12. -eltorito-alt-boot \
  13. -e boot/grub/efi.img \
  14. -no-emul-boot -isohybrid-gpt-basdat \
  15. -o "$IMAGE" \
  16. "$BUILD"
  17. rm "$MBR_FILE"

电源 PC

Download the HFS map, then use the following command:

下载 HFS map,然后使用以下命令:

  1. IMAGE=custom.iso
  2. BUILD=/opt/cd-image/
  3. mkisofs -r -V "Custom Ubuntu Install CD" \
  4. --netatalk -hfs -probe -map hfs.map \
  5. -chrp-boot -iso-level 2 -part -no-desktop \
  6. -hfs-bless $BUILD/install \
  7. -hfs-volid Ubuntu/PowerPC_hardy \
  8. -o $IMAGE $BUILD
  1. IMAGE=custom.iso
  2. BUILD=/opt/cd-image/
  3. mkisofs -r -V 'Custom Ubuntu Install CD' \
  4. -o $IMAGE -no-emul-boot \
  5. -J -b boot/boot.img -c boot/boot.catalog $BUILD

Burning the image to CD, DVD, or Blu-ray 将映像烧录为 CD、 DVD 或蓝光

  1. sudo xorriso -as cdrecord dev=/dev/sr0 blank=as_needed -v $IMAGE

当代 gnu / linux 系统的第一个光驱具有 address / dev / sr0。 如果有疑问,运行以下命令了解现有驱动器及其 / dev 文件地址。

  1. sudo xorriso -devices

如果你的驱动器或媒体是旧的,那么你可能在实验这个过程中烧掉很多杯垫。 可重复使用的媒体可以减轻痛苦: CD-RW,DVD-RW,dvd + rw,DVD-RAM,BD-RE。

Putting an isohybrid image onto USB stick 将一个同功能混合图像放到 u 盘上

如果 x86和 AMD 图像是由 xorriso 制作的,并带有同功能混合选项,或者 x86和 AMD 图像是由 SYSLINUX 程序同功能混合后处理的,那么它也会从 u 盘或硬盘启动。

Such an image is not to be unpacked and installed to the USB stick by a program like 'Rufus' or 'UNetbootin', but rather to be written plainly to the base device file of the USB stick. This implies that the partition table of the stick will be overwritten and thus all data on the stick will become unaccessible, if not overwritten.

这样的映像不是要通过像 Rufus 或 UNetbootin 这样的程序解压并安装到 u 盘上,而是直接写到 u 盘的基本设备文件上。 这意味着棍子的分区表将被覆盖,因此棍子上的所有数据将变得不可访问,如果不被覆盖的话。

Verify device address or make a backup 验证设备地址或进行备份

在 gnu / linux 系统上的主要问题是,您需要超级用户能力来覆盖整个 USB 棒,而这种能力足以破坏您的硬盘内容。

So first verify that the device file address really leads to the intended device (e.g. by reading a few megabytes and watching it blink). If the USB stick is supposed to be Linux device "/dev/sdh":

因此,首先要验证设备文件地址是否真的指向目标设备(例如,读取几兆字节并观察它的闪烁)。 如果 u 盘应该是 Linux 设备” / dev / sdh” :

  1. sudo umount /dev/sdh*
  2. dd if=/dev/sdh of=/dev/null bs=1024 count=100000

or by making a backup of its complete content in a compressed disk file:

或者在压缩磁盘文件中备份完整的内容:

  1. sudo umount /dev/sdh*
  2. dd if=/dev/sdh | gzip >"$HOME"/red_usb_stick.gz

(Your /dev/sd address will probably end by a lower letter than "h". But this paragraph is all about not to spoil /dev/sda and other hard disks by mistake.)

(您的 / dev / sd 地址可能以小于“ h”的字母结尾。 但是这个段落完全是为了不要错误地破坏 / dev / sda 和其他硬盘。)

Write to USB stick 写到 u 盘

一旦你确信这是正确的设备文件地址,通过以下方式将 ISO 映像复制到 u 盘上:

  1. sudo dd if="$IMAGE" bs=1M of=/dev/sdh ; sync

Eventually restore backup 最终恢复备份

以后要恢复 u 盘的原始内容,同样要注意真正使用正确的地址,然后:

  1. dd if="$HOME"/red_usb_stick.gz | sudo gunzip >/dev/sdh

Of course, the Ubuntu ISO image will be overwritten by this restore run.

当然,Ubuntu ISO 镜像会被这次恢复运行覆盖。

Testing测试

你现在可以从 CD 或 u 盘上启动了。 选择您创建的新菜单项。 如果您使用预置停止 CD 询问问题,那么安装可能是完全自动的。

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注