承接上集,完成硬碟分區、格式化、GRUB 安裝與核心準備後,本文介紹自動安裝配置檔建立、安裝媒體複製、GRUB 選單配置與最終部署驗證。
mkdir -p /mnt/sdb/SUSE
cp -r /path/to/SUSE-ISO/* /mnt/sdb/SUSE/
關鍵:必須解壓 ISO 內容至目錄,**不可直接放置 ISO 檔案**,SLES 10 不支援從 ISO 直接安裝。
使用 YaST「自動安裝」模組生成 autoinst.xml,重點修改兩段:
<bootloader>
<sections config:type="list">
<section>
<append>ramdisk_size=8192 install=hd://sda1/SUSE autoyast=file:///mounts/extra/autoinst.xml splash=silent showopts</append>
<initrd>(hd0,0)/boot/initrd</initrd>
<kernel>(hd0,0)/boot/linux</kernel>
<name>SUSE Linux Enterprise Server 10 Installation</name>
<original_name>install</original_name>
<root>/dev/sda1</root>
<type>image</type>
</section>
</sections>
</bootloader>
警告:選擇此項將格式化使用者分區並重新安裝,資料全失。
<partitioning config:type="list">
<drive>
<device>/dev/sda</device>
<partitions config:type="list">
<partition> <!-- 安裝分區:不建立、不格式化 -->
<create config:type="boolean">false</create>
<filesystem config:type="symbol">ext3</filesystem>
<format config:type="boolean">false</format>
<partition_id config:type="integer">131</partition_id>
<partition_nr config:type="integer">1</partition_nr>
<size>7402719232</size>
</partition>
<partition> <!-- swap -->
<filesystem config:type="symbol">swap</filesystem>
<format config:type="boolean">true</format>
<mount>swap</mount>
<partition_nr config:type="integer">2</partition_nr>
<size>auto</size>
</partition>
<partition> <!-- 根分區 -->
<filesystem config:type="symbol">reiser</filesystem>
<format config:type="boolean">true</format>
<mount>/</mount>
<partition_nr config:type="integer">3</partition_nr>
<size>max</size>
</partition>
</partitions>
<use>all</use>
</drive>
</partitioning>
核心原則:**create=false + format=false 保護安裝分區資料**。
cp autoinst.xml /mnt/sdb/
安裝時系統會將第一分區掛載至 /mounts/extra,故 autoyast=file:///mounts/extra/autoinst.xml 能正確找到配置。
vi /mnt/sdb/boot/grub/menu.lst
color white/blue black/light-gray
default 0
timeout 30
title SUSE Linux Enterprise Server 10 Installation
root (hd0,0)
kernel /boot/linux root=/dev/sda1 ramdisk_size=8192 install=hd://sda1/SUSE autoyast=file:///mounts/extra/autoinst.xml splash=silent showopts
initrd /boot/initrd
關鍵點:
install=hd://sda1/SUSE:硬碟安裝來源協議autoyast 協議用 file:// 而非裝置路徑(SUSE 已知問題)append 關鍵字,直接在 kernel 行傳參數用戶若需重置系統,重啟時選擇 GRUB 選單中的「SUSE Linux Enterprise Server 10 Installation」,系統將自動格式化使用者分區並重裝,實現「一鍵恢復出廠狀態」。
此流程比手動安裝更靈活,實現從啟動即自動完成硬體偵測、分區、軟體安裝、配置的全自動化部署,適合批量刀片伺服器初始化場景。