【Debian GNU/Linux 安装手册】B.5. 高级选项

B.5. 高级选项

B.5.1. 安装过程中运行用户命令

预置工具提供了一个非常强大和灵活的选项,可以在安装过程的一些环节运行命令或脚本。

当目标系统的文件系统挂载后,它可以在 /target 中使用。如果使用安装 CD,则挂载后可以在 /cdrom 中使用。

# d-i preseeding is inherently not secure. Nothing in the installer checks
# for attempts at buffer overflows or other exploits of the values of a
# preconfiguration file like this one. Only use preconfiguration files from
# trusted locations! To drive that home, and because it's generally useful,
# here's a way to run any shell command you'd like inside the installer,
# automatically.

# This first command is run as early as possible, just after
# preseeding is read.
#d-i preseed/early_command string anna-install some-udeb
# This command is run immediately before the partitioner starts. It may be
# useful to apply dynamic partitioner preseeding that depends on the state
# of the disks (which may not be visible when preseed/early_command runs).
#d-i partman/early_command \
#       string debconf-set partman-auto/disk "$(list-devices disk | head -n1)"
# This command is run just before the install finishes, but when there is
# still a usable /target directory. You can chroot to /target and use it
# directly, or use the apt-install and in-target commands to easily install
# packages and run commands in the target system.
#d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh

B.5.2. 使用预置修改默认值

也可以使用预置修改问题的默认答案,但同时显示问题。这需要在问题设定值之后,必须将 seen 旗标重置为 false

d-i foo/bar string value
d-i foo/bar seen false

要对所有问题达到同样效果,可以通过在启动引导符后面设置 preseed/interactive=true。这对于测试和调试您的预置文件很有帮助。

注意,d-i owner 只应该用于安装程序里面的变量。对于那些属于目标系统软件包的变量,您应该使用软件包的名字替代。请参考 第 B.2.2 节 “使用引导参数预置问题的答案” 的脚注。

如果使用引导参数预置,您可以通过 ?= 操作符让安装程序询问相关的问题,例如,foo/bar?=value (或者 owner:foo/bar?=value)。当然,这只会影响在安装时显示出来的问题对应的参数,而不是内部的参数。

获得更多的调试信息,需使用引导参数 DEBCONF_DEBUG=5。这将让 debconf 打印更多的细节,包括当前变量设置和每个软件包安装脚本的进度。

B.5.3. 预置文件链

可以在一个预置文件里面包含另外的预置文件。这些文件里面的任何设置将覆盖前面加载的设置。有一种用法,例如,通用的网络设置放在一个文件,其他规格的设置放在另外的文件里面。

# More than one file can be listed, separated by spaces; all will be
# loaded. The included files can have preseed/include directives of their
# own as well. Note that if the filenames are relative, they are taken from
# the same directory as the preconfiguration file that includes them.
#d-i preseed/include string x.cfg

# The installer can optionally verify checksums of preconfiguration files
# before using them. Currently only md5sums are supported, list the md5sums
# in the same order as the list of files to include.
#d-i preseed/include/checksum string 5da499872becccfeda2c4872f9171c3d

# More flexibly, this runs a shell command and if it outputs the names of
# preconfiguration files, includes those files. 
#d-i preseed/include_command \
#      string if [ "`hostname`" = bob ]; then echo bob.cfg; fi

# Most flexibly of all, this downloads a program and runs it. The program
# can use commands such as debconf-set to manipulate the debconf database.
# More than one script can be listed, separated by spaces.
# Note that if the filenames are relative, they are taken from the same
# directory as the preconfiguration file that runs them.
#d-i preseed/run string foo.sh

也可以通过在前面设置 preseed/url 从 initrd 或者文件预置链载进入网络预置。这将使网络预置在网络连通时执行。您应该小心使用,因为这是两种预置,意味着您有机会执行 preseed/early 命令,第二个可以在网络连通后使用。

原创文章,作者:晴川运维,如若转载,请注明出处:https://baike.qcidc.com/6199.html

(0)
晴川运维晴川运维
上一篇 2025年6月8日
下一篇 2025年6月8日

相关推荐

  • Debian系统如何查看端口开放状态

    Debian系统如何查看端口开放状态   查看系统端口状态 要查看 Debian 系统上端口的开放状态,可以使用以下命令: 使用 netstat 命令: sudo net…

    Debian 2天前
  • Linux终端查看图片具体方法

    Linux终端如何查看图像?本篇文章将使用ImageMagick和fim 命令为大家演示一下Linux终端查看图片具体方法。 如何使用 display 命令从终端查看图像 Imag…

    Debian 3天前
  • 【Debian GNU/Linux 安装手册】C.2. 目录树

    C.2. 目录树 Debian GNU/linux 依照 文件系统层次标准 (Filesystem Hierarchy Standard) 安排文件以及文件命名。该标准让…

    Debian 2025年6月11日
  • Linux 的vi和vim 有什么不同?

    Linux 的vi和vim 有什么不同? Vi 和 Vim 都是 Linux 中常用的文本编辑器,它们的主要区别在于以下几点: 1. 命令模式的默认设置不同:Vi 在启动时默认进入…

    Debian 1天前
  • 如何在 Debian Linux 上设置和配置网桥

    Q:我是一个新 Debian linux 用户,我想为 Debian Linux 上运行的虚拟化环境(KVM)设置网桥。那么我该如何在 Debian Linux 9.x 服务器上的…

    Debian 2025年6月8日
  • Linux wget命令使用实例

    Linux系统中的wget是一个下载文件的工具,它用在命令行下。对于Linux用户是必不可少的工具,我们经常要下载一些软件或从远程服务器恢复备份到本地服务器。 安装wget命令 首…

    Debian 2025年6月12日
  • 强化Linux服务器的几个建议

    Linux服务器安全对于保护用户数据、知识产权非常重要,同时还能减少你面对黑客的时间。在工作中,通常由系统管理员对Linux的安全负责,下面为大家详细讲解强化Linux服务器具体方…

    Debian 2025年6月14日
  • 【Debian GNU/Linux 安装手册】1.6. 获得本文档最新版本

    1.6. 获得本文档最新版本 本文档会不断地修订。请查阅 Debian 11 页面 以了解最近的关于 11 版 Debian GNU/linux 系统的的信息。更新的安装…

    Debian 2025年6月8日
  • Linux使用vlock锁定终端

    Linux vlock命令用于锁住虚拟终端。执行vlock(virtual console lock)指令可锁住虚拟终端,避免他人使用,下面为大家详细讲解一下Linux使用vloc…

    Debian 2025年6月8日
  • Linux下安装并使用netstat命令

    Netstat命令用于显示协议统计数据和当前TCP/IP网络的连接相关信息。很多时候我们需要查看自己的电脑某些网络端口是否被正常打开或者是否已经成功与别的机器建立连接,或者想看一些…

    Debian 2025年6月8日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注