gPXE+TFTP+DHCP+iSCSI做無盤服務器

1.環境準備
1.1 安裝CentOS5
除一般系統組件以外,必須安裝:
TFTP,
DHCPD,
開發工具包
可選安裝:
httpd
1.3環境假設
服務器的IP地址爲192.168.1.1
2.安裝軟件
用root帳號登錄系統運行以下命令:
cp gpxe-0.9.7.tar.gz /usr/local/src
cp syslinux-3.81.tar.gz /usr/local/src
cp iscsitarget-1.4.18.tar.gz /usr/local/src
cd /usr/local/src
tar -zxvf  gpxe-0.9.7.tar.gz
tar -zxvf  syslinux-3.81.tar.gz
tar -zxvf  iscsitarget-1.4.18.tar.gz
cd /usr/local/src/gpxe-0.9.7/src
make bin/undionly.kpxe
cd /usr/local/src/syslinux-3.81/com32/menu/
ls menu.c32
cd /usr/local/src/iscsitarget-1.4.18/
make
make install
3.配置
3.1 IET配置
vi /etc/ietd.conf
#添加如下信息
Target iqn.2007-08.name.dns.target.my:iscsiboot

    Lun 0 Path=/path/to/image/file.img,Type=fileio
 
service iscsi-target start
3.2 DHCPD配置
vi /etc/dhcpd.conf
#修改成以下內容
allow booting;

allow bootp;

ddns-update-style none;

log-facility local7;

default-lease-time -1;

max-lease-time 7200;

authoritative;

option space gpxe;

option gpxe-encap-opts code 175 = encapsulate gpxe;

option gpxe.bus-id code 177 = string;

subnet 192.168.1.0 netmask 255.255.255.0 {

    use-host-decl-names on;

    range 192.168.1.26 192.168.1.30;

    option routers 192.168.1.1;

    option broadcast-address 192.168.1.255;

    option root-path "192.168.1.1:/home/tftpboot/";

    next-server 192.168.1.1;

    if not exists gpxe.bus-id {

        filename "gpxe/undionly.kpxe";

    } else {

        # filename "http://192.168.1.1/boot/boot.php";

        filename "gpxe/menu.gpxe";

    }

    server-name "lapdance";

    server-identifier 192.168.1.1; }
 
3.3 TFTP配置
cd /etc/inetd.d
vi tftp
#修改爲以下配置
no code
 
service inetd restart
mkdir /tftpboot/gpxe
cd /tftpboot/gpxe
cp /usr/local/src/gpxe-0.9.7/src/bin/undionly.kpxe /tftpboot/gpxe/
cp /usr/loca/src/syslinux-3.81/com32/menu/menu.c32 /tftp/boot/gpxe/
touch menu.gpxe
vi menu.gpxe
#插入以下內容
#!gpxe chain

#menu.c32 menu.cfg
sanboot iscsi:192.168.1.1::::iqn.2007-08.name.dns.target.my:iscsiboot
 

4.客戶端
1.找一臺機子掛上硬盤安裝windowsXP,主分區建議小於4個G
2.安裝XP系統後安裝Microsoft iSCSI Software Initiator
下載地址:http://download.microsoft.com/download/C/0/3/C0326CE2-51D0-4E1C-A9E0-7E16BE79410B/CHK-Boot/Initiator-2.08-boot-build3825-x86chk.exe
3.安裝sanboot補丁
下載地址:
4.將裝XP的磁盤從客戶機上拆下來掛到服務器上,製作img磁盤文件
#查看磁盤信息
fdisk -l /dev/sdX
#顯示如下
Disk /dev/sdX: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes

Device        Boot Start End     Blocks    Id    System

/dev/sdX1     *    1     1825    14659281  7     HPFS/NT
 
5.生成文件命令(注意bs與count的值與上面信息的對應關係)
dd if=/dev/sdX of=/path/to/image/file.img bs=8225280 count=1825
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章