Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux 伺服器

刀片伺服器硬碟自安裝(一):分區、格式化與 grub 佈署

本文示範如何為 IBM BladeCenter HS20 刀片伺服器打造一顆「開機即自動裝好 SUSE Linux Enterprise Server 10」的硬碟,流程共九步,其他刀片伺服器同樣適用。系統首次從這顆硬碟開機時會自動開始安裝,大幅降低預加載負擔與人工介入。

前置準備

· 系統 A:預加載 SLES10,grub 為開機載入器,具兩個 SCSI 介面但只用第一個。
· 系統 B:僅有一顆硬碟的空系統,無作業系統。

目標是用系統 A 為系統 B 準備自安裝硬碟,並把硬碟切成兩區:小的安裝分區放 SUSE 安裝介質,大的作業系統分區留給安裝程式使用。

第一步:接線

關閉兩台系統電源,將系統 B 的硬碟(磁碟 B)移到系統 A 的第二個 SCSI 介面,再從系統 A 的磁碟 A(第一個 SCSI 磁碟)開機。

第二步:分區

以 fdisk 操作磁碟 B。SCSI 磁碟通常為 /dev/sdb,其他類型(如 IDE)名稱需調整,可先用 fdisk -l 確認。

a. fdisk /dev/sdb
b. 輸入 d 刪除既有分區(空碟可略)
c. 輸入 n 新增主分區 1,範圍 1 至 900 柱面(約 6.3GB,安裝介質約需 4.3GB):

Command (m for help): n
  p
Partition number (1-4): 1
First cylinder (1-8924, default 1):
Last cylinder (1-8924, default 8924): 900

d. 再輸入 n 新增分區 2,從 901 到磁碟末端,作為作業系統分區:

Command (m for help): n
  p
Partition number (1-4): 2
First cylinder (901-8924, default 901):
Last cylinder (901-8924, default 8924):

此時不要在這一區寫入任何資料,安裝程序會自行格式化。

e. 輸入 a 將分區 1 設為可開機:
Command (m for help): a
Partition number (1-4): 1

f. 輸入 w 寫入分區表並離開:

Command (m for help): w
The partition table has been altered;
Calling ioctl() to re-read partition table.
Syncing disks.

變更至此才真正寫入磁碟,磁碟 B 分區完成。

第三步:格式化

把第一個分區格式化成 ext3:

blade8:~ # mkfs.ext3 /dev/sdb1
mke2fs 1.38 (30-Jun-2005)
OS type: Linux
Block size=4096 (log=2)
904960 inodes, 1807304 blocks
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

第四步:安裝 grub

a. 掛載分區一:mount /dev/sdb1 /mnt/sdb
b. 把 /boot/grub 下的 grub 程式與設定檔複製到 /mnt/sdb/boot/
c. 安裝 grub 到分區一:

blade8:~ # grub-install --root-directory=/mnt/sdb /dev/sdb1 --recheck
Probing devices to guess BIOS drives. This may take a long time.
Installation finished. No error reported.
This is the contents of the device map /mnt/sdb/boot/grub/device.map.
Check if this is correct or not. If any of the line is incorrect,
Fix it and re-run the script 'grub-install'.
(fd0)  /dev/fd0
(hd0)  /dev/sda
(hd1)  /dev/sdb

到這裡,磁碟 B 的安裝分區已成為一片可開機且帶 grub 的磁碟。接下來要讓 grub 在開機時啟動 SUSE 安裝程式。

第五步:準備安裝核心

建立 /mnt/sdb/boot 目錄,並從 SUSE 安裝 ISO 的 /boot/i386/loader/ 複製 linux 與 initrd 進去。

(未完待續……)

Copyright © Linux教程網 All Rights Reserved