BigAdmin System Administration Portal
在 x86/x64 平台上搭配使用 Solaris JumpStart 與 Solaris 10 作業系統
Print-friendly VersionPrint-friendly Version

在 x86/x64 平台上搭配使用 Solaris JumpStart 與 Solaris 10 作業系統

Craig Winter 與 Dale Layfield,2007 年 3 月


摘要

Sun Microsystems 的 Solaris JumpStart 技術可用於在多個網路節點上自動安裝 Solaris 作業系統與其他相關軟體。

在 x86/x64 平台與在 SPARC 平台上對 Solaris 10 作業系統使用 Solaris JumpStart 軟體,基本上方法相同。但若要正確運作,仍必須注意兩者之間的些微差異。

此文件將提供必要的步驟與說明,讓您瞭解如何為 Sun x86/x64 機器上的 Solaris 10 作業系統設定 JumpStart 伺服器,以及如何為兩個或更多用戶端配置 JumpStart。

如需一般性的參考資料,請參閱 Sun 線上文件使用自訂 JumpStart


簡介

此文提供可讓您使用 x86/x64 平台的 Solaris 10 作業系統建立 JumpStart 伺服器的逐步程序。這一版的 Solaris 10 作業系統適用於伺服器上執行的作業系統,以及 JumpStart 安裝伺服器上的作業系統。使用 AMD Opteron 與 Intel 處理器的機器皆可做為伺服器與用戶端,使用哪一種處理器對效果並無影響。

另提供下列作業的相關指示:

用戶端上必須啟用 Pre-boot Execution Environment (PXE),才能從網路開機。在某些用戶端上,PXE 必須在 BIOS 中啟用。

建立用戶端啟動檔案時所產生的錯誤,在「最終清除」一節中有相關說明。


Solaris JumpStart 程序

這些指示可引導您設定 JumpStart 安裝伺服器,進而在兩個用戶端上安裝適用於 x86/x64 平台的 Solaris 10 作業系統。

在此練習中,JumpStart 伺服器的節點名稱為 stinger2,其 IP 位址為 172.16.64.194。預設路由器的 IP 位址是 172.16.64.1。JumpStart 伺服器所在的網路位址是 172.16.64.0

如有需要,您可以下載 Solaris 10 作業系統

1. 建立 JumpStart 安裝伺服器

a. 在伺服器上建立安裝目錄:

# mkdir -p /export/install

b. 將適用於 x86/x64 平台的 Solaris 10 作業系統 DVD 放入伺服器的 DVD 播放器中。移至 DVD 的 Solaris_10/Tools 目錄並執行 setup_install_server 指令,以建立安裝伺服器。Solaris 軟體會複製到新建立的目錄。將絕對路徑名稱指定為引數。

# cd /cdrom/cdrom0/Solaris_10/Tools
  # ./setup_install_server /export/install
  Verifying target directory...
  Calculating the required disk space for the Solaris_10 product
  \|/-\|/-
  Calculating space required for the installation boot image
  \|/-\|/-
  Copying the CD image to disk...
  \|/-\|/-
  Copying Install Boot Image hierarchy...
  \|/-\|/-
  Copying /boot x86 netboot hierarchy...
  \|/-\|/-
  Install Server setup complete
  #

c. 驗證 install 目錄是否已寫入資料。

  # du -sk /export/install

  3083278 /export/install

d. 從 DVD 播放器取出 DVD。

  # cd /;eject

建立用戶端配置檔案

用戶端配置檔案用於控制自訂 JumpStart 安裝。

a. 建立將用以存放檔案的配置目錄:

  # mkdir /export/config

b. 建立 sysidcfg 檔案:

第一個要建立的檔案是 sysidcfg 檔案。此檔案必須利用正確的資訊予以適當格式化,否則檔案將會遭到忽略,且自動 JumpStart 安裝將會中斷。此安裝接著會預設為標準 Solaris 互動式安裝。

