完全无人值守预置 debian 11(排除问题)

pro*_*d43 7 debian automated-install preseed pxe-boot

我正在尝试完全自动化地预置 debian 11 netinstall。\n我在这里阅读了许多文档:

\n

这是我的引导行(来自 grub.cfg)

\n
set default="autoinstall"\nset timeout=3\n\nmenuentry "Debian 11 Fully Automated UEFI LVM LUKS BTRFS Remote Decrypt DEBUG TTY4" --id autoinstall {\n        set background_color=black\n        linux    /debian-installer/amd64/linux auto=true url=tftp://192.168.1.100/preseed/debseed11_crypt.cfg net.ifnames=0 biosdevname=0 ipv6.disable=1 language=en locale=en_US.UTF-8 keymap=fr vga=788 noprompt DEBCONF_DEBUG=5 --- quiet\n        initrd   /debian-installer/amd64/initrd.gz\n}\n
Run Code Online (Sandbox Code Playgroud)\n

这是我的预置文件:

\n
#### Preseed preconfiguration file (for Debian buster)\n### Partman early command\n### Kernal parameter\n#d-i debian-installer/add-kernel-opts string net.ifnames=0 biosdevname=0 hostname=unassigned-hostname domain=unassigned-domain\n#d-i debconf/priority critical\n\n#d-i debian-installer/add-kernel-opts string net.ifnames=0 biosdevname=0 console=ttyS0,19200n8\n### Localization\nd-i debian-installer/locale string en_US\nd-i debian-installer/language string en\nd-i debian-installer/country string US\n#d-i debian-installer/locale string en_US.UTF-8 fr_FR.UTF-8\nd-i localechooser/supported-locales multiselect en_US.UTF-8, fr_FR.UTF-8\n\n### Keyboard selection\nd-i keyboard-configuration/xkb-keymap select fr\n\n###  Network configuration\n\n# Netcfg choisira une interface connect\xc3\xa9e si possible. Cela emp\xc3\xaachera\n# # d'afficher une liste s'il y a plusieurs interfaces.\nd-i netcfg/choose_interface select auto\n\n#d-i netcfg/choose_interface select eth0\nd-i netcfg/use_dhcp string true\nd-i netcfg/link_wait_timeout string 10\nd-i netcfg/dhcp_timeout string 60\n\n#d-i netcfg/disable_autoconfig boolean true\n\nd-i netcfg/dhcp_failed note\n#d-i netcfg/dhcp_options select auto\n\n#Configure network manually\n# IPv4 Static network configuration\n#d-i netcfg/get_ipaddress string 192.168.1.120\n#d-i netcfg/get_netmask string 255.255.255.0\n#d-i netcfg/get_gateway string 192.168.1.1\n#d-i netcfg/get_nameservers string 192.168.1.1\n#d-i netcfg/confirm_static boolean true\n\n# Set a hostname\n#d-i netcfg/get_hostname string zhurong\n#d-i netcfg/get_domain string planet.mars\n# Force a hostname\n#d-i netcfg/hostname string zhurong.planet.mars\n# Disable that annoying WEP key dialog\nd-i netcfg/wireless_wep string\n\n\nd-i netcfg/get_hostname unassigned-hostname \nd-i netcfg/get_domain unassigned-domain\nd-i netcfg/get_hostname seen true\nd-i netcfg/get_domain seen true\n\n### Mirror settings\nd-i mirror/country string manual\nd-i mirror/http/hostname string httpredir.debian.org\nd-i mirror/http/directory string /debian\nd-i mirror/http/proxy string\n\n### Account setup\n# Skip creation of a normal user account\nd-i passwd/make-user boolean false\n# Set root password\n# or encrypted using a crypt(3)  hash.\nd-i passwd/root-password-crypted password $6$47Cx5oMpkh66eYNI$LV76xupgkvZ3rHJCq1NgXKzp3bBDv6g0FmMiSvmUp1jqaIkTEz5F6eA.SRhBzyPReVQEnzZWwFWSdKGBBn.tE1\n\n### Clock and time zone setup\n# Set hardware clock to UTC\nd-i clock-setup/utc boolean true\n# Set timezone\nd-i time/zone string Europe/Paris\n# Use NTP clock during installation\nd-i clock-setup/ntp boolean true\n\n### Partitioning\n# LVM LUKS method\n\n# Inhibit partman to fill the disk with random data \nd-i partman-auto-crypto/erase_disks boolean false\n\n#d-i partman/early_command \\\n#       string dd if=/dev/zero of=/dev/sda bs=512 count=1\nd-i partman-auto/method string crypto\nd-i partman-lvm/device_remove_lvm boolean true\nd-i partman-md/device_remove_md boolean true\nd-i partman-lvm/confirm boolean true\nd-i partman-auto-lvm/guided_size string max\nd-i partman-auto-lvm/new_vg_name string debian\nd-i partman-auto/disk string /dev/vda\nd-i partman-auto/choose_recipe select boot-crypto\nd-i partman-crypto/passphrase       password  aaabbbccc\nd-i partman-crypto/passphrase-again password  aaabbbccc\nd-i partman-auto/expert_recipe string \\\nboot-crypto :: \\\n  1024 1024 1024 ext4 \\\n          $primary{ } $bootable{ } \\\n          method{ format } format{ } \\\n          use_filesystem{ } filesystem{ ext4 } \\\n          mountpoint{ /boot } \\\n  . \\\n  8192 8192 8192 linux-swap \\\n          $lvmok{ } lv_name{ swap } \\\n          in_vg { debian } \\\n          method{ swap } format{ } \\\n  . \\\n  80896 80896 1000000 btrfs \\\n          $lvmok{ } lv_name{ root } \\\n          in_vg { debian } \\\n          method{ format } format{ } \\\n          use_filesystem{ } filesystem{ btrfs } \\\n          mountpoint{ / } \\\n   . \\\n\n#d-i partman-basicfilesystems/no_mount_point boolean false\nd-i partman-partitioning/confirm_write_new_label boolean true\nd-i partman/choose_partition select finish\nd-i partman/confirm boolean true\nd-i partman/confirm_nooverwrite boolean true\n\nd-i partman-md/confirm boolean true\nd-i partman-partitioning/confirm_write_new_label boolean true\nd-i partman/choose_partition select finish\nd-i partman/confirm boolean true\nd-i partman/confirm_nooverwrite boolean true\n\n### Apt setup\nd-i apt-setup/cdrom/set-first boolean false\nd-i apt-setup/cdrom/set-next boolean false\nd-i apt-setup/cdrom/set-failed boolean false\nd-i apt-setup/services-select multiselect security, updates\nd-i apt-setup/security_host string security.debian.org\n### Package selection\ntasksel tasksel/first multiselect standard\n# Individual additional packages to install\nd-i pkgsel/include string openssh-server vim tmux tcpdump dropbear-initramfs cryptsetup-initramfs python3.9\nd-i pkgsel/upgrade select full-upgrade\nd-i pkgsel/update-policy select none\nd-i pkgsel/updatedb boolean true\npopularity-contest popularity-contest/participate boolean false\n\n\n### GRUB STUFF\nd-i grub-installer/only_debian boolean true\nd-i grub-installer/bootdev  string default\n\n# Note: options passed to the installer will be added automatically. \n#d-i debian-installer/add-kernel-opts string nousb\n\n# Optional password for grub, either in clear text\n# #d-i grub-installer/password password r00tme\n# #d-i grub-installer/password-again password r00tme\n# # or encrypted using an MD5 hash, see grub-md5-crypt(8).\n# #d-i grub-installer/password-crypted password [MD5 hash]\n#\n# # Use the following option to add additional boot parameters for the\n# # installed system (if supported by the bootloader installer).\n# # Note: options passed to the installer will be added automatically.\n# #d-i debian-installer/add-kernel-opts string nousb\n#\n# ### Finishing up the installation\n# # Avoid that last message about the install being complete.\nd-i finish-install/reboot_in_progress note\n\n\nd-i preseed/late_command string \\\n  mkdir -p -m 700 /target/root/.ssh; \\\n  echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJEe3gF//znGIzq30frI6O9qDn5eM6uqEZZlx7mR5SiS" > /target/root/.ssh/authorized_keys; \\\n  in-target chown --recursive root:root /root/.ssh; \\\n  in-target chmod 0644 /root/.ssh/authorized_keys; \\\n  in-target update-alternatives --set editor /usr/bin/vim.basic; \\\n  in-target passwd --expire root; \\\n  in-target echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJEe3gF//znGIzq30frI6O9qDn5eM6uqEZZlx7mR5SiS' > /etc/dropbear-initramfs/authorized_keys; \\\n  in-target sed -i '/*PasswordAuthentication*/c\\PasswordAuthentication no' /etc/ssh/sshd_config; \\\n  in-target sed -i '/*PasswordAuthentication*/c\\PasswordAuthentication no' /etc/ssh/sshd_config; \\\n  in-target systemctl enable --now sshd; \\\n  in-target sed -i '/*DROPBEAR_OPTIONS=*/c\\DROPBEAR_OPTIONS="-I 300 -j -k -p 22 -s -c /bin/cryptroot-unlock "' /etc/dropbear-initramfs/config; \\\n  in-target sed -i '/*IP=*/c\\IP="dhcp"' /etc/initramfs-tools/initramfs.conf; \\\n  in-target update-initramfs -u;\n#\n
Run Code Online (Sandbox Code Playgroud)\n

目前,我收到 debien 安装程序的询问:

\n
    \n
  • 主机名
  • \n
  • 域名
  • \n
\n

我只是想摆脱这些问题。这是我尝试过的:

\n
    \n
  • 我尝试在 pxe 服务器上的命令行内核选项中使用优先级=关键。
  • \n
  • 我配置了 dhcpd 服务器来管理该特定主机的主机名域名。
  • \n
\n
host curiosity {\nhardware ethernet 12:34:45:12:34:56;\nfixed-address 192.168.1.90;\noption host-name "curiosity";\noption domain-name "planet.mars";\n}\n
Run Code Online (Sandbox Code Playgroud)\n

我知道我可以设置主机名/域变量,一切都会好的,但我想制作一个非常通用的预置来部署在多个服务器上。

\n

一些帮助或线索将非常感激。

\n

提前谢谢您。

\n

编辑:已解决:

\n

顺便说一句,第一个预选并不完美。如果有人对这里感兴趣那就更好了。

\n

它通过 ssh DEBUG TTY4 进行全自动 Debian 11 UEFI LUKS BTRFS 远程解密

\n
#### Preseed preconfiguration file (for Debian bullseye)\n\n# Debian 11 Fully Automated UEFI LVM LUKS BTRFS Remote Decrypt via ssh DEBUG # TTY4\n\n\n### Partman early command\n### Kernel parameter\n#d-i debian-installer/add-kernel-opts string net.ifnames=0 biosdevname=0 hostname=unassigned-hostname domain=unassigned-domain\n#d-i debconf/priority critical\n\n#d-i debian-installer/add-kernel-opts string net.ifnames=0 biosdevname=0 console=ttyS0,19200n8\n### Localization\nd-i debian-installer/locale string en_US\nd-i debian-installer/language string en\nd-i debian-installer/country string US\n#d-i debian-installer/locale string en_US.UTF-8 fr_FR.UTF-8\nd-i localechooser/supported-locales multiselect en_US.UTF-8, fr_FR.UTF-8\n\n### Keyboard selection\nd-i keyboard-configuration/xkb-keymap select fr\n\n###  Network configuration\n\n# Netcfg choisira une interface connect\xc3\xa9e si possible. Cela emp\xc3\xaachera\n# # d'afficher une liste s'il y a plusieurs interfaces.\nd-i netcfg/choose_interface select auto\n\n#d-i netcfg/choose_interface select eth0\nd-i netcfg/use_dhcp string true\nd-i netcfg/link_wait_timeout string 10\nd-i netcfg/dhcp_timeout string 60\n\n#d-i netcfg/disable_autoconfig boolean true\n\nd-i netcfg/dhcp_failed note\n#d-i netcfg/dhcp_options select auto\n\n#Configure network manually\n# IPv4 Static network configuration\n#d-i netcfg/get_ipaddress string 192.168.1.120\n#d-i netcfg/get_netmask string 255.255.255.0\n#d-i netcfg/get_gateway string 192.168.1.1\n#d-i netcfg/get_nameservers string 192.168.1.1\n#d-i netcfg/confirm_static boolean true\n\n# Set a hostname\n#d-i netcfg/get_hostname string zhurong\n#d-i netcfg/get_domain string planet.mars\n# Force a hostname\n#d-i netcfg/hostname string zhurong.planet.mars\n# Disable that annoying WEP key dialog\nd-i netcfg/wireless_wep string\n\n#d-i netcfg/get_hostname=install\nd-i netcfg/get_hostname unassigned-hostname \nd-i netcfg/get_domain unassigned-domain\nd-i netcfg/get_hostname seen true\nd-i netcfg/get_domain seen true\n\n### Mirror settings\nd-i mirror/country string manual\nd-i mirror/http/hostname string httpredir.debian.org\nd-i mirror/http/directory string /debian\nd-i mirror/http/proxy string\n\n### Account setup\n# Skip creation of a normal user account\nd-i passwd/make-user boolean false\n# Set root password\n# or encrypted using a crypt(3)  hash.\nd-i passwd/root-password-crypted password $6$47Cx5oMpkh999YNI$XG76xupgkvZ3rHJCq1NgXKzp3bBfIuj0FmMiSvmUp1jqaIkTEz5F6eA.SRhBzyPReVQEnzZWwFWSdYGCBn.tE1\n\n### Clock and time zone setup\n# Set hardware clock to UTC\nd-i clock-setup/utc boolean true\n# Set timezone\nd-i time/zone string Europe/Paris\n# Use NTP clock during installation\nd-i clock-setup/ntp boolean true\n\n### Partitioning\n# LVM LUKS method\n\n# Inhibit partman to fill the disk with random data \nd-i partman-auto-crypto/erase_disks boolean false\n\n#d-i partman/early_command \\\n#       string dd if=/dev/zero of=/dev/sda bs=512 count=1\n\n# Force UEFI booting ('BIOS compatibility' will be lost). Default: false.\nd-i partman-efi/non_efi_system boolean false\n# Ensure the partition table is GPT - this is required for EFI\nd-i partman-partitioning/choose_label string gpt\nd-i partman-partitioning/default_label string gpt\n\nd-i partman-auto/method string crypto\nd-i partman-lvm/device_remove_lvm boolean true\nd-i partman-md/device_remove_md boolean true\nd-i partman-lvm/confirm boolean true\nd-i partman-auto-lvm/guided_size string max\nd-i partman-auto-lvm/new_vg_name string debian\nd-i partman-auto/disk string /dev/sda\nd-i partman-auto/choose_recipe select boot-crypto\nd-i partman-crypto/passphrase       password  aabbcc\nd-i partman-crypto/passphrase-again password  aabbcc\nd-i partman-auto/expert_recipe string \\\nboot-crypto :: \\\n  512 50 512 fat32 \\\n          $primary{ } $bootable{ } \\\n          method{ efi } format{ } \\\n          mountpoint{ /boot/efi } \\\n  . \\\n  1024 1024 1024 ext4 \\\n          $primary{ } $bootable{ } \\\n          method{ format } format{ } \\\n          use_filesystem{ } filesystem{ ext4 } \\\n          mountpoint{ /boot } \\\n  . \\\n  8192 8192 8192 linux-swap \\\n          $lvmok{ } lv_name{ swap } \\\n          in_vg { debian } \\\n          method{ swap } format{ } \\\n  . \\\n  80896 80896 1000000 btrfs \\\n          $lvmok{ } lv_name{ root } \\\n          in_vg { debian } \\\n          method{ format } format{ } \\\n          use_filesystem{ } filesystem{ btrfs } \\\n          mountpoint{ / } \\\n  . \\\n\n#d-i partman-basicfilesystems/no_mount_point boolean false\nd-i partman-partitioning/confirm_write_new_label boolean true\nd-i partman/choose_partition select finish\nd-i partman/confirm boolean true\nd-i partman/confirm_nooverwrite boolean true\n\nd-i partman-md/confirm boolean true\nd-i partman-partitioning/confirm_write_new_label boolean true\nd-i partman/choose_partition select finish\nd-i partman/confirm boolean true\nd-i partman/confirm_nooverwrite boolean true\n\n### Apt setup\nd-i apt-setup/cdrom/set-first boolean false\nd-i apt-setup/cdrom/set-next boolean false\nd-i apt-setup/cdrom/set-failed boolean false\nd-i apt-setup/services-select multiselect security, updates\nd-i apt-setup/security_host string security.debian.org\n### Package selection\ntasksel tasksel/first multiselect standard\n# Individual additional packages to install\nd-i pkgsel/include string openssh-server vim tmux tcpdump dropbear-initramfs cryptsetup-initramfs python3.9\nd-i pkgsel/upgrade select full-upgrade\nd-i pkgsel/update-policy select none\nd-i pkgsel/updatedb boolean true\npopularity-contest popularity-contest/participate boolean false\n\n\n### GRUB STUFF\nd-i grub-installer/only_debian boolean true\nd-i grub-installer/bootdev  string default\n\n# Note: options passed to the installer will be added automatically. \n#d-i debian-installer/add-kernel-opts string nousb\n\n# Optional password for grub, either in clear text\n# #d-i grub-installer/password password r00tme\n# #d-i grub-installer/password-again password r00tme\n# # or encrypted using an MD5 hash, see grub-md5-crypt(8).\n# #d-i grub-installer/password-crypted password [MD5 hash]\n#\n# # Use the following option to add additional boot parameters for the\n# # installed system (if supported by the bootloader installer).\n# # Note: options passed to the installer will be added automatically.\n# #d-i debian-installer/add-kernel-opts string nousb\n#\n# ### Finishing up the installation\n# # Avoid that last message about the install being complete.\nd-i finish-install/reboot_in_progress note\n\n\nd-i preseed/late_command string \\\n  mkdir -p -m 700 /target/root/.ssh; \\\n  echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJEe3gF//znGIzq30frI6O9qDn5eM6uqEZZlx7mR5SiS" > /target/root/.ssh/authorized_keys; \\\n  in-target chown --recursive root:root /root/.ssh; \\\n  in-target chmod 0644 /root/.ssh/authorized_keys; \\\n  in-target update-alternatives --set editor /usr/bin/vim.basic; \\\n  \n\nd-i preseed/late_command string \\\n  mkdir -p -m 700 /target/root/.ssh; \\\n  echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJEe3gF//znGIzq30frI6O9qDn5eM6uqEZZlx7mR5SiS" > /target/root/.ssh/authorized_keys; \\\n  in-target chown --recursive root:root /root/.ssh; \\\n  in-target chmod 0644 /root/.ssh/authorized_keys; \\\n  in-target update-alternatives --set editor /usr/bin/vim.basic; \\\n  echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJEe3gF//znGIzq30frI6O9qDn5eM6uqEZZlx7mR5SiS' > /target/etc/dropbear-initramfs/authorized_keys; \\\n  echo 'PasswordAuthentication no' >> /target/etc/ssh/sshd_config.d/setup; \\\n  echo 'PermitRootLogin prohibit-password' >> /etc/ssh/sshd_config.d/setup; \\\n  echo 'auto eno1' >> /target/etc/network/interfaces; \\\n  sed -i 's/eth0/eno1/g' /target/etc/network/interfaces; \\\n  in-target systemctl enable --now sshd; \\\n  echo 'DROPBEAR_OPTIONS="-I 300 -j -k -p 22 -s -c /bin/cryptroot-unlock"' >> /target/etc/dropbear-initramfs/config; \\\n  echo 'IP="dhcp"' >> /target/etc/initramfs-tools/initramfs.conf; \\\n  in-target update-initramfs -u;\n\n#  in-target passwd --expire root; \\\n\n
Run Code Online (Sandbox Code Playgroud)\n

解决 !

\n

pro*_*d43 5

我找到了办法!感谢这篇关于相反问题的文章

我刚刚在 grub.cfg 中的引导行中添加了两个参数

netcfg/get_hostname=install netcfg/get_domain=install

现在它是完全自动化的,不会询问任何问题。