【转】重新打包DebianISO实现无人应答安装(UEFI+BIOS)
轉(zhuǎn)自:重新打包DebianISO實(shí)現(xiàn)無人應(yīng)答安裝(UEFI+BIOS) - 全部 - 真不是你的
?
之前我寫過打包DebianISO的文章,但是那種打包的方法只能用在引導(dǎo)是BIOS的機(jī)器上,按照正常的情況,應(yīng)該是UEFI+BIOS同時(shí)支持。
正好前兩天給甲骨文重裝系統(tǒng)的時(shí)候需要重新打包支持UEFI的ISO用作本地測試,所以這里把UEFI的打包過程也記錄一下。
Debian的無人應(yīng)答安裝難就難在preseed的配置,因?yàn)闆]有一個(gè)完整的文檔可以參考,基本上只能自己一個(gè)配置一個(gè)配置的去試,少一個(gè)配置可能就會(huì)在安裝的界面彈提示框,出了提示框就不能實(shí)現(xiàn)無人應(yīng)答安裝了。
不過好在我之前已經(jīng)折騰出了一個(gè)Debian10可以完美用的preseed配置,所以在甲骨文的機(jī)器上裝,只需要做一下關(guān)于UEFI的支持即可。
所以這也就是為啥要在本地測試的原因,先在虛擬機(jī)內(nèi)跑,虛擬機(jī)沒問題了再放到甲骨文上試。不過即便是這樣我也還是翻車了很多次,甲骨文的機(jī)器也刪了很多臺(tái)。。這里就不細(xì)說了。。
安裝打包需要用到的工具:
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目錄給寫權(quán)限:
chmod +w -R imlala/install.amd解壓出initrd:
gunzip imlala/install.amd/initrd.gzbios和uefi引導(dǎo)需要修改的文件不同,這里只記錄uefi引導(dǎo)需要修改的位置,bios引導(dǎo)的可以參考我之前的文章。
首先需要把iso內(nèi)關(guān)于uefi引導(dǎo)的grub配置進(jìn)行修改,編輯如下文件:
nano imlala/boot/grub/grub.cfg設(shè)置一個(gè)超時(shí)時(shí)間,這里我設(shè)置為5秒,默認(rèn)情況下是沒有超時(shí)的,也就是說當(dāng)iso掛載上去后,菜單內(nèi)必須要人工手動(dòng)去選擇,為了實(shí)現(xiàn)無人應(yīng)答安裝,必須設(shè)置超時(shí),過了超時(shí)時(shí)間讓iso自動(dòng)進(jìn)入相應(yīng)的grub菜單:
set timeout=5然后把圖形化安裝菜單和文本安裝菜單的位置調(diào)換一下,默認(rèn)是圖形化安裝在grub菜單的第一位,為啥要調(diào)換位置?因?yàn)閳D形化菜單是不支持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 }具體改動(dòng)的位置:
然后就是老套路了,新建一個(gè)preseed配置文件:
nano preseed.cfg寫入你需要的配置,下面這個(gè)配置是我經(jīng)過測試的,目前可以用在debian10.9上:
# 配置語言 d-i debian-installer/locale string en_US # 配置鍵盤 d-i keyboard-configuration/xkb-keymap select us # 使用自動(dòng)的方式配置網(wǎng)絡(luò)(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登錄并設(shè)置root密碼,關(guān)閉普通用戶創(chuàng)建 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 # 設(shè)置時(shí)區(qū)為東八區(qū) d-i clock-setup/utc boolean true d-i time/zone string Asia/Shanghai d-i clock-setup/ntp boolean false # 硬盤分區(qū),注意/dev/sda這里的設(shè)備名,要改為你自己的設(shè)備名,一般虛擬機(jī)如VMware/VirtualBox都是這個(gè)設(shè)備名 d-i partman-auto/disk string /dev/sda d-i partman-auto/method string regular # 手動(dòng)劃分分區(qū)大小 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{ / } \ . \ # 因甲骨文的機(jī)器是efi引導(dǎo),所以這里強(qiáng)制使用gpt分區(qū)表 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 # 如果硬盤內(nèi)之前有l(wèi)vm或是raid的分區(qū),全部刪除 d-i partman-md/device_remove_md boolean true d-i partman-lvm/device_remove_lvm boolean true # 下面的這些配置可以做到?jīng)]有交互式的完成硬盤分區(qū) 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 # 禁止在安裝的時(shí)候彈出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 # 安裝額外的軟件包,不更新系統(tǒng) d-i pkgsel/include string openssh-server d-i pkgsel/upgrade select none # 禁止在安裝的時(shí)候彈出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服務(wù)使用root用戶登錄 d-i preseed/late_command string in-target sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config這里詳細(xì)說一下關(guān)于手動(dòng)分區(qū)的配置,可能很多人不理解分區(qū)這塊的配置。
分區(qū)那里的三個(gè)數(shù)字,比如說512 3 512,第一個(gè)512代表最小分區(qū)大小,第二個(gè)數(shù)字代表優(yōu)先級(jí),數(shù)字越小表示優(yōu)先級(jí)越高,第三個(gè)數(shù)字代表最大分區(qū)大小。如果第三個(gè)數(shù)字設(shè)置為-1就代表剩下的空間全部劃分給這個(gè)分區(qū)。
然后尤其注意這個(gè)配置:
d-i partman-efi/non_efi_system boolean true如果在preseed內(nèi)配置了這個(gè)BIOS引導(dǎo)直接失效,它將強(qiáng)制使用UEFI引導(dǎo),所以如果你要UEFI+BIOS同時(shí)支持,這個(gè)配置需要從preseed中刪除。
接下來把改好的配置內(nèi)嵌到initrd:
echo preseed.cfg | cpio -H newc -o -A -F imlala/install.amd/initrd重新壓縮initrd:
gzip imlala/install.amd/initrd還原install.amd目錄之前的權(quán)限:
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在虛擬機(jī)上啟用uefi引導(dǎo):
測試安裝,文本安裝選項(xiàng)在第一啟動(dòng)位:
等待5秒超時(shí)過后,自動(dòng)安裝開始:
參考文獻(xiàn):
https://wiki.syslinux.org/wiki/index.php?title=Isohybrid
https://wiki.debian.org/DebianInstaller/Preseed/EditIso
總結(jié)
以上是生活随笔為你收集整理的【转】重新打包DebianISO实现无人应答安装(UEFI+BIOS)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 车主信用卡怎么申请?车主信用卡常见问题及
- 下一篇: 写让别人能读懂的代码