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

目的

我想完全无人值守地安装Ubuntu Desktop 16.04.1 LTS。 把ISO CD放进去吧。

问题

  • 启动参数不正确
  • 问题仍然存在,需要点击鼠标
  • 使用kickstart / preseed的复杂答案
  • 文档示例没有按照规定工作,特别是来自partman和ubunutu

我在这里发现了这篇文章,它接近我需要的东西,但是因为它是Ubuntu Server所以没有完全达到我所需要的。 该post建议使用“非图形”Ubuntu安装,但我找不到Ubuntu桌面的非图形安装,这是有道理的。 我尝试调整这些步骤,让它适用于Ubuntu Desktop 16.04.1 LTS。

使用的文档

我使用了以下所有资源……

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

  • AskUbuntu
  • Ubuntu install.en.pdf
  • 预先存在的例子
  • Ubiquity安装程序文档
  • Partman文档和示例
  • 分区配方解释3个数字及其权重
  • 一个更复杂的预定示例

当前解决方案

我目前创建了一个无人参与的安装,但我不确定它是否正确 – 这意味着我应该编辑isolinux / isolinux.cfg

我链接的post和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 

第3步

我编辑了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,它可能会有所不同。

第4步

我尝试使用并创建了许多预置文件,但我发现越复杂,出错的可能性就越大。 这是我目前使用上述isolinux.cfg文件的简单preseed文件。

 ### Partitioning di partman-auto/disk string /dev/sda di partman-auto/method string regular di partman-lvm/device_remove_lvm boolean true di partman-md/device_remove_md boolean true di partman-auto/choose_recipe select atomic # This makes partman automatically partition without confirmation di partman-partitioning/confirm_write_new_label boolean true di partman/choose_partition select finish di partman/confirm boolean true di partman/confirm_nooverwrite boolean true # Locale di debian-installer/locale string en_US di console-setup/ask_detect boolean false di console-setup/layoutcode string us # Network di netcfg/get_hostname string unassigned-hostname di netcfg/get_domain string unassigned-domain di netcfg/choose_interface select auto # Clock di clock-setup/utc-auto boolean true di clock-setup/utc boolean true di time/zone string US/Pacific di clock-setup/ntp boolean true # Packages, Mirrors, Image di base-installer/kernel/override-image string linux-server di base-installer/kernel/override-image string linux-image-amd64 di mirror/country string US di mirror/http/proxy string di apt-setup/restricted boolean true di apt-setup/universe boolean true di pkgsel/install-language-support boolean false tasksel tasksel/first multiselect ubuntu-desktop # Users di passwd/user-fullname string Liason di passwd/username string liason di passwd/user-password-crypted password [crpyt 3] di passwd/root-login boolean true di passwd/root-password-crypted password [crypt 3] di user-setup/allow-password-weak boolean true # Grub di grub-installer/grub2_instead_of_grub_legacy boolean true di grub-installer/only_debian boolean true di finish-install/reboot_in_progress note # Custom Commands 

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

第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文件并且能够使其工作。 我尝试使用isolinux/txt.cfg大约一个小时,但它没有用。

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

感谢您的任何帮助。

回答

我从原来问我的问题看了一段时间,看看是否有其他解决方案,但看起来我等待的解决方案是迄今为止我见过的唯一可行的解​​决方案。

误解

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

找到文档链接

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

成功的过程

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

Mount 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 --- 

请注意以下几点:

  • 我注释掉了文件中的所有原始文本。
  • 我在底部添加了所有文本,包括“default live-install”
  • 我将preseed文件命名为“ks.preseed”,它将位于ISO的顶级目录中(/ opt / ubuntuiso)

使用或创建预置文件

请谨慎使用已存在的preseed文件! 我还没有找到任何正常工作。 这并不是说它们不存在,我只是没有找到任何相当多的搜索。 配置preseed文件的方法有很多种,但我发现有许多选项可供忽略,我在上面链接的Ubiquity文档和preseed / late_command vs ubiquity / success_command的链接中概述了这些选项。 我包括我的简单工作preseed文件,该文件适用于上面的txt.cfg文件。

