如何创建完全无人值守的Ubuntu Desktop 16.04.1 LTS安装?


43

目的

我想完全无人值守安装Ubuntu Desktop 16.04.1 LTS。放入ISO CD,然后走开。

问题

  • 引导参数不正确
  • 问题仍在询问中,需要单击鼠标
  • 使用kickstart / preseed进行复杂的答案
  • 文档示例无规定,特别是partman和ubunutu的作品

我在这里看到了这篇文章,它接近我需要的内容,但是由于它是针对Ubuntu Server的,所以并没有完全满足我的需要。该帖子建议使用“非图形” Ubuntu安装,但我找不到适用于Ubuntu Desktop的非图形安装,这很有意义。我试图调整这些步骤,并使它适用于Ubuntu Desktop 16.04.1 LTS。

使用的文件

我已使用以下所有资源...

显然,我无法包括所有资源,因为askubuntu不允许链接超过2个。嗯,这不是很有帮助-所以这里只是一个列表:

  • AskUbuntu
  • Ubuntu install.en.pdf
  • 前置示例
  • 无处不在的安装程序文档
  • Partman文档和示例
  • 3个数字的分区食谱说明及其权重
  • 一个更复杂的示例

当前解决方案

我当前创建了无人参与的安装,但是不确定是否正确-这意味着我应该已经编辑过isolinux / isolinux.cfg

我链接的帖子和Ubuntu桌面映像之间有很多区别。这是我的解决方案:

第1步

安装了Ubuntu ISO,以便我可以将内容复制到另一个目录,然后编辑相关文件。

mkdir -p /mnt/iso
mount -o loop ubuntu.iso /mnt/iso

第2步

然后,我将ISO文件复制到另一个目录进行编辑。

mkdir -p /opt/ubuntuiso
cp -rT /mnt/iso /opt/ubuntuiso

第三步

我编辑了isolinux/isolinux.cfg文件,并用以下内容替换了其中的所有内容:

default live-install
label live-install
  menu label ^Install Ubuntu
  kernel /casper/vmlinuz.efi
  append  file=/cdrom/ks.preseed auto=true priority=critical debian-installer/locale=en_US keyboard-configuration/layoutcode=us ubiquity/reboot=true languagechooser/language-name=English countrychooser/shortlist=US localechooser/supported-locales=en_US.UTF-8 boot=casper automatic-ubiquity initrd=/casper/initrd.lz quiet splash noprompt noshell ---

附加行很长,为便于阅读,以下是我使用的所有选项:

file=/cdrom/ks.preseed 
auto=true 
priority=critical 
debian-installer/locale=en_US 
keyboard-configuration/layoutcode=us 
ubiquity/reboot=true 
languagechooser/language-name=English 
countrychooser/shortlist=US 
localechooser/supported-locales=en_US.UTF-8 
boot=casper 
automatic-ubiquity 
initrd=/casper/initrd.lz 
quiet 
splash 
noprompt 
noshell

我发现所有这些引导参数都是获得完全无人值守安装所必需的。对于Ubuntu Server,可能有所不同。

第四步

我尝试使用和创建许多预置文件,但发现越复杂,出错的机会就越大。目前,这是我与上述isolinux.cfg文件一起使用的简单预置文件。

### Partitioning
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-auto/choose_recipe select atomic

# This makes partman automatically partition without confirmation
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

# Locale
d-i debian-installer/locale string en_US
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string us

# Network
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/choose_interface select auto

# Clock
d-i clock-setup/utc-auto boolean true
d-i clock-setup/utc boolean true
d-i time/zone string US/Pacific
d-i clock-setup/ntp boolean true

# Packages, Mirrors, Image
d-i base-installer/kernel/override-image string linux-server
d-i base-installer/kernel/override-image string linux-image-amd64
d-i mirror/country string US
d-i mirror/http/proxy string
d-i apt-setup/restricted boolean true
d-i apt-setup/universe boolean true
d-i pkgsel/install-language-support boolean false
tasksel tasksel/first multiselect ubuntu-desktop

# Users
d-i passwd/user-fullname string Liason
d-i passwd/username string liason
d-i passwd/user-password-crypted password [crpyt 3]
d-i passwd/root-login boolean true
d-i passwd/root-password-crypted password [crypt 3]
d-i user-setup/allow-password-weak boolean true

# Grub
d-i grub-installer/grub2_instead_of_grub_legacy boolean true
d-i grub-installer/only_debian boolean true
d-i finish-install/reboot_in_progress note

# Custom Commands

我没有包含加密的密码,因此,如果您尝试使用此预置文件,请将其更改为加密的密码。是三种输入密码的方法。