在作業系統安裝開始之前,JumpStart 用戶端會尋找名為 sysidcfg 的檔案。此檔案的名稱必須是「sysidcfg」,因此這個檔案若要有多個版本,每個 sysidcfg 檔案皆必須位於個別的目錄中。每個用戶端皆可以有自己的 sysidcfg 檔案,也可讓多個用戶端使用相同的 sysidcfg 檔案。sysidcfg 檔案可透過 add_install_client 指令指定給用戶端。以下說明如何建立兩個 sysidcfg 檔案:

  # cd /export/config
  # mkdir sysidcfg1
  # cd sysidcfg1
  # vi sysidcfg

  system_locale=en_US.ISO8859-1
  timezone=US/Pacific
  timeserver=localhost
  terminal=vt100
  name_service=NONE
  security_policy=NONE
  root_password=<encrypted from /etc/shadow>
  network_interface=bge0 {hostname=client1
                          netmask=255.255.255.0
                          protocol_ipv6=no
                          default_route=172.16.64.1}

  :wq

  # cd ../
  # mkdir sysidcfg2
  # cd sysidcfg2
  # vi sysidcfg

  system_locale=en_US.ISO8859-1
  timezone=US/Pacific
  timeserver=localhost
  terminal=vt100
  name_service=NONE
  security_policy=NONE
  root_password=<encrypted from /etc/shadow>
  network_interface=bge0 {hostname=client2
                          netmask=255.255.255.0
                          protocol_ipv6=no
                          default_route=172.16.64.1}

  :wq

c. 建立 rules 檔案:

下一個要建立的檔案是 rules 檔案。這是一個文字檔,其中包含將安裝 Solaris 作業系統之各個用戶端或用戶端群組的規則。rules 檔案的各行會告知 JumpStart 應對每個用戶端或用戶端群組使用哪個 beginprofilefinish 檔案。

rules 檔案只有一個。其中可根據所需的唯一配置數目包含多行。以下說明 rules 檔案的內容,其中包含兩個不同用戶端的資訊:

  # cd /export/config
  # vi rules

  hostname client1 begin1 profile1 finish1
  hostname client2 begin2 profile2 finish2

  :wq

check 程序檔在建立 rules.ok 檔案時,會使用 rules 檔案。若要進行自訂 JumpStart 安裝,必須先成功建立 rules.ok 檔案。

d. 建立 begin 檔案:

begin 檔案是一個使用者定義的 Bourne shell 程序檔,可在開始安裝 Solaris 作業系統前,用於執行用戶端上的作業。一般作業包括建立導出的設定檔以及在升級前備份檔案。

您可以視需要使用多個 begin 檔案。以下說明如何建立兩個 begin 檔案:

  # cd /export/config
  # vi begin1

  #!/bin/sh
  echo "Begin Script for JumpStart client1..."

  :wq

  # vi begin2

  #!/bin/sh
  echo "Begin Script for JumpStart client2..."

  :wq

  # chmod 755 begin*

在用戶端上進行安裝時,begin 檔案的輸出會寫入到 /tmp/begin.log。安裝完成後,記錄檔會出現在 /var/sadm/system/logs/begin.log 中。

「Solaris 10 Installation Guide」包含「Custom JumpStart Environment Variables」一節,其中描述可在 begin 程序檔中使用的變數。

e. 建立 finish 檔案:

finish 檔案是一個使用者定義的 Bourne shell 程序檔,可在 Solaris 作業系統安裝完成後,用於執行用戶端上的作業。此程序檔通常用於增加其他檔案、增加套裝軟體與修補程式、自訂根環境以及安裝其他軟體。

您可以視需要使用多個 finish 檔案。以下說明如何建立兩個 finish 檔案:

  # cd /export/config
  # vi finish1

  #!/bin/sh
  echo "Finish Script for JumpStart client1..."
  echo "Get rid of the nfs prompt during the initial boot"
  touch /a/etc/.NFS4inst_state.domain

  :wq

  # vi finish2

  #!/bin/sh
  echo "Finish Script for JumpStart client2..."
  echo "Get rid of the nfs prompt during the initial boot"
  touch /a/etc/.NFS4inst_state.domain

  :wq

  # chmod 755 finish*

