用户工具

站点工具


freebsd:os:iscsi_over_zfs

iSCSI Over ZFS Cheat Code

FreeBSD 官方文档: https://www.freebsd.org/doc/handbook/network-iscsi.html

以下例子为本机同时做 Target 和 Initiator

ZFS

# zfs create -o compress=lz4 -o volblocksize=64k -s -V 10G tank/iscsi

/etc/ctl.conf

auth-group ag0 {
	chap user 1234567890123456
}

portal-group pg0 {
	discovery-auth-group no-authentication
	listen 0.0.0.0
	listen [::]
}

target iqn.2016-10.org.hshh:target0 {
	auth-group ag0
	portal-group pg0
	lun 0 {
		path /dev/zvol/tank/iscsi
	}
}

/etc/iscsi.conf

t0 {
	TargetAddress	= 127.0.0.1
	TargetName	= iqn.2016-10.org.hshh:target0
	AuthMethod	= CHAP
	chapIName	= user
	chapSecret	= 1234567890123456
}

/etc/rc.conf

ctld_enable="YES"
iscsid_enable="YES"
iscsictl_enable="YES"
iscsictl_flags="-Aa"

iSCSI Target (Server)

# service ctld start

iSCSI Initiator (Client)

# service iscsid start
# service iscsictl start

Disk

# camcontrol devlist
# gpart create -s gpt da6
# gpart add -t freebsd-ufs da6
# newfs -j da6p1
# mount /dev/da6p1 /mnt

Remove

# umount /mnt
# iscsictl -L
# iscsictl -Ra
# service iscsid stop
# service ctld stop
# kldstat

Resize

# umount /mnt
# iscsictl -Ra
# service iscsid stop
# service ctld stop
# zfs set volsize=20G tank/iscsi
# service ctld start
# service iscsid start
# iscsictl -Aa
# gpart show da6
# gpart recover da6
# gpart resize -i 1 da6
# growfs /dev/da6p1
# fsck -y /dev/da6p1
freebsd/os/iscsi_over_zfs.txt · 最后更改: 2016/10/06 16:58 由 Hshh