第5步

我从/opt/ubuntuiso/目录创建了新的ISO 。

mkisofs -D -r -V ATTENDLESS_UBUNTU -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /opt/autoinstall.iso /opt/ubuntuiso

第6步

我终于在Virtualbox上进行了测试,并创建了一个完全无人值守的安装。

问题

我是否需要编辑isolinux/isolinux.cfg文件?

在另一篇文章中,看来他们能够编辑isolinux/txt.cfg文件并能够使该文件生效。我尝试使用约一个小时isolinux/txt.cfg,但没有成功。

有没有人有可以直接指定分区的更复杂的partman配方?还是有效的LVM设置?我尝试使用简单的LVM设置,但重新启动后无法启动,只会出现黑屏。此外,我在文档中列出的上述示例中,没有一个可用。

感谢您的任何帮助。

Answers:


21

接听

从最初询问我的问题开始,我花了一些时间来看看是否还有其他解决方案,但是看起来我在等待时想出的解决方案是迄今为止我所见的唯一可行的解​​决方案。

误解

由于这是造成很多混乱的根源,因此我将尝试清除它。似乎有些答案是在我专门尝试创建无人值守的Ubuntu 16 Desktop映像安装时尝试使用Ubuntu 16 Server映像的。由于di(debian安装程序)和普遍存在的实现差异而引起该问题。由于Server映像将注意并使用预置文件中的所有di命令,因此我提出的大多数问题与Server映像无关。但是,由于将普遍性用作桌面映像的安装程序,因此许多di命令将被忽略,并且您的功能非常有限,并且缺少许多文档。

找到文档链接

  • 是Ubiquity忽略preseed / late_command的链接(我相信它也忽略了preseed / early_command)
  • 是Ubiquity文档,它讨论了Ubiquity中将不使用哪些安装程序组件,但是正如您将注意到的那样,即使在本文档中,它也显示了preseed / early_command,但是我将对其进行全面测试以进行验证,因为它似乎不适用于我(我承认我没有严格测试early_command,所以我可能是错的)。

成功的过程

这是我成功创建无人值守的Ubuntu Desktop 16.04 LTS iso的过程。

挂载Ubuntu ISO

您将需要挂载ISO文件,以便可以编辑相关文件。

mkdir -p /mnt/iso
mount -o loop ~/Downloads/ubuntu-16.04.1-desktop-amd64.iso /mnt/iso

复制ISO文件

我们将需要将已挂载的ISO中的文件复制到其他目录中,以便我们进行编辑。可以随意使用任何您喜欢的目录,由于另一种操作方法,我选择了/ opt目录,但/ tmp也可以轻松使用。

mkdir -p /opt/ubuntuiso
cp -rT /mnt/iso /opt/ubuntuiso

编辑txt.cfg文件

在这里,我们将编辑/opt/ubuntuiso/isolinux/txt.cfg文件并自定义我们的引导参数,以获取完全无人值守的安装,其中将包含预置的文件。使用您选择的任何编辑器:

#default live
#label live
#  menu label ^Try Ubuntu without installing
#  kernel /casper/vmlinuz.efi
#  append  file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash ---
#label live-install
#  menu label ^Install Ubuntu
#  kernel /casper/vmlinuz.efi
#  append  file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.lz quiet splash ---
#label check
#  menu label ^Check disc for defects
#  kernel /casper/vmlinuz.efi
#  append  boot=casper integrity-check initrd=/casper/initrd.lz quiet splash ---
#label memtest
#  menu label Test ^memory
#  kernel /install/mt86plus
#label hd 
#  menu label ^Boot from first hard disk
#  localboot 0x80

default live-install
label live-install
  menu label ^Install Ubuntu
  kernel /casper/vmlinuz.efi
  append  file=/cdrom/ks.preseed auto=true priority=critical debian-installer/locale=en_US keyboard-configuration/layoutcode=us ubiquity/reboot=true languagechooser/language-name=English countrychooser/shortlist=US localechooser/supported-locales=en_US.UTF-8 boot=casper automatic-ubiquity initrd=/casper/initrd.lz quiet splash noprompt noshell ---

请注意以下几点:

  • 我注释掉了文件中的所有原始文本。
  • 我在底部添加了所有文本,包括“默认实时安装”
  • 我将预置文件命名为“ ks.preseed”,它将位于ISO(/ opt / ubuntuiso)的顶级目录中

使用或创建预置文件

