Skip to content

Instantly share code, notes, and snippets.

@windschord
Created December 31, 2023 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save windschord/ca51000a264a4ee059f94346c63e950c to your computer and use it in GitHub Desktop.
Save windschord/ca51000a264a4ee059f94346c63e950c to your computer and use it in GitHub Desktop.
Setup iSCSI target on proxmox ve with zfs

前提

実行環境

root@ve:~# pveversion
pve-manager/8.1.3/b46aac3b42da5d15 (running kernel: 6.5.11-4-pve)

root@ve:~# zfs version
zfs-2.2.2-pve1
zfs-kmod-2.2.0-pve3

root@ve:~#  zfs list

実行ユーザー

root

1. iSCSI ターゲット管理ツールのインストール

root@ve:~#  apt -y install targetcli-fb

2. zfs pool ブロックストレージを作成

root@ve:~# zfs create -V 100gb -o compression=lz4 data-pool/iscsi-blk-1

※ 100GBで lz4 圧縮を有効化してzfs poolの data-pool に zvol名 iscsi-blk-1 で作成

3. iSCSI targetの設定

root@ve:~# targetcli
# -- zvolをブロックデバイスとして登録 --
/> cd /backstores/block
/backstores/block> create block1 /dev/zvol/internal-ssd-zfs/iscsi-blk-1

# -- ターゲットを作成
# -- 命名規則:[ iqn.年-月.ドメイン名の逆:任意の名前 ]
/backstores/block> cd /iscsi/
/iscsi> create iqn.2024-01.example.com:storage01

# -- LUNを設定
/iscsi> cd /iscsi/iqn.2024-01.example.com:storage01/tpg1/luns
/iscsi/iqn.20...e01/tpg1/luns> create /backstores/block/block1

# -- ACLの設定
/iscsi/iqn.20...e01/tpg1/luns> cd ../acls
/iscsi/iqn.20...e01/tpg1/acls> create iqn.0000-00.your.initiator.name.local:initiator 

# -- (Option) 認証の有効化
/iscsi/iqn.20...e01/tpg1/acls> cd ..
/iscsi/iqn.20...e01/tpg1> set attribute authentication=1

# -- (Option) 認証ユーザの登録
/iscsi/iqn.20...e01/tpg1> cd acls/iqn.0000-00.your.initiator.name.local:initiator
/iscsi/iqn.20...l:initiator> set auth userid=username 
/iscsi/iqn.20...l:initiator> set auth password=password 

# -- 設定完了
> exit

4. iSCSIイニシエーターの設定

参考資料

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment