【转】重新打包DebianISO实现无人应答安装(UEFI+BIOS)
轉自:重新打包DebianISO實現無人應答安裝(UEFI+BIOS) - 全部 - 真不是你的
?
之前我寫過打包DebianISO的文章,但是那種打包的方法只能用在引導是BIOS的機器上,按照正常的情況,應該是UEFI+BIOS同時支持。
正好前兩天給甲骨文重裝系統的時候需要重新打包支持UEFI的ISO用作本地測試,所以這里把UEFI的打包過程也記錄一下。
Debian的無人應答安裝難就難在preseed的配置,因為沒有一個完整的文檔可以參考,基本上只能自己一個配置一個配置的去試,少一個配置可能就會在安裝的界面彈提示框,出了提示框就不能實現無人應答安裝了。
不過好在我之前已經折騰出了一個Debian10可以完美用的preseed配置,所以在甲骨文的機器上裝,只需要做一下關于UEFI的支持即可。
所以這也就是為啥要在本地測試的原因,先在虛擬機內跑,虛擬機沒問題了再放到甲骨文上試。不過即便是這樣我也還是翻車了很多次,甲骨文的機器也刪了很多臺。。這里就不細說了。。
安裝打包需要用到的工具:
apt -y update apt -y install xorriso isolinux syslinux-utils p7zip-full下載debian的iso并解壓:
wget https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.9.0-amd64-netinst.iso 7z x debian-10.9.0-amd64-netinst.iso -oimlala把install.amd目錄給寫權限:
chmod +w -R imlala/install.amd解壓出initrd:
gunzip imlala/install.amd/initrd.gzbios和uefi引導需要修改的文件不同,這里只記錄uefi引導需要修改的位置,bios引導的可以參考我之前的文章。
首先需要把iso內關于uefi引導的grub配置進行修改,編輯如下文件:
nano imlala/boot/grub/grub.cfg設置一個超時時間,這里我設置為5秒,默認情況下是沒有超時的,也就是說當iso掛載上去后,菜單內必須要人工手動去選擇,為了實現無人應答安裝,必須設置超時,過了超時時間讓iso自動進入相應的grub菜單:
set timeout=5然后把圖形化安裝菜單和文本安裝菜單的位置調換一下,默認是圖形化安裝在grub菜單的第一位,為啥要調換位置?因為圖形化菜單是不支持preseed的:
menuentry --hotkey=i 'Install' { set background_color=black linux /install.amd/vmlinuz vga=788 --- quiet initrd /install.amd/initrd.gz } menuentry --hotkey=g 'Graphical install' { set background_color=black linux /install.amd/vmlinuz vga=788 --- quiet initrd /install.amd/gtk/initrd.gz }具體改動的位置:
然后就是老套路了,新建一個preseed配置文件:
nano preseed.cfg寫入你需要的配置,下面這個配置是我經過測試的,目前可以用在debian10.9上:
# 配置語言 d-i debian-installer/locale string en_US # 配置鍵盤 d-i keyboard-configuration/xkb-keymap select us # 使用自動的方式配置網絡(DHCP) d-i netcfg/choose_interface select auto # 配置hostname和domain d-i netcfg/get_hostname string unassigned-hostname d-i netcfg/get_domain string unassigned-domain d-i netcfg/hostname string imlala # 配置軟件源 d-i mirror/country string manual d-i mirror/http/hostname string ftp.jp.debian.org d-i mirror/http/directory string /debian d-i mirror/http/proxy string # 開啟root登錄并設置root密碼,關閉普通用戶創建 d-i passwd/root-login boolean true d-i passwd/make-user boolean false d-i passwd/root-password password 123456 d-i passwd/root-password-again password 123456 # 設置時區為東八區 d-i clock-setup/utc boolean true d-i time/zone string Asia/Shanghai d-i clock-setup/ntp boolean false # 硬盤分區,注意/dev/sda這里的設備名,要改為你自己的設備名,一般虛擬機如VMware/VirtualBox都是這個設備名 d-i partman-auto/disk string /dev/sda d-i partman-auto/method string regular # 手動劃分分區大小 d-i partman-auto/expert_recipe string \ boot-root :: \ 1 1 1 free \ $bios_boot{ } \ method{ biosgrub } \ . \ 256 2 256 fat32 \ $primary{ } \ $iflabel{ gpt } \ $reusemethod{ } \ method{ efi } format{ } \ mountpoint{ /boot/efi } \ . \ 512 3 512 ext4 \ $primary{ } \ $bootable{ } \ method{ format } format{ } \ use_filesystem{ } filesystem{ ext4 } \ mountpoint{ /boot } \ . \ 1024 5 1024 linux-swap \ $primary{ } \ method{ swap } format{ } \ . \ 1 4 -1 ext4 \ $primary{ } \ method{ format } format{ } \ use_filesystem{ } filesystem{ ext4 } \ mountpoint{ / } \ . \ # 因甲骨文的機器是efi引導,所以這里強制使用gpt分區表 d-i partman-efi/non_efi_system boolean true d-i partman-partitioning/choose_label string gpt d-i partman-partitioning/default_label string gpt # 如果硬盤內之前有lvm或是raid的分區,全部刪除 d-i partman-md/device_remove_md boolean true d-i partman-lvm/device_remove_lvm boolean true # 下面的這些配置可以做到沒有交互式的完成硬盤分區 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 # 禁止在安裝的時候彈出CD/DVD掃描提示 d-i apt-setup/non-free boolean true d-i apt-setup/contrib boolean true d-i apt-setup/cdrom/set-first boolean false d-i apt-setup/cdrom/set-next boolean false d-i apt-setup/cdrom/set-failed boolean false # 軟件包選擇 tasksel tasksel/first multiselect standard # 安裝額外的軟件包,不更新系統 d-i pkgsel/include string openssh-server d-i pkgsel/upgrade select none # 禁止在安裝的時候彈出popularity popularity-contest popularity-contest/participate boolean false # grub安裝 d-i grub-installer/only_debian boolean true d-i grub-installer/with_other_os boolean true d-i grub-installer/bootdev string default # 安裝完成之后不要彈出安裝完成的界面,直接重啟 d-i finish-install/reboot_in_progress note # 允許ssh服務使用root用戶登錄 d-i preseed/late_command string in-target sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config這里詳細說一下關于手動分區的配置,可能很多人不理解分區這塊的配置。
分區那里的三個數字,比如說512 3 512,第一個512代表最小分區大小,第二個數字代表優先級,數字越小表示優先級越高,第三個數字代表最大分區大小。如果第三個數字設置為-1就代表剩下的空間全部劃分給這個分區。
然后尤其注意這個配置:
d-i partman-efi/non_efi_system boolean true如果在preseed內配置了這個BIOS引導直接失效,它將強制使用UEFI引導,所以如果你要UEFI+BIOS同時支持,這個配置需要從preseed中刪除。
接下來把改好的配置內嵌到initrd:
echo preseed.cfg | cpio -H newc -o -A -F imlala/install.amd/initrd重新壓縮initrd:
gzip imlala/install.amd/initrd還原install.amd目錄之前的權限:
chmod -w -R imlala/install.amd最后重新打包iso:
xorriso -as mkisofs \ -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \ -c isolinux/boot.cat \ -b isolinux/isolinux.bin \ -no-emul-boot \ -boot-load-size 4 \ -boot-info-table \ -eltorito-alt-boot \ -e boot/grub/efi.img \ -no-emul-boot \ -isohybrid-gpt-basdat \ -o preseed-debian-10.9.0-amd64-netinst.iso \ imlala在虛擬機上啟用uefi引導:
測試安裝,文本安裝選項在第一啟動位:
等待5秒超時過后,自動安裝開始:
參考文獻:
https://wiki.syslinux.org/wiki/index.php?title=Isohybrid
https://wiki.debian.org/DebianInstaller/Preseed/EditIso
總結
以上是生活随笔為你收集整理的【转】重新打包DebianISO实现无人应答安装(UEFI+BIOS)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 车主信用卡怎么申请?车主信用卡常见问题及
- 下一篇: 央行14天期逆回购利率下降,逆回购利率下