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

我需要一个CD或USB棒,它将在完全无头的机器上安装Ubuntu。 粘贴CD并重新启动,不应涉及键盘或屏幕。

有一些障碍:

  1. 首次启动CD时的语言选择菜单。
  2. CD菜单等待的事实。
  3. 安装程序在安装过程中提出问题。

完整的解决方案是:

重新制作CD,即下载非图形ubuntu安装ISO(服务器或备用安装CD),然后安装它

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

将相关文件复制到其他目录

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

防止出现语言选择菜单

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

使用GUI程序添加名为ks.cfg的kickstart文件

 # apt-get install system-config-kickstart # system-config-kickstart # save file to ks.cfg 

要为安装添加软件包,请将%package部分添加到ks.cfg kickstart文件中,附加到ks.cfg文件的末尾,如下所示。

 %packages @ ubuntu-server openssh-server ftp build-essential 

这将安装ubuntu-server“bundle”,并将添加openssh-serverftpbuild-essential软件包。

添加预置文件,以禁止其他问题

 # 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 

设置引导命令行以使用kickstart和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 -- 

现在创建一个新的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 

而已。 你有一张CD,一旦你启动它就可以安装Ubuntu系统,而不需要一次击键。

这是一个执行此过程的shell脚本,感谢您的介绍: http : //www.utech.de/2013/05/shell-script-creating-a-cd-for-unattended-ubuntu-server-installations/

您在链接后找到的脚本基本上实现了@Elazar描述的过程,因此基本部分只是上面的一个屏幕。 我添加了链接以节省一些时间,并使其更容易重复此其他版本的Ubuntu。

此问题的说明涵盖了创建EFI可引导ISO(如官方Ubuntu x86_64 ISO)的过程:

如何创建自定义版本的Ubuntu的EFI可引导ISO?

关键区别是将其设置为预置文件:

 di partman-auto/method string lvm di partman-auto-lvm/guided_size string max di partman-auto/choose_recipe select atomic di partman-partitioning/confirm_write_new_label boolean true di partman/confirm_write_new_label boolean true di partman/choose_partition select finish di partman/confirm_nooverwrite boolean true di partman/confirm boolean true di partman-auto/purge_lvm_from_device boolean true di partman-lvm/device_remove_lvm boolean true di partman-lvm/confirm boolean true di partman-lvm/confirm_nooverwrite boolean true di partman-auto/init_automatically_partition select Guided - use entire disk and set up LVM di partman/choose_partition select Finish partitioning and write changes to disk di partman-auto-lvm/no_boot boolean true di partman-md/device_remove_md boolean true di partman-md/confirm boolean true di partman-md/confirm_nooverwrite boolean true 

使用此作为kickstart文件:

 lang en_US langsupport en_US keyboard us mouse timezone America/Los_Angeles rootpw --disabled user USERNAME --fullname "USERNAME" --password "PASSWORD" reboot text install cdrom auth --useshadow --enablemd5 network --bootproto=dhcp --device=eth0 firewall --disabled skipx %packages @ ubuntu-server openssh-server 

编辑ISO的grub EFI启动配置:

 sudo nano ~/ubuntu/boot/grub/grub.cfg 

调成:

 if loadfont /boot/grub/font.pf2 ; then set gfxmode=auto insmod efi_gop insmod efi_uga insmod gfxterm terminal_output gfxterm fi set menu_color_normal=white/light-blue set menu_color_highlight=light-blue/light-gray set timeout=10 set default=0 menuentry "Automatically Install Ubuntu Server with Custom Config" { set gfxpayload=keep linux /install/vmlinuz file=/cdrom/preseed/ubuntu-server.seed quiet ks=cdrom:/ks.cfg preseed/file=/cdrom/ks.preseed -- initrd /install/initrd.gz } menuentry "OEM install (for manufacturers)" { set gfxpayload=keep linux /install/vmlinuz file=/cdrom/preseed/ubuntu-server.seed quiet oem-config/enable=true -- initrd /install/initrd.gz } menuentry "Multiple server install with MAAS" { set gfxpayload=keep linux /install/vmlinuz modules=maas-enlist-udeb vga=788 initrd=/install/initrd.gz quiet -- initrd /install/initrd.gz } menuentry "Check disc for defects" { set gfxpayload=keep linux /install/vmlinuz MENU=/bin/cdrom-checker-menu quiet -- initrd /install/initrd.gz } menuentry "Rescue a broken system" { set gfxpayload=keep linux /install/vmlinuz rescue/enable=true -- initrd /install/initrd.gz } 

像这样设置isolinux / txt.cfg:

 default install label install menu label ^Install Ubuntu Server with Custom Config kernel /install/vmlinuz append file=/cdrom/preseed/ubuntu-server.seed initrd=/install/initrd.gz ks=cdrom:/ks.cfg preseed/file=/cdrom/ks.preseed -- label cloud menu label ^Multiple server install with MAAS kernel /install/vmlinuz append modules=maas-enlist-udeb vga=788 initrd=/install/initrd.gz quiet -- label check menu label ^Check disc for defects kernel /install/vmlinuz append MENU=/bin/cdrom-checker-menu vga=788 initrd=/install/initrd.gz quiet -- label memtest menu label Test ^memory kernel /install/mt86plus label hd menu label ^Boot from first hard disk localboot 0x80 

创建双启动目录ISO:

 sudo mkisofs -U -A "Custom1404" -V "Custom1404" -volset "Custom1404" -J -joliet-long -r -v -T -o ../Custom1404.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot . 

validation是否已创建EFI可引导ISO:

 dumpet -i Custom1404.iso 

输出:

 Validation Entry: Header Indicator: 0x01 (Validation Entry) PlatformId: 0x00 (80x86) ID: "" Checksum: 0x55aa Key bytes: 0x55aa Boot Catalog Default Entry: Entry is bootable Boot Media emulation type: no emulation Media load segment: 0x0 (0000:7c00) System type: 0 (0x00) Load Sectors: 4 (0x0004) Load LBA: 3100 (0x00000c1c) Section Header Entry: Header Indicator: 0x91 (Final Section Header Entry) PlatformId: 0xef (EFI) Section Entries: 1 ID: "" Boot Catalog Section Entry: Entry is bootable Boot Media emulation type: no emulation Media load address: 0 (0x0000) System type: 0 (0x00) Load Sectors: 4672 (0x1240) Load LBA: 1932 (0x0000078c) 

在AskUbuntu的答案的以下链接中描述了一种相当简单的方法,

如何制作可启动,无人值守的USB还原磁盘?

  • 使用便携式网络连接创建所需的系统,例如根据

    • 未管理的有线网络或
    • help.ubuntu.com/community/Installation/UEFI-and-BIOS
  • 制作系统的[压缩] dd-image文件 (我认为这比重新制作更容易)。

  • 根据此描述, 制作一个shellcript并通过持久性实时系统中的“autostart”进行调用 。 您可以通过最少的修改(可能只匹配压缩的图像文件的名称)来完成它,或者您可以修改它以适合您的特定情况。