Solaris 安裝程式會在 /a 上掛載用戶端系統的檔案系統。finish 程序檔可用於增加、變更或移除與 /a 相關的檔案。在系統第一次重新開機前,這些檔案系統仍會掛載於 /a

JumpStart 目錄 (即 /export/install) 會掛載於 SI_CONFIG_DIR 變數所指定的目錄。此目錄會預設為 /tmp/install_config。您可透過 finish 程序檔中所執行的指令,從 JumpStart 目錄將檔案複製到用戶端。要增加至已安裝系統上的檔案會放在 JumpStart 目錄中,之後供用戶端存取。

finish 程序檔中的下一行,會將檔案複製到用戶端上新建立的檔案系統階層:

  cp /tmp/install_config/<file_name> /a/<path_name>/

f. 建立 profile 檔案:

profile 檔案是一個文字檔,可定義在用戶端上安裝 Solaris 作業系統的方式。

您可以建立多個 profile 檔案。數個用戶端可使用相同的 profile 檔案,每個用戶端亦可有自己的 profile 檔案。以下說明如何建立兩個 profile 檔案:

  # cd /export/config
  # vi profile1

  # install_type MUST be first
  install_type      initial_install

  # start with the minimal required number of packages
  cluster           SUNWCXall
  cluster           SUNWCapache delete
  cluster           SUNWCpcmc   delete
  cluster           SUNWCpcmcx  delete
  cluster           SUNWCthai   delete
  cluster           SUNWClp     delete
  cluster           SUNWCnis    delete
  cluster           SUNWCppp    delete

  # format the entire disk for Solaris
  fdisk   all   solaris all

  # define how the disk is partitioned
  partitioning      explicit
  filesys           rootdisk.s0 6144  /
  filesys           rootdisk.s1 1024  swap
  filesys           rootdisk.s7 free  /state/partition1

  # install systems as standalone
  system_type standalone

  # specify patches to install
  patch 119281-06 nfs 172.16.64.194:/export/patches

  # specify packages to install
  package SPROcc add nfs 172.16.64.194:/export/packages

  :wq

  # vi profile2

  # install_type MUST be first
  install_type      initial_install

  # start with the minimal required number of packages
  cluster           SUNWCXall
  cluster           SUNWCapache delete
  cluster           SUNWCpcmc   delete
  cluster           SUNWCpcmcx  delete
  cluster           SUNWCthai   delete
  cluster           SUNWClp     delete
  cluster           SUNWCnis    delete
  cluster           SUNWCppp    delete

  # format the entire disk for Solaris
  fdisk   all   solaris all

  # define how the disk is partitioned
  partitioning      explicit
  filesys           rootdisk.s0 6144  /
  filesys           rootdisk.s1 4096  swap
  filesys           rootdisk.s7 free  /state/partition1

  # install systems as standalone
  system_type standalone

  # specify patches to install
  patch 119281-06 nfs 172.16.64.194:/export/patches

  # specify packages to install
  package SPROcc add nfs 172.16.64.194:/export/packages

  :wq

g. 建立 check 程序檔:

check 程序檔可用於驗證 rulesprofile 檔案是否已正確設定。首先將 check 程序檔複製到本機目錄 (即 /export/config),如下所示:

  # cd /export/config
  # cp /export/install/Solaris_10/Misc/jumpstart_sample/check .

h. 執行檢查程序檔:

  # ./check
  Validating rules...
  Validating profile profile1...
  Validating profile profile2...
  The custom JumpStart configuration is ok.

若未發現錯誤,即會建立 rules.ok 檔案。此檔案與 rules 檔案相同,但其註釋與空行會遭到移除。check 程序檔會將下列註釋增加到 rules.ok 檔案的結尾:

  # version=2 checksum=<num>

3. 共用安裝與配置目錄

a. 修改 dfstab 以共用 JumpStart 目錄。

