AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1119075
Accepted
motorbass
motorbass
Asked: 2022-12-30 08:04:56 +0800 CST2022-12-30 08:04:56 +0800 CST 2022-12-30 08:04:56 +0800 CST

关于 Debian 11 自动化安装的建议

  • 772

我目前正在尝试通过 Packer for Nutanix 环境自动创建 Debian 11 模板,并且需要一些关于预置/自动安装 Debian 的建议。

首先,在阅读了这本圣经https://www.debian.org/releases/stable/amd64/apbs02.fr.html之后,我开始使用 preseed.cfg 文件。我从 Debian 提供的 preseed.cfg 文件开始,然后调整一些内容以满足我的需要。最后,我使用命令 => 验证语法debconf-set-selections -c preseed.cfg一切正常。

现在,我看到有 3 种不同的方法来使用 preseed.cfg :

  • 通过 initrd :对我来说似乎很难并且没有找到简单的教程/文档
  • 通过网络:由于某些防火墙限制,目前不是一个选项
  • 通过文件:目前似乎是最简单和最好的选择

当 Packer 开始创建 VM 时,它会将 debian ISO 作为 CD-ROM 加载到第一个位置,并在第二个位置加载一个空虚拟磁盘。我告诉打包程序将我的 preseed.cfg 脚本加载为 cd-rom,因此从管理程序的角度来看,第二个 cd-rom 驱动器安装在第三个位置。

但是,在这种情况下,VM 在 ISO(cd-rom 第一位置)上启动,它不会挂载具有 preseed.cfg 文件的第二个 cd-rom 驱动器,除非我转到 debian 控制台,否则我无法访问它然后安装第二个驱动器。

我看到一个关于将 preseed.cfg 上传到我原来的 debian.iso 文件夹并像这样修改 /isolinux/txt.cfg 文件的论坛(然后用 OSCDIMG 重新创建 iso):

label install
    menu label ^Install
    kernel /install.amd/vmlinuz
    append vga=788 initrd=/install.amd/initrd.gz preseed/file=/cdrom/preseed/preseed.cfg --- quiet

我的问题是:这样做公平吗?有什么我错过的或更容易让它工作的东西吗?

编辑:我尝试了 initrd 方法,唯一剩下的就是我必须手动选择自动安装。如何摆脱这个动作?

编辑 2:02-01-2023

  • 我尝试了 2 个不同的东西,第一个是在 isolinux/txt.cfg 中有这一行 append auto=true priority=critical vga=788 initrd=/install.amd/initrd.gz preseed/file=/cdrom/preseed.cfg --- quiet=> NOK,它仍然在启动菜单上启动(但是如果我手动选择自动安装就可以了,所以这意味着 preseed.cfg 工作得很好)
  • 第二,prompt 1 timeout 1在 isolinux.cfg 中进行测试 => 直接手动选择语言...

EDIT3: 03-01-2023 这是我使用的 preseed.cfg:

# SETUP AUTO MODE
d-i auto-install/enable boolean true
d-i debconf/priority select critical
# LANGUAGE & KEYMAP
d-i debian-installer/locale string fr_FR
d-i keyboard-configuration/xkb-keymap select fr(latin9)
# NETWORK
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string template-debian-11-x64
d-i netcfg/get_domain string my_domain.net
d-i netcfg/hostname string template-debian-11-x64
# MIRRORS
d-i mirror/http/hostname string  http://deb.debian.org/debian/ 
d-i mirror/http/hostname string http://security.debian.org/debian-security 
# ACCOUNTS
d-i passwd/root-password password mypassword!
d-i passwd/root-password-again password mypassword!
d-i passwd/user-fullname string user
d-i passwd/username string user
d-i passwd/user-password password mypassword!
d-i passwd/user-password-again password mypassword!
d-i passwd/user-uid string 1010
d-i passwd/user-default-groups string si audio cdrom video
# LVM PART
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string lvm
d-i partman-auto-lvm/guided_size string 95%
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto/choose_recipe select multi
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
#APT
d-i apt-setup/cdrom/set-first boolean false
tasksel tasksel/first multiselect standard, ssh-server
# GRUB
d-i grub-installer/bootdev string /dev/sda
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
#FINAL
d-i finish-install/reboot_in_progress note

非常感谢

盖尔语

debian
  • 2 2 个回答
  • 112 Views