请谨慎使用现有的预置文件!我还没有找到任何可行的方法。这并不是说它们不存在,我只是在搜索中没有找到任何东西。配置预置文件的方法有很多,但是我发现许多选项可以忽略,上面我链接的“泛在文档”中以及preseed / late_command与ubiquity / success_command的链接中对此进行了概述。我包括与上述txt.cfg文件一起使用的简单工作预置文件。

对于netcfg / get_hostname字符串netcfg / get_domain字符串,您可以输入任意内容。我使用了unassigned-hostname和unassigned-domain,因为稍后将通过脚本编写过程对其进行更改。

对于要在安装后运行的任何自定义命令,您需要使用:

ubiquity ubiquity/success_command string

后跟您要运行的任何命令。注意用“; \”继续字符串, 并使用“ / target”更改与已安装的新系统有关的任何内容。

# Partitioning
# Old style using d-i command
#d-i partman-auto/disk string /dev/sda
#d-i partman-auto/method string regular
#d-i partman-lvm/device_remove_lvm boolean true
#d-i partman-md/device_remove_md boolean true
#d-i partman-auto/choose_recipe select atomic

# Newer ubiquity command
ubiquity partman-auto/disk string /dev/sda
ubiquity partman-auto/method string regular
ubiquity partman-lvm/device_remove_lvm boolean true
ubiquity partman-md/device_remove_md boolean true
ubiquity partman-auto/choose_recipe select atomic

# This makes partman automatically partition without confirmation
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

# Locale
d-i debian-installer/locale string en_US
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string us

# Network
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/choose_interface select auto

# Clock
d-i clock-setup/utc-auto boolean true
d-i clock-setup/utc boolean true
d-i time/zone string US/Pacific
d-i clock-setup/ntp boolean true

# Packages, Mirrors, Image
d-i mirror/country string US
d-i apt-setup/multiverse boolean true
d-i apt-setup/restricted boolean true
d-i apt-setup/universe boolean true

# Users
d-i passwd/user-fullname string User
d-i passwd/username string user
d-i passwd/user-password-crypted password yourEncryptedPasswd
d-i passwd/user-default-groups string adm audio cdrom dip lpadmin sudo plugdev sambashare video
d-i passwd/root-login boolean true
d-i passwd/root-password-crypted password rootEncryptedPasswd
d-i user-setup/allow-password-weak boolean true

# Grub
d-i grub-installer/grub2_instead_of_grub_legacy boolean true
d-i grub-installer/only_debian boolean true
d-i finish-install/reboot_in_progress note

# Custom Commands
ubiquity ubiquity/success_command string \
  sed -i -e 's/dns=dnsmasq/#dns=dnsmasq/' /target/etc/NetworkManager/NetworkManager.conf ;\
  cp -a /cdrom/scripts/ /target/root/ ;\
  cp -a /cdrom/salt/ /target/root/

请注意这些事项,因为我将它们留作说明之用,它们在您前面的命令中可能会有所不同。

  • 您需要添加用户/ root密码。这里的链接向您展示了制作crypt 3密码的3种不同方法。
  • 您可能需要更改分配给用户的组。
  • 您肯定会想要更改success_command。我留下了它,以显示如何格式化以及如何使用/ target环境。

创建新的ISO

创建ISO,以便您可以测试预置文件。如果使用一个或自己制作,则需要对其进行测试,因为这很可能会导致过程失败。我编写了用于快速测试的脚本,但是您可以将预置文件指向http://托管的预置文件,然后以这种方式进行快速测试。

mkisofs -D -r -V "UNATTENDED_UBUNTU" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /tmp/ubuntu16-desktop-unattended-install.iso /opt/ubuntuiso

随时更改输出名称和保存它的目录。

刻录ISO

我建议您在virtualbox或类似工具上进行测试,一旦工作,将其刻录到DVD上。现在,您应该已经可以正常使用无人值守的Ubuntu Desktop 16.04 LTS安装DVD。

反馈,更正,错误

我一口气写完了所有内容,可能会出现错误,错别字或一堆乱七八糟的东西。如果有人尝试此操作,请在过程中遇到错误时通知我。并且请记住,如果您创建自己的预置文件,由于无处不在的用户喜欢忽略而不执行预置文件中的某些操作,那么我可能无法回答为什么您的无人值守安装被破坏并且无法正常工作。我希望这对某人有帮助。


@BrandonAuthier,您好,谢谢您在此处分享的信息。我非常仔细地遵循了您的所有步骤,最后尝试从最终制作的/tmp/ubuntu16-desktop-unattended-install.iso映像中制作可引导的USB密钥。要做到这一点我用这个命令,作为根(我的USB设备处于的/ dev / SDC) dd if=/tmp/ubuntu16-desktop-unattended-install.iso of=/dev/sdc bs=4M && sync。不幸的是,USB密钥(仅当它包含此自定义iso时才起作用:它适用于原始的iso)不在建议的引导选项中,因此看来它不是“可引导的”。也许您对正在发生的事情有所了解?
Hadrien TOMA