b. 編輯 /etc/dfs/dfstab 檔案:

  # vi /etc/dfs/dfstab

  #       Place share(1M) commands here for automatic execution
  #       on entering init state 3.
  #
  #       Issue the command 'svcadm enable network/nfs/server' to
  #       run the NFS daemon processes and the share commands, after
  #       adding the very first entry to this file.
  #
  #       share [-F fstype] [ -o options] [-d "<text>"] <pathname>
  #       [resource]
  #       for example,
  #       share  -F nfs  -o rw=engineering  -d "home dirs"  /export/home2

  share -F nfs -o ro,anon=0 /export/install
  share -F nfs -o ro,anon=0 /export/config
  share -F nfs -o ro,anon=0 /export/patches
  share -F nfs -o ro,anon=0 /export/packages

  :wq

c. 啟動 NFS 伺服器。

  # /etc/init.d/nfs.server start

d. 共用目錄。

  # shareall
  # share
  -               /export/install   ro,anon=0   ""
  -               /export/config   ro,anon=0   ""
  -               /export/patches   ro,anon=0   ""
  -               /export/packages   ro,anon=0   ""

e. 驗證檔案共用。

  # showmount -e localhost
  export list for localhost:
  /export/install  (everyone)
  /export/config   (everyone)
  /export/patches  (everyone)
  /export/packages (everyone)

4. 建立用戶端 tftpboot 檔案

a. 對每個用戶端執行 add_install_client 程序檔。

b. 移至 add_install_client 程序檔的位置:

  # cd /export/install/Solaris_10/Tools

c. 對網路上每個執行 JumpStart 安裝的用戶端執行 add_install_client 程序檔。確定您對每個用戶端使用正確的引數。-e 引數是用戶端的 MAC 位址,而 -p 引數會顯示此用戶端所使用之 sysidcfg 檔案的目錄名稱。以下說明如何為兩個不同的用戶端執行 add_install_client

  # ./add_install_client \
      -d \
      -e 00:0a:e4:37:16:4d \
      -s 172.16.64.194:/export/install \
      -c 172.16.64.194:/export/config \
      -p 172.16.64.194:/export/config/sysidcfg1 i86pc

  enabling tftp in /etc/inetd.conf
  Converting /etc/inetd.conf
  enabling network/tftp/udp6 service
  copying boot file to /tftpboot/pxegrub.I86PC.Solaris_10-1

  If not already configured, enable PXE boot by creating
  a macro named 01000AE429C1FD with:
    Boot server IP (BootSrvA) : 172.16.64.194
    Boot file      (BootFile) : 01000AE429C1FD

  # ./add_install_client \
      -d \
      -e 00:0a:e4:2a:33:f8 \
      -s 172.16.64.194:/export/install \
      -c 172.16.64.194:/export/config \
      -p 172.16.64.194:/export/config/sysidcfg2 i86pc

  enabling tftp in /etc/inetd.conf
  Converting /etc/inetd.conf
  enabling network/tftp/udp6 service
  copying boot file to /tftpboot/pxegrub.I86PC.Solaris_10-1

  If not already configured, enable PXE boot by creating
  a macro named 01000AE42A33F8 with:
    Boot server IP (BootSrvA) : 172.16.64.194
    Boot file      (BootFile) : 01000AE42A33F8

之後在 dhcpmgr 執行期間建立巨集時,會使用 Boot server IPBoot file 值。

5. 配置及執行 DHCP 伺服器

a. 執行 dhcpmgr

  # /usr/sadm/admin/bin/dhcpmgr
  Java Accessibility Bridge for GNOME loaded.

會出現第一個畫面:
(按一下影像可加以放大)

b. 選取 [配置成 DHCP 伺服器],然後按一下 [確定]。

[DHCP 配置精靈] 隨即出現:

c. 選取 [文字檔],然後按 [下一步]。

d. 驗證儲存路徑,然後按 [下一步]。

e. 選取名稱服務,然後按 [下一步]。

f. 驗證租用資訊,然後按 [下一步]。

g. 驗證 DNS 網域資訊,然後按 [下一步]。

h. 驗證網路資訊,然後按 [下一步]。

i. 選取網路類型與路由選項,然後按 [下一步]。