2 个回答

  • Voted
  1. Nikita Kipriyanov
    2022-12-31T10:17:04+08:002022-12-31T10:17:04+08:00

    在 Packer 中使用 a boot_command,它将向 VM 发送按键,基本上,将内容输入其中。它会“输入”什么取决于你。这转到加壳文件(我命名它base.pkr.hcl):

    ...
    variable "preseed_file" {
      type    = string
      default = "base.preseed"
    }
    ...
    source "qemu" "qemu" {
      ...
      boot_command = [
        "<wait><wait><wait><esc><wait><wait><wait>",
        "/install.amd/vmlinuz ",
        "initrd=/install.amd/initrd.gz ",
        "auto=true ",
        "debian-installer/locale=ru_RU.UTF-8 ",
        "keyboard-configuration/xkb-keymap=ru ",
        "keyboard-configuration/optionscode=grp:caps_toggle,lv3:ralt_switch,compose:rctrl,grp_led:scroll ",
        "url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
        "hostname=${var.vm_name} ",
        "domain=${var.domain} ",
        "interface=auto ",
        "vga=788 noprompt quiet --<enter>"
      ]
      http_content         = { "/preseed.cfg" = templatefile(var.preseed_file, { var = var }) }
      ...
    }
    ...
    

    这样,加壳程序将通过 HTTP 将预置文件提供给虚拟机,并有效地使用您在加壳程序文件中提供的启动选项覆盖 ISO 中内置的启动选项。无需对 ISO 进行任何更改。


    我正在使用 Qemu;这是我半年前做那件事时最终得到的副本。看起来 Nutanix builder 没有这个 boot_command;但是,您可以尝试使用 Qemu 或 Virtualbox 等构建系统,然后将其与 Nutanix 一起使用。我只是不知道。

    • 1
  2. Best Answer
    Georgee
    2022-12-31T12:55:53+08:002022-12-31T12:55:53+08:00

    关于您的第一个问题,我认为没有任何更简单的方法可以debian installer通过将预置文件传递给它来启用自动安装。安装第二个图像可能是满足您特定需求的好主意,但 AFAIKdebian installer不尊重第二个媒体的预置,并且我知道没有解决方法(仅供参考,ubuntu 的subiquity安装程序确实支持此类输入)。

    为了实现“无人”安装,我将解释两件应该注意的事情。

    Debian 安装程序配置(预置)

    为了让debian installergo 完全自动化,你需要在你的 preseed 文件中添加:

    d-i debconf/priority select critical
    

    这只会告诉debian installer不要问它可以找到答案的问题。除此之外,您需要使用 启用自动模式d-i auto-install/enable boolean true,但暂时忽略它(我将在下一部分讨论自动模式)。来自auto mode文档:

    auto内核参数是auto-install/enable的别名,将其设置为true会延迟区域设置和键盘问题,直到有机会预置它们,而priority是debconf/priority的别名,并将其设置为关键停止任何优先级较低的问题都不会被问到。

    PS您可以将一些问题/答案作为具有key=value格式的内核参数传递,其中key是别名。这需要更改引导参数。查看完整列表:aliases useful with preseeding

    引导程序配置

    除了安装程序配置外,我们还需要对引导加载程序进行一些更改。为了使isolinux引导加载程序在无人值守的安装场景中工作,我对其 iso 中的配置文件进行了以下 2 处更改:

    1. 通过内核参数设置自动模式。
    2. 告诉isolinux自动选择菜单中的默认条目。

    第一个更改是通过添加auto=true到append默认菜单条目的行来完成的。对于 debian 11,我发现“图形安装”是默认条目。由于此条目的配置是从中读取的isolinux/gtk.cfg,因此应在该文件中应用此更改。例如,您可以将示例引导加载程序配置附加行更改为"append auto=true vga=...".

    第二个目标是通过更改timeout 0为timeout 1in来实现的isolinux/isolinux.cfg(参见this)。

    注1: kernelauto=true参数是d-i auto-install/enable boolean truepreseed config的别名。原来是因为某些原因应该由内核参数启用。将其等价物放入预置文件中仍然会出现语言选择提示,等待用户输入(也许在读取预置文件debian installer时启用自动模式为时已晚?)。

    注意 2:您不需要prompt 1在 isolinux 配置中。它可能会做与您想要的相反的事情,这会阻止自动选择默认条目(请参阅本节的最后一行)。

    注 3:更改引导加载程序配置需要修改 iso 内容(因此需要重新构建 iso)。

    注 4:引导isolinux加载程序通常用于 BIOS(传统)系统。在 UEFI 系统中,您需要改为配置 GRUB。

    • 1

相关问题

  • 关闭 FTP

  • 如何在同一台电脑上从 putty 连接 debian vmware

  • debian- 文件到包的映射

  • Debian Ubuntu 网络管理器错误 [关闭]

  • 为本地网络中的名称解析添加自定义 dns 条目

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve