iscsitarget+ipxe无盘启动详解

本文提供了一套详细的步骤指南,用于在服务器上配置DHCP和iscsi目标,以及在客户机上制作并使用启动u盘进行网络存储访问。包括静态IP设置、iscsi目标初始化、配置IED脚本、服务器与客户机交互流程,以及u盘制作与使用说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


服务器:

1. 启动dhcp
  1.1 设置静态ip
# ifconfig eth0 192.168.0.1 netmask 255.255.255.0
      也可以使用网上的配置 interface 脚本的方法配置静态ip.

  1.2 启用dhcp
# dhcpd

      此时可能会遇到 /var/run/dhcpd.pid 文件报错,
      只需要创建该文件,并把权限设置为 777 即可。

2. 启用iscsitarget
  2.1 如果没安装iscsitarget,则手动安装:
 # apt-get install iscsitarget

      在 /etc/init.d/ 下会生成对应 iscsitarget 脚本文件。

      也可以使用源码安装,方法网上有,可以自己看,同时制作好ipxe启动u盘,注意事项在下面有说明。

      

  2.2 配置 /etc/iet/ietd.conf 脚本

# Example iscsi target configuration
#
# Everything until the first target definition belongs
# to the global configuration.
#
# "iSNSServer" is the iSNS server you want your portal to register
# with.
#
# "iSNSAccessControl" is for enabling initiator access control
# through the iSNS server.
#
# "IncomingUser" specifies credentials the initiator has to provide -
# several of these are supported. If mutual CHAP shall be employed,
# "OutgoingUser" specifies the user/pass combination the target will
# provide - only one is supported.
#
# Leave them alone (keep them commented out) if you don't want to use
# authentication for discovery sessions.

iSNSServer 192.168.0.1
iSNSAccessControl No

#IncomingUser joe secret
#OutgoingUser jack 12charsecret

# Targets definitions start with "Target" and the target name.
# The target name must be a globally unique name, the iSCSI
# standard defines the "iSCSI Qualified Name" as follows:
#
# iqn.yyyy-mm.<reversed domain name>[:identifier]
#
# "yyyy-mm" is the date at which the domain is valid and the identifier
# is freely selectable. For further details please check the iSCSI spec.

#Target iqn.2001-04.com.example:storage.disk2.sys1.xyz
#Target iqn.2001-04.com.example:storage.Lun0
	# CHAP Users
	#
	# The same rules as for discovery users apply here.
	#
	# Don't set them if you don't want to use CHAP authentication.
	#
	#IncomingUser joe secret
	#OutgoingUser jim 12charpasswd
	#
	# Logical Unit definition
	#
	# Block devices, regular files (fileio only), LVM, and RAID
	# can be offered to the initiators as a block device.
	#
	# Lun numbers MUST start with zero (each target needs a Lun 0)
	#
	#Lun 0 Path=/dev/sdb,Type=fileio,ScsiId=xyz,ScsiSN=xyz
	#
	# Alias name for this target (Not Used)
	#
	#Alias Test
	#
	# Various iSCSI parameters
	# (not all are used right now, see also iSCSI spec for details)
	#
	# Outgoing SCSI data (initiator to target user data or command
	# parameters) is sent as either solicited data or unsolicited data.
	# Solicited data is sent in response to R2T PDUs.  Unsolicited data
	# can be sent as part of an iSCSI command PDU sequence
	# ("Immediate Data") or as a separate iSCSI data PDU sequence.
	#
	#MaxConnections		1		# Number of connections/session
						# We only support 1
	#MaxSessions		0		# Number of sessions/target
						# 0 = no explicit limit
	#InitialR2T		Yes		# Wait first for R2T
						# Yes = no unsolicited data
	#ImmediateData		Yes		# Data can accompany command
						# Yes = cmnd/data in same PDU
	#MaxRecvDataSegmentLength 8192		# Max data per PDU to receive
	#MaxXmitDataSegmentLength 8192		# Max data per PDU to transmit
	#MaxBurstLength		262144		# Max data per sequence (R2T)
	#FirstBurstLength	65536		# Max unsolicited data sequence
	#DefaultTime2Wait	2		# Secs to wait for ini to logout
						# also secs for ini to wait
						# before logging back in
						# Not implemented, but settable
	#DefaultTime2Retain	0		# Secs keep session after logout
						# We only support 0
	#MaxOutstandingR2T	1		# Max outstanding R2Ts per cmnd
	#DataPDUInOrder		Yes		# Data in PDUs is ordered
						# We only support ordered
	#DataSequenceInOrder	Yes		# PDUs in sequence are ordered
						# We only support ordered
	#ErrorRecoveryLevel	0		# We only support level 0
	#HeaderDigest		None,CRC32C	# PDU header checksum algo list
						# None or CRC32C
						# If only one is set then the
						# initiator must agree to it
						# or the connection will fail
	#DataDigest		None,CRC32C	# PDU data checksum algo list
						# Same as above
	#MaxSessions		0		# Maximum number of sessions to
						# this target - 0 = unlimited
	#NOPInterval		0		# Send a NOP-In ping each after
						# that many seconds if the conn
						# is otherwise idle - 0 = off
	#NOPTimeout		0 		# Wait that many seconds for a
						# response on a NOP-In ping
						# If 0 or > NOPInterval, NOPInterval
						# is used!
	#
	# Various target parameters
	#
	#Wthreads		8		# Number of IO threads
	#QueuedCommands		32		# Number of queued commands
Target iqn.2012-12.local.mynet:storage.lun1
Lun 1 Path=/var/lun1.bin,Type=fileio,ScsiId=lun1,ScsiSN=lun1
    该脚本只有中间的IP地址和最后两行有用 ,最后的路径 /var/lun1.bin 由自己创建,一般30G,能够放一个操作系统即可。

      
  2.3 启用iscsitarget
# service iscsitarget start
 
  注意:
  a. 如果用源码安装,在 /etc/init.d/ 下会生成对应 iscsi-target 脚本文件,
     该文件和源码安装生成的 iscsitarget 脚本有区别,
     会导致 service iscsitarget start 命令不可用。
     
  b. 每次配置完 ietd.conf 脚本,都要重启服务   
# service iscsitarget restart




客户机:

1. 制作启动u盘

     1.1 ipxe源码下载

$sudo apt-get install git
$sudo apt-get install git-core
$git clone git://git.ipxe.org/ipxe.git
     1.2 进入src文件夹,make 编译,根据官网说明制作启动u盘

           编译ipxe源码可能报错 fatal error: lzma.h,解决办法:

apt-get install liblzma-dev

2. 进入终端

   ctrl+B 进入终端

iPXE >

3. dhcp

iPXE > dhcp

4. sanhook
 
iPXE > sanhook iscsi:192.168.0.1:::1:iqn.2012-12.local.mynet:storage.lun1

   注意:这里 :::1 和 lun1 两处的 1 需要和 ietd.conf 脚本里的对应。
   
   如果是 sanboot,则命令如下:
iPXE > sanboot iscsi:192.168.0.1:::1:iqn.2012-12.local.mynet:storage.lun1

5. eixt  

iPXE > exit

   执行完该命令,应该就会进入下一步引导,这里需要提前在bios里设置好引导顺序,

   比如要从光盘安装系统,那么应该设置为先启动u盘,然后是光盘,这样通过u盘加载ipxe 后可以直接引导光盘来安装系统。

     

   另外,还需注意,服务器的静态ip地址有时会变,所以客户机的ip要随之改变才能登陆成功。



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值