j. 驗證 NIS 網域資訊,然後按 [下一步]。

k. 驗證 NIS+ 網域資訊,然後按 [下一步]。

l. 檢閱設定,然後按一下 [完成]。

[DHCP 管理員] 隨即出現,並要求您啟動 [位址精靈]:

m. 按一下 [是]。

[位址精靈] 隨即出現:

n. 鍵入 IP 位址的數字,然後按 [下一步]。

o. 驗證伺服器資訊,然後按 [下一步]。

p. 驗證 IP 位址,然後按 [下一步]。

q. 驗證用戶端配置資訊,然後按 [下一步]。

r. 選取租用類型,然後按 [下一步]。

s. 檢閱設定,然後按一下 [完成]。

dhcpmgr 仍在執行的情況下,建立 BootFileBootSrvA 巨集。若要存取 [建立巨集] 表單,請先選取 [DHCP 管理員] 表單上的 [巨集] 標籤。接著,在最上層功能表上選取 [編輯] -> [建立]。

[建立巨集] 表單隨即出現:

在 [名稱] 欄位中鍵入由 add_install_client 程序檔針對第一個用戶端產生的名稱,以建立巨集的 BootFile 部分。此名稱也可用於 [選項值] 欄位中。在鍵入資訊後,按一下 [增加]。

u. 在 [選項值] 欄位中鍵入 JumpStart 伺服器的網路 IP 位址,以建立巨集的 BootSrvA 部分。在鍵入資訊後,按一下 [增加]。接著按一下 [確定],以完成第一個巨集的建立。

v. 重複相同的程序以建立第二個巨集。

x. 按一下 [增加]。

y. 按一下 [增加],再按一下 [確定]。

z. 產生第二個巨集後,在 [DHCP 管理員] 視窗中選取 [檔案] -> [結束],以結束 dhcpmgr 公用程式。

最終清除

當您執行 add_install_client 程序檔時,此程序檔會為每個用戶端建立 menu.lst<filename> 檔案。

由於在建立 /tftpboot/menu.lst<BootFile: Name> 檔案時會產生錯誤,因此您必須在第 4 行上的 kernel/unix 後加入下列文字:

- install dhcp

因此,請將檔案由:

default=0
timeout=30
title Solaris_10 Jumpstart
    kernel /I86PC.Solaris_10-1/multiboot kernel/unix -B \
install_config=172.16.64.194:/export/config, \
sysid_config=172.16.64.194:/export/config/sysidcfg1, \
install_media=172.16.64.194:/export/install, \
install_boot=172.16.64.194:/export/install/boot
    module /I86PC.Solaris_10-1/x86.miniroot

變更為:

default=0
timeout=4
title Solaris_10 Jumpstart
    kernel /I86PC.Solaris_10-1/multiboot kernel/unix - install dhcp -B \
install_config=172.16.64.194:/export/config, \
sysid_config=172.16.64.194:/export/config/sysidcfg1, \
install_media=172.16.64.194:/export/install, \
install_boot=172.16.64.194:/export/install/boot
    module /I86PC.Solaris_10-1/x86.miniroot

執行自動 JumpStart 安裝

    啟動用戶端。

    出現提示後,在用戶端的鍵盤上按下 F12。

    Network Boot Request....
    
    CLIENT MAC ADDR: 00 0A E4 2A 33 F8  GUID: 11223344 556 7788 99AA \
                                              BBCCDDEEFF00
    
    DHCP....\|/-\|/-
    

    若所有項目皆已正確設定,安裝作業即可執行到結束為止。如有問題發生,安裝程式即會結束,並進入 shell 中。錯誤的成因會記錄在 install_log 檔案中。


安裝後

以下是 JumpStart 安裝的記錄檔:

  /var/sadm/system/logs/install_log
                        begin_log
                        finish_log
                        sysidtool.log

關於作者

Craig Winter 與 Dale Layfield 是 Sun Microsystems, Inc. 之 Market Development Engineering 中 MDE Verticals Group 的工程師。


Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License.


BigAdmin