对于netcfg / get_hostname字符串netcfg / get_domain字符串,您可以放置​​任何您想要的内容。 我使用了unassigned-hostname和unassigned-domain,因为我稍后会通过脚本编写过程更改它。

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

 ubiquity ubiquity/success_command string 

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

 # Partitioning # Old style using di command #di partman-auto/disk string /dev/sda #di partman-auto/method string regular #di partman-lvm/device_remove_lvm boolean true #di partman-md/device_remove_md boolean true #di 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 di partman-partitioning/confirm_write_new_label boolean true di partman/choose_partition select finish di partman/confirm boolean true di partman/confirm_nooverwrite boolean true # Locale di debian-installer/locale string en_US di console-setup/ask_detect boolean false di console-setup/layoutcode string us # Network di netcfg/get_hostname string unassigned-hostname di netcfg/get_domain string unassigned-domain di netcfg/choose_interface select auto # Clock di clock-setup/utc-auto boolean true di clock-setup/utc boolean true di time/zone string US/Pacific di clock-setup/ntp boolean true # Packages, Mirrors, Image di mirror/country string US di apt-setup/multiverse boolean true di apt-setup/restricted boolean true di apt-setup/universe boolean true # Users di passwd/user-fullname string User di passwd/username string user di passwd/user-password-crypted password yourEncryptedPasswd di passwd/user-default-groups string adm audio cdrom dip lpadmin sudo plugdev sambashare video di passwd/root-login boolean true di passwd/root-password-crypted password rootEncryptedPasswd di user-setup/allow-password-weak boolean true # Grub di grub-installer/grub2_instead_of_grub_legacy boolean true di grub-installer/only_debian boolean true di 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密码。 这是一个链接,向您显示3种不同的方法来制作crypt 3密码。
  • 您可能希望更改用户分配到的组。
  • 您肯定想要更改success_command。 我离开它来展示如何格式化以及如何使用/ target环境。

创建新的ISO

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

 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

我建议在虚拟机等上进行测试,一旦你运行它,然后将其刻录成DVD。 您现在应该有一个无人值守的Ubuntu Desktop 16.04 LTS安装DVD。

反馈,更正,错误

我一气呵成地写了这一切,可能会有错误,拼写错误或一路上乱七八糟的事情。 如果有人试图这样做,如果您在此过程中遇到错误,请告诉我。 请记住,如果你创建自己的preseed文件,我可能无法回答为什么你的无人值守安装被破坏而无法工作,因为普遍存在喜欢忽略而不在预置文件中做某些事情。 我希望这对某人有帮助。

我很遗憾听到我以前的方法不起作用。 幸运的是,我发现了一个由Rinck Sonnenberg( netson )设计的脚本,它将在GitHub上创建Ubuntu Server的无人值守的AMD64 ISO,我分叉了它。 然后,我通过添加创建I386 ISO的function来改进脚本。 我还将操作系统从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!

这应该回答你的问题,因为它对我来说效果很好。 这种方法比我以前的答案容易得多,这也很好。 我希望它对你有用,就像它对我们一样。

请不要尝试这种方法。 不工作(除非你想要杀死时间):

我已经看到了这个问题的答案。 我会告诉你最常见的解决方案。 我以前从未尝试过,所以它可能已经过时了。 我真的不明白它的意义,因为只是手动安装本身会更容易,但无论如何……

以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 'di partman/confirm_write_new_label boolean true di partman/choose_partition \ select Finish partitioning and write changes to disk di 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 。 删除单词quietvga=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 

你去吧!

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

该项目提供了创建Linux最小设置的无人参与安装所需的一切,而最小化则转换为最轻量级的设置 – 包括OpenSSH服务和Python – 您可以从Linux发行版的标准安装程序派生。 我们的想法是,一旦完成最小化设置,您将在Ansible或类似工具的帮助下进一步部署您的配置和服务。

伟大的工作Brandon Authier为您的post和说明,你帮助了我很多。

我的方法有一个问题:我发现在安装完成并且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: di grub-installer/bootdev string /dev/sda # To install to the first device (assuming it is not a USB stick): #di grub-installer/bootdev string default 

如果不移除USB记忆棒,这可以防止崩溃grub安装。 我从https://www.debian.org/releases/stable/example-preseed.txt得到了这个