实际上,USB密钥被视为“磁盘驱动器”,而不是“ USB存储设备”(可以从中启动)。
哈德里安·托马

1
我认为创建可引导的USB密钥略有不同,并且需要将isolinux /和isolinux.cfg重命名为syslinux /和syslinux.cfg。我是为CD / DVD编写的,并在VM中使用它进行测试,然后通过DVD安装。我没有尝试将其制成可引导的USB,但是dd命令可能有很多地方出错。如果您不更改这些名称,那可能就是其中一部分。如果您没有正确格式化USB并使用fdisk给它提供可启动标志,那可能是另一个。当我有更多时间时,我可以弄清楚如何做并发布。
布兰登·奥西耶

1
mkusb如果您不熟悉Linux引导和grub / syslinux加载的底层知识,我强烈建议您使用ISO将其放在USB上。
dragon788

1
如果您有Ubuntu计算机,则@HadrienTOMA dragon788可能正确使用mkusb,因为它似乎是由PPA安装的。老实说,查找如何使用fdisk格式化USB,创建适当的文件系统,然后进行dd-ing是值得学习的。我唯一担心的是我的ISO映像可能无法通过仅添加它而起作用。有机会进行测试后,我会通知您。
布兰登·奥西耶

1

听到我以前的方法不起作用,我感到很遗憾。幸运的是,我发现了一个由Rinck Sonnenberg(netson)设计的脚本,该脚本将在GitHub上创建Ubuntu Server的无人值守的AMD64 ISO,并将其分叉。然后,我通过添加创建I386 ISO的功能来改进了脚本。我还将操作系统从Ubuntu Server更改为Ubuntu Desktop。您无需访问GitHub存储库,只需按照以下说明进行操作即可。

运行以下命令:

$ wget https://raw.githubusercontent.com/iPlus-TechNet/ubuntu-unattended/master/create-unattended-iso.sh
$ chmod +x create-unattended-iso.sh
$ sudo ./create-unattended-iso.sh

有时wget不可用。如果是这种情况,请使用curl

$ curl -O https://raw.githubusercontent.com/iPlus-TechNet/ubuntu-unattended/master/create-unattended-iso.sh

如果没有这些工作,下载并将其移动到主文件夹。

然后将询问您要安装哪个版本的Ubuntu,然后询问Ubuntu是否询问您是否正在手动安装。然后,该脚本将下载Ubuntu ISO,然后将请求的更改应用于该脚本。现在您已经有了一个可以随时进行无人值守安装的ISO!

这应该可以回答您的问题,因为它对我来说很好。很好的是,这种方法比我以前的回答要容易得多。希望它对您有用,对我们一样。


1
感谢您的回答,阅读完脚本后,您会看到您正在使用Ubuntu Server,我已经明确地说过多次,现在我不想使用。我已经知道Ubuntu Server使用di并实际上利用了传统的预置参数。但是,我想让Ubuntu Desktop成为我的问题明确指出的问题。我不想安装服务器,必须在安装后构建桌面版本。
Brandon Authier

好。我将其更改为Ubuntu Desktop。
iplustech.net

我修好了它。希望它现在对您有用。
iplustech.net

1
好吧,这应该非常简单-您的脚本仅下载服务器映像-这不是我要求的,这就是您的脚本解决方案失败的原因。它与我的系统有关系,这并不奇怪,因为它是我在该线程问题中明确指出的DESKTOP版本。感谢您的尝试,但是服务器映像无法解决此问题。
Brandon Authier

2
github.com/iPlus-TechNet不再存在了吗?我有一个404错误。
Hadrien TOMA

1

看看:https//github.com/core-process/linux-unattended-installation

该项目为您提供了创建无人值守安装最小化Linux安装所需的全部功能,而最小化却转化为最轻量级的安装-包括OpenSSH服务和Python-您可以从Linux发行版的标准安装程序中获得这些安装。这样做的想法是,一旦完成了最少的设置,您将借助Ansible或类似工具对配置和服务进行所有进一步的部署。


嗯,看起来有点有趣。我肯定会等待18.04 LTS,但是我可能会为弄清楚它的工作方式而感到困惑。我已经通过解决以上所有问题来解决了它。但是,了解其他人如何解决它总是有利于不同的想法。
布兰登·奥西耶

