如何在多台预装Windows10的设备上无人值守安装Ubuntu16.04?
如何在预装Windows 10的设备上全自动安装Ubuntu Desktop 16.04?
我之前也跟你一样,要给一堆预装Windows 10的机器部署Ubuntu 16.04,想着搞全自动安装省点力气,结果查了一堆官方文档和教程全踩坑——要么每次都卡在「选择安装类型」的弹窗,要么官方文档里的语法早就失效了。折腾了好几天才摸出可行的方案,现在分享出来帮大家少走弯路。
核心问题拆解
我们要解决的核心就是跳过所有磁盘分区相关的交互提示,尤其是那个「选择安装类型」的弹窗,同时确保整个安装流程完全自动化。下面是一步步的实操方案:
1. 准备基础安装U盘
先按常规方法制作Ubuntu 16.04的安装U盘:
- 可以用命令行工具:
dd if=ubuntu-16.04-desktop-amd64.iso of=/dev/sdX bs=4M status=progress(替换/dev/sdX为你的U盘设备) - 或者用Rufus这类可视化工具,注意不要勾选「持久化存储」,保持纯安装介质即可
2. 编写有效的preseed.cfg(关键中的关键)
旧文档里的partman参数大多已经失效,这就是为什么你会卡在分区步骤。下面是经过验证的有效配置,重点关注磁盘分区相关的参数:
# 基础系统配置 d-i debian-installer/locale string en_US.UTF-8 d-i console-setup/ask_detect boolean false d-i console-setup/layoutcode string us d-i time/zone string Asia/Shanghai d-i clock-setup/utc boolean true # 用户配置(按需修改) d-i passwd/user-fullname string UbuntuAdmin d-i passwd/username string ubuntu d-i passwd/user-password password yourSecurePassword d-i passwd/user-password-again password yourSecurePassword # 核心:跳过磁盘分区交互(解决「选择安装类型」弹窗) 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 # 选择「使用整个磁盘」的方案:atomic是带LVM,plain是不带LVM,按需选择 d-i partman-auto/choose_recipe select atomic # 自动确认所有磁盘操作 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 # 额外配置:安装openssh-server,方便远程管理 d-i pkgsel/include string openssh-server # 安装完成自动重启 d-i finish-install/reboot_in_progress note
把这个文件保存为preseed.cfg,放到U盘的根目录下。
3. 修改U盘启动参数,引导自动安装
根据你的设备是BIOS还是UEFI启动,修改对应的配置文件:
对于BIOS启动(isolinux)
找到U盘里的isolinux/txt.cfg,修改默认的install启动项,在append后面加上file=/cdrom/preseed.cfg automatic-ubiquity noprompt:
label install menu label ^Install Ubuntu kernel /casper/vmlinuz.efi append file=/cdrom/preseed.cfg boot=casper automatic-ubiquity noprompt quiet splash ---
对于UEFI启动(GRUB)
找到U盘里的boot/grub/grub.cfg,修改默认的「Install Ubuntu」启动项,同样在linux行的参数里加上file=/cdrom/preseed.cfg automatic-ubiquity noprompt:
menuentry "Install Ubuntu" { set gfxpayload=keep linux /casper/vmlinuz.efi file=/cdrom/preseed.cfg boot=casper automatic-ubiquity noprompt quiet splash --- initrd /casper/initrd.lz }
4. 测试自动安装
把U盘插到目标设备上,设置从U盘启动,正常情况下整个安装流程会完全自动进行:
- 不会弹出语言、时区选择窗口
- 不会出现「选择安装类型」的弹窗
- 安装完成后自动重启进入新系统
内容的提问来源于stack exchange,提问作者Mexanizator
相关产品推荐
相关产品推荐