1
刚刚添加了对构建磁盘映像和ISO映像的支持。请享用!
尼古拉斯

1

出色的工作Brandon Authier为您提供了帖子和说明,您对我有很大帮助。

我的方法有一个问题:我发现安装完成并重新启动PC后GRUB挂起。

所以我在ks.preseed中添加了以下内容:

# Due notably to potential USB sticks, the location of the MBR can not be
# determined safely in general, so this needs to be specified:

d-i grub-installer/bootdev  string /dev/sda

# To install to the first device (assuming it is not a USB stick):
#d-i grub-installer/bootdev  string default

如果您不卸下USB记忆棒,这可以防止grub安装崩溃。我是从https://www.debian.org/releases/stable/example-preseed.txt获得的


因为USB仍被插入并尝试再次从USB引导而挂起了?我可以肯定地将其添加到上面的预置文件中,但是想确保我知道发生了什么以及这可以防止什么。
Brandon Authier '18 -10-28

0

请不要尝试这种方法。不起作用(除非您要浪费时间):

我已经看到了所有答案。我将告诉您最常见的解决方案。我从来没有尝试过它,所以它可能已经过时了。我真的不明白这一点,因为仅手动安装本身会更容易,但是无论如何...

以root身份登录或运行 $ sudo su -

下载并安装ISO。不要从Ubuntu网站上手动执行此操作。

# mkdir -p /mnt/iso
# mount -o loop ubuntu.iso /mnt/iso

备份并移动相关文件。

# mkdir -p /opt/ubuntuiso
# cp -rT /mnt/iso /opt/ubuntuiso

阻止GUI的语言部分出现

# cd /opt/ubuntuiso
# echo en >isolinux/lang

添加一个“ Kickstart”文件。

# apt install system-config-kickstart
# system-config-kickstart

[可选]添加安装软件包

# vim /path/to/ks.cfg #[OPTIONAL]

或者只是在文件中搜索它,然后直接对其进行编辑。添加该%packages部分,然后将其包装放在其下。

%packages
# Add your packages below. Example:
@ ubuntu-server
apache2
mysql-server
php7.0
php-pear
libapache2-mod-php7.0 
php7.0-mysql
php7.0-curl
php7.0-json
php7.0-cgi

就像我说的那样,我从来没有自己做过,因此,如果您具有上述配置,那么它实际上可能不会安装LAMP堆栈,您稍后必须手动进行。

用“预设”文件隐藏问题。

# echo 'd-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition \
select Finish partitioning and write changes to disk
d-i partman/confirm boolean true' > ks.preseed

激活文件:

# vi isolinux/txt.cfg

然后搜索:

label install
  menu label ^Install Ubuntu Server
  kernel /install/vmlinuz
  append  file=/cdrom/preseed/ubuntu-server.seed vga=788 initrd=/install/initrd.gz quiet --

然后,您需要添加ks=cdrom:/ks.cfgpreseed/file=/cdrom/ks.preseed。删除单词quietand vga=788,所以它看起来像这样:

append file=/cdrom/preseed/ubuntu-server.seed initrd=/install/initrd.gz ks=cdrom:/ks.cfg preseed/file=/cdrom/ks.preseed --

现在您可以创建新答案:

# mkisofs -D -r -V "ATTENDLESS_UBUNTU" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /opt/autoinstall.iso /opt/ubuntuiso

然后你走了!


现在,我已经看了看周围,我看到了同样的精确公式这里埃拉扎尔Leibovich。我想这是最常见的,我是对的。
iplustech.net,2016年

1
嗯,我不确定在此之前我的评论发生了什么……以上方法无效。如果您正在阅读此文章以寻找答案,请不要尝试此操作,这会浪费您的时间。我在最初的问题中专门链接了这个确切的过程,从而清楚地概述了此方法的缺陷:由于无处不在,从Ubuntu 16.01开始,ks的ps文件太有限了,忽略了许多功能txt.cfg对于Ubuntu Desktop 16.04不起作用,因为您必须传递一些引导参数以绕过甚至达到普遍存在的ps-ding
Brandon Authier

3
海报显然没有看过我的帖子。他写道:“我从来没有尝试过它,所以它可能已经过时了。我真的不明白它的意义,因为仅进行手动安装会更容易,但是无论如何……”。甚至没有尝试并声称它是一种解决方案???其次,我解释说我想要一个无人值守的安装程序,在这里我可以走开。不是手动的。想象一下要安装100个盒子,您要手动进行操作吗?号
Brandon Authier

哦。对于那个很抱歉。我可能会寻找其他方法来做到这一点。
iplustech.net
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.