<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>iSCSI | 徒然なるままに</title>
	<atom:link href="https://www.seichan.org/tag/iscsi/feed" rel="self" type="application/rss+xml" />
	<link>https://www.seichan.org</link>
	<description>徒然と日々の出来事(ネタ)を書いていこうかと．主に FreeBSD，Unix系の話題が中心ですが，その他の話題もあつかってみたり．</description>
	<lastBuildDate>Sun, 24 Mar 2024 00:40:29 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.2</generator>
	<item>
		<title>GEOM MULTIPATH でマルチパスを構成する (2)</title>
		<link>https://www.seichan.org/2023/12/geom-multipath-%e3%81%a7%e3%83%9e%e3%83%ab%e3%83%81%e3%83%91%e3%82%b9%e3%82%92%e6%a7%8b%e6%88%90%e3%81%99%e3%82%8b-2.html</link>
					<comments>https://www.seichan.org/2023/12/geom-multipath-%e3%81%a7%e3%83%9e%e3%83%ab%e3%83%81%e3%83%91%e3%82%b9%e3%82%92%e6%a7%8b%e6%88%90%e3%81%99%e3%82%8b-2.html#respond</comments>
		
		<dc:creator><![CDATA[seichan]]></dc:creator>
		<pubDate>Fri, 15 Dec 2023 13:00:00 +0000</pubDate>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[GEOM]]></category>
		<category><![CDATA[iSCSI]]></category>
		<guid isPermaLink="false">https://www.seichan.org/blog/?p=1048</guid>

					<description><![CDATA[GEOM MULTIPATH は，ストレージ IO を複数のインターフェイスで冗長させることができるものです． 前回は「GEOM MULTIPATH でマルチパスを構成する (1)」で iSCSI ターゲットおよびイニシ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">GEOM MULTIPATH は，ストレージ IO を複数のインターフェイスで冗長させることができるものです．</p>



<p class="wp-block-paragraph">前回は「GEOM MULTIPATH でマルチパスを構成する (1)」で iSCSI ターゲットおよびイニシエーターのマルチパスに向けた設定追加を解説しました．</p>



<p class="wp-block-paragraph">今回は GEOM MULTIPATH について纏めます．</p>



<ul class="wp-block-list">
<li>GEOM に関するお話
<ul class="wp-block-list">
<li><a href="https://www.seichan.org/2023/11/freebsd-geom-%e5%86%8d%e3%80%85%e5%ad%a6%e7%bf%92.html" target="_blank">FreeBSD GEOM 再々学習</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-concat-%e3%83%87%e3%82%a3%e3%82%b9%e3%82%af%e3%81%ae%e9%80%a3%e7%b5%90-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM CONCAT (ディスクの連結) を使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-stripe-%e3%82%b9%e3%83%88%e3%83%a9%e3%82%a4%e3%83%97-raid0-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM STRIPE (ストライプ/RAID0) を使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-mirror-%e3%83%9f%e3%83%a9%e3%83%bc%e3%83%aa%e3%83%b3%e3%82%b0-raid1-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b-1.html" target="_blank">GEOM MIRROR (ミラーリング/RAID1) を使ってみる (1)</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-mirror-%e3%83%9f%e3%83%a9%e3%83%bc%e3%83%aa%e3%83%b3%e3%82%b0-raid1-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b-2.html" target="_blank">GEOM MIRROR (ミラーリング/RAID1) を使ってみる (2)</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-stripe-mirror-%e3%81%a7-raid10-%e3%82%92%e6%a7%8b%e6%88%90%e3%81%97%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM STRIPE + MIRROR で RAID10 を構成してみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-raid3%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM RAID3を使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-cache-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM CACHE を使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-gvirstor%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM GVIRSTORを使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-gate-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM GATE を使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-label-%e3%81%a7%e5%90%8d%e5%89%8d%e3%81%ab%e3%82%88%e3%82%8b%e7%ae%a1%e7%90%86%e3%82%92%e8%a1%8c%e3%81%86.html" target="_blank">GEOM LABEL で名前による管理を行う</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-part-%e3%81%a7%e3%83%87%e3%82%a3%e3%82%b9%e3%82%af%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%b3%e3%81%ae%e7%ae%a1%e7%90%86%e3%82%92%e8%a1%8c%e3%81%86.html" target="_blank">GEOM PART でディスクパーティションの管理を行う</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-multipath-%e3%81%a7%e3%83%9e%e3%83%ab%e3%83%81%e3%83%91%e3%82%b9%e3%82%92%e6%a7%8b%e6%88%90%e3%81%99%e3%82%8b-1.html" target="_blank">GEOM MULTIPATH でマルチパスを構成する (1)</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-multipath-%e3%81%a7%e3%83%9e%e3%83%ab%e3%83%81%e3%83%91%e3%82%b9%e3%82%92%e6%a7%8b%e6%88%90%e3%81%99%e3%82%8b-2.html" target="_blank">GEOM MULTIPATH でマルチパスを構成する (2)</a></li>
</ul>
</li>
</ul>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-2" checked><label class="toc-title" for="toc-checkbox-2">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">FreeBSD で Multipath を構成する</a><ol><li><a href="#toc2" tabindex="0">マルチパスでディスクを束ねる</a></li><li><a href="#toc3" tabindex="0">マルチパスのモードを変更する</a></li><li><a href="#toc4" tabindex="0">マルチパスの Active / Passive を切り替える</a></li><li><a href="#toc5" tabindex="0">マルチパスを停止する</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">FreeBSD で Multipath を構成する</span></h2>



<p class="wp-block-paragraph">前回，ターゲットおよびイニシエーターの設定を行い以下のとおりでディスクが見えている状態となっています．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># iscsictl -L
Target name                          Target portal    State
iqn.2023-12.iscsi.org.seichan:target0 172.16.255.254   Connected: da4 da5
iqn.2023-12.iscsi.org.seichan:target1 172.16.255.254   Connected: da3
iqn.2023-12.iscsi.org.seichan:target2 172.16.255.254   Connected: da2
iqn.2023-12.iscsi.org.seichan:target0 172.17.255.254   Connected: da7 da9
iqn.2023-12.iscsi.org.seichan:target1 172.17.255.254   Connected: da8
iqn.2023-12.iscsi.org.seichan:target2 172.17.255.254   Connected: da6
</pre>



<p class="wp-block-paragraph">これらディスクはペア (同じデバイスを指している) の組み合わせと GEOM MULTIPATH で束ねた際の名前を表にまとめます．</p>



<figure class="wp-block-table"><table><tbody><tr><td>GEOM MULTIPATH名</td><td>iSCSI1上のデバイス</td><td>iSCSI2上のデバイス</td></tr><tr><td>target0_0</td><td>da4</td><td>da7</td></tr><tr><td>target0_1</td><td>da5</td><td>da9</td></tr><tr><td>target1_0</td><td>da3</td><td>da8</td></tr><tr><td>target2_0</td><td>da2</td><td>da6</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">GEOM  MULTIPATH は gmultipath というコマンドを通じて利用・管理を行います．簡単に触れますが，詳細はコマンドのオプションの詳細は FreeBSD の マニュアル「<a rel="noopener" href="http://www.koganemaru.co.jp/cgi-bin/mroff.cgi?subdir=man&amp;lc=1&amp;cmd=&amp;man=gmultipath&amp;dir=jpman-13.2.2%2Fman&amp;sect=0" target="_blank">gmultipath</a>」を見てください．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># gmultipath
usage: gmultipath create [-vAR] name prov ...
       gmultipath label [-vAR] name prov ...
       gmultipath configure [-vAPR] name
       gmultipath add [-v] name prov
       gmultipath remove [-v] name prov
       gmultipath prefer [-v] prov ...
       gmultipath fail [-v] name prov
       gmultipath restore [-v] name prov
       gmultipath rotate [-v] name
       gmultipath getactive [-v] name
       gmultipath destroy [-v] name
       gmultipath stop [-v] name
       gmultipath clear [-v] prov ...
       gmultipath help
       gmultipath list [-a] [name ...]
       gmultipath status [-ags] [name ...]
       gmultipath load [-v]
       gmultipath unload [-v]</pre>



<h3 class="wp-block-heading"><span id="toc2">マルチパスでディスクを束ねる</span></h3>



<p class="wp-block-paragraph">まずは毎度のことながらカーネルモジュールをロードします．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># kldload geom_multipath

# kldstat
Id Refs Address                Size Name
 1   18 0xffffffff80200000  1f3e2d0 kernel
 2    1 0xffffffff8213f000     9290 geom_gate.ko
 3    1 0xffffffff82319000     3218 intpm.ko
 4    1 0xffffffff8231d000     2180 smbus.ko
 5    1 0xffffffff82320000     7490 vmci.ko
 6    1 0xffffffff82328000     f0ac iscsi.ko
 7    1 0xffffffff82338000     589c geom_multipath.ko</pre>



<p class="wp-block-paragraph">また，再起動後に備えて /boot/loader.conf にも記載します．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># cat /boot/loader.conf
geom_multipath_load="YES"</pre>



<p class="wp-block-paragraph">gmultipath label コマンドでディスクを束ねることが可能です．オプションとして -A と -R が指定可能で，指定しない場合は -P が使用されるとマニュアルにはあります．</p>



<ul class="wp-block-list">
<li>-A<br>Active / Active でアクティブなパスを全て使い IO を処理する。帯域がパスの数分ある状態。</li>



<li>-R<br>Active / Readonly で通常はアクティブなパスを用いて IO 処理を行う。アクティブパスが切れたら RO として読み取りだけ可能な状態。(これを使うケースはないのでは&#8230;)</li>



<li>-P<br>Active / Passive で通常はアクティブなパスを用いて IO 処理を行う。アクティブパスが切れたらもう一方のパスを利用して IO 処理を行う。</li>
</ul>



<p class="wp-block-paragraph">通常は Active / Active か Active / Passive を利用する事になると思います．da4 と da7 を Active / Active で target0_0 として束ねる場合のコマンドは次のとおりとなります。</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># gmultipath label -A target0_0 da4 da7</pre>



<p class="wp-block-paragraph">エラーが出なければ成功しています．gmultipath list コマンドで状態を確認してみます．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># gmultipath list
Geom name: target0_0
Type: AUTOMATIC
Mode: Active/Active
UUID: 42183e3b-996f-11ee-810f-0050568da523
State: OPTIMAL
Providers:
1. Name: multipath/target0_0
   Mediasize: 107374181888 (100G)
   Sectorsize: 512
   Mode: r0w0e0
   State: OPTIMAL
Consumers:
1. Name: da4
   Mediasize: 107374182400 (100G)
   Sectorsize: 512
   Mode: r1w1e1
   State: ACTIVE
2. Name: da7
   Mediasize: 107374182400 (100G)
   Sectorsize: 512
   Mode: r1w1e1
   State: ACTIVE</pre>



<p class="wp-block-paragraph">プロバイダーが target0_0，コンシューマーが da4 と da7 であるということ，モードが Active/Active であることが確認できました．</p>



<p class="wp-block-paragraph">このデバイスをフォーマットしてマウント，利用をしてみます．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># newfs /dev/multipath/target0_0
/dev/multipath/target0_0: 102400.0MB (209715192 sectors) block size 32768, fragment size 4096
        using 164 cylinder groups of 625.22MB, 20007 blks, 80128 inodes.
super-block backups (for fsck_ffs -b #) at:
 192, 1280640, 2561088, 3841536, 5121984, 6402432, 7682880, 8963328, 10243776, 11524224, 12804672, 14085120, 15365568,
 16646016, 17926464, 19206912, 20487360, 21767808, 23048256, 24328704, 25609152, 26889600, 28170048, 29450496, 30730944,
 32011392, 33291840, 34572288, 35852736, 37133184, 38413632, 39694080, 40974528, 42254976, 43535424, 44815872, 46096320,

# mount /dev/multipath/target0_0 /mnt</pre>



<p class="wp-block-paragraph">読み書きは普通にできるとして，マルチパスで Active / Active として iSCSI トラフィックが分散されているのかを確認してみたいと思います．<br>dd を用いて img_X.img ファイルを生成するスクリプトを実行したうえで前後の netstat の結果を見てみました．<br>vmx1 および vmx2 のカウンターが上がっているため，両方のインターフェイスが利用されている状態が確認できます．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># netstat -i -b -n
Name    Mtu Network       Address              Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll
vmx1   1500 &lt;Link#2>      00:50:56:8d:e4:3c   188843     0     0   20397284   184083     0   29538342     0
vmx1      - 172.16.255.0/ 172.16.255.1        188298     -     -   17728412   191281     -   26959584     -
vmx2   1500 &lt;Link#3>      00:50:56:8d:e6:8c   185433     0     0   18967600   182735     0   24141602     0
vmx2      - 172.17.255.0/ 172.17.255.1        184892     -     -   16346652   186394     -   21581828     -


# ls /mnt
.snap           img_11.img      img_15.img      img_19.img      img_22.img      img_6.img
img_0.img       img_12.img      img_16.img      img_2.img       img_3.img       img_7.img
img_1.img       img_13.img      img_17.img      img_20.img      img_4.img       img_8.img
img_10.img      img_14.img      img_18.img      img_21.img      img_5.img       img_9.img


# netstat -i -b -n
Name    Mtu Network       Address              Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll
vmx1   1500 &lt;Link#2>      00:50:56:8d:e4:3c   227611     0     0   22982526   187352     0  139989136     0
vmx1      - 172.16.255.0/ 172.16.255.1        227065     -     -   19770856   267128     -  137364612     -
vmx2   1500 &lt;Link#3>      00:50:56:8d:e6:8c   223336     0     0   21524808   186269     0  132049886     0
vmx2      - 172.17.255.0/ 172.17.255.1        222794     -     -   18373172   260514     -  129440636     -</pre>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>



<h3 class="wp-block-heading"><span id="toc3">マルチパスのモードを変更する</span></h3>



<p class="wp-block-paragraph">先ほどは Active / Active でマルチパスを構成していましたが，これを Active / Passive に変更してみます．</p>



<p class="wp-block-paragraph">gmultipath configure コマンドでモードの変更が可能です．指定できるオプションは label と変わりません．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># gmultipath configure -P target0_0

# gmultipath list
Geom name: target0_0
Type: AUTOMATIC
Mode: Active/Passive
UUID: 42183e3b-996f-11ee-810f-0050568da523
State: OPTIMAL
Providers:
1. Name: multipath/target0_0
   Mediasize: 107374181888 (100G)
   Sectorsize: 512
   Mode: r1w1e1
   State: OPTIMAL
Consumers:
1. Name: da4
   Mediasize: 107374182400 (100G)
   Sectorsize: 512
   Mode: r2w2e2
   State: ACTIVE
2. Name: da7
   Mediasize: 107374182400 (100G)
   Sectorsize: 512
   Mode: r2w2e2
   State: PASSIVE</pre>



<p class="wp-block-paragraph">この状態で改めて dd のスクリプトを実行した前後の netstat の結果を確認します．<br>vmx1 のカウンターが上がっているため，vmx1 (Active 側) インターフェイスが利用されている状態が確認できます．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># netstat -i -b -n
Name    Mtu Network       Address              Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll
vmx1   1500 &lt;Link#2>      00:50:56:8d:e4:3c   233417     0     0   23392392   189912     0  154641112     0
vmx1      - 172.16.255.0/ 172.16.255.1        232868     -     -   20099300   277873     -  151980720     -
vmx2   1500 &lt;Link#3>      00:50:56:8d:e6:8c   224383     0     0   21619428   187169     0  132892558     0
vmx2      - 172.17.255.0/ 172.17.255.1        223838     -     -   18452996   261812     -  130270680     -

# ls /mnt
.snap           img_12.img      img_17.img      img_21.img      img_26.img      img_30.img      img_6.img
img_0.img       img_13.img      img_18.img      img_22.img      img_27.img      img_31.img      img_7.img
img_1.img       img_14.img      img_19.img      img_23.img      img_28.img      img_32.img      img_8.img
img_10.img      img_15.img      img_2.img       img_24.img      img_29.img      img_4.img       img_9.img
img_11.img      img_16.img      img_20.img      img_25.img      img_3.img       img_5.img

# netstat -i -b -n
Name    Mtu Network       Address              Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll
vmx1   1500 &lt;Link#2>      00:50:56:8d:e4:3c   343298     0     0   30681114   197348     0  469842448     0
vmx1      - 172.16.255.0/ 172.16.255.1        342749     -     -   25849688   493649     -  467077952     -
vmx2   1500 &lt;Link#3>      00:50:56:8d:e6:8c   224464     0     0   21627366   187250     0  132900496     0
vmx2      - 172.17.255.0/ 172.17.255.1        223919     -     -   18459800   261893     -  130277484     -</pre>



<h3 class="wp-block-heading"><span id="toc4">マルチパスの Active / Passive を切り替える</span></h3>



<p class="wp-block-paragraph">マルチパスで Active / Passive 構成をとろうとした際，複数のデバイス毎にアクティブインターフェイスを変えたい．という場合があると思います．<br>そんな場合に label でデバイスの指定順番で制御する事ができますが，後ほどでもアクティブパスを変更することが可能です．</p>



<p class="wp-block-paragraph">パスの変更には gmultipath prefer コマンドを利用します．gmultipath getactive コマンドと共に設定および前後の確認を行ってみます．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># gmultipath getactive target0_0
da4

# gmultipath prefer target0_0 da7

# gmultipath getactive target0_0
da7</pre>



<p class="wp-block-paragraph">rotate コマンド実行前は da4 がアクティブパスでした．rotate 後は da7 がアクティブパスに変更されていますので，パスが切り替わった事が確認できます．</p>



<p class="wp-block-paragraph">では先ほどと同様に，dd コマンドを用いたトラフィックの状況を確認してみます．<br>vmx2 のカウンターが上がっているため，実際の動作としても vmx2 がアクティブに変更されている状態が確認できます．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># netstat -i -b -n
Name    Mtu Network       Address              Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll
vmx1   1500 &lt;Link#2>      00:50:56:8d:e4:3c   352195     0     0   31310250   200892     0  492213664     0
vmx1      - 172.16.255.0/ 172.16.255.1        351643     -     -   26354128   510042     -  489399552     -
vmx2   1500 &lt;Link#3>      00:50:56:8d:e6:8c   225633     0     0   21741846   188412     0  133014532     0
vmx2      - 172.17.255.0/ 172.17.255.1        225085     -     -   18557776   263055     -  130375252     -

# ls /mnt
.snap           img_13.img      img_19.img      img_24.img      img_3.img       img_4.img
img_0.img       img_14.img      img_2.img       img_25.img      img_30.img      img_5.img
img_1.img       img_15.img      img_20.img      img_26.img      img_31.img      img_6.img
img_10.img      img_16.img      img_21.img      img_27.img      img_32.img      img_7.img
img_11.img      img_17.img      img_22.img      img_28.img      img_33.img      img_8.img
img_12.img      img_18.img      img_23.img      img_29.img      img_34.img      img_9.img

# netstat -i -b -n
Name    Mtu Network       Address              Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll
vmx1   1500 &lt;Link#2>      00:50:56:8d:e4:3c   352262     0     0   31316970   200964     0  492220720     0
vmx1      - 172.16.255.0/ 172.16.255.1        351709     -     -   26359864   510114     -  489405600     -
vmx2   1500 &lt;Link#3>      00:50:56:8d:e6:8c   343203     0     0   29539716   196342     0  470304936     0
vmx2      - 172.17.255.0/ 172.17.255.1        342654     -     -   24709620   493956     -  467554636     -
</pre>



<p class="wp-block-paragraph">prefer は明示的にアクティブにするパス(デバイス) を指定しましたが，二つのパスの場合は gmultipath rotate でも十分に利用可能です．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># gmultipath rotate target0_0

# gmultipath getactive target0_0
da4</pre>



<h3 class="wp-block-heading"><span id="toc5">マルチパスを停止する</span></h3>



<p class="wp-block-paragraph">マルチパスを停止したい場合 gmultipath destroy コマンドを利用してマルチパスの解除，メタデータの削除ができます．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># gmultipath destroy target0_0

# gmultipath status
               Name   Status  Components
multipath/target1_0  OPTIMAL  da2 (ACTIVE)
                              da7 (ACTIVE)
multipath/target2_0  OPTIMAL  da3 (ACTIVE)
                              da5 (ACTIVE)
multipath/target0_1  OPTIMAL  da6 (ACTIVE)
                              da9 (ACTIVE)</pre>



<p class="wp-block-paragraph">他にも，一時的なパスの停止なども gmultipath コマンドで実施可能ですが，フェイルオーバーしてくれますし明示的にやるケースは少ないと思いますので紹介からは省いています．</p>



<p class="wp-block-paragraph">以上 GEOM MULTIPATH の解説でした．</p>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.seichan.org/2023/12/geom-multipath-%e3%81%a7%e3%83%9e%e3%83%ab%e3%83%81%e3%83%91%e3%82%b9%e3%82%92%e6%a7%8b%e6%88%90%e3%81%99%e3%82%8b-2.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>GEOM MULTIPATH でマルチパスを構成する (1)</title>
		<link>https://www.seichan.org/2023/12/geom-multipath-%e3%81%a7%e3%83%9e%e3%83%ab%e3%83%81%e3%83%91%e3%82%b9%e3%82%92%e6%a7%8b%e6%88%90%e3%81%99%e3%82%8b-1.html</link>
					<comments>https://www.seichan.org/2023/12/geom-multipath-%e3%81%a7%e3%83%9e%e3%83%ab%e3%83%81%e3%83%91%e3%82%b9%e3%82%92%e6%a7%8b%e6%88%90%e3%81%99%e3%82%8b-1.html#respond</comments>
		
		<dc:creator><![CDATA[seichan]]></dc:creator>
		<pubDate>Thu, 14 Dec 2023 13:00:00 +0000</pubDate>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[GEOM]]></category>
		<category><![CDATA[iSCSI]]></category>
		<guid isPermaLink="false">https://www.seichan.org/blog/?p=1044</guid>

					<description><![CDATA[GEOM MULTIPATH は，ストレージ IO を複数のインターフェイスで冗長させることができるものです． iSCSI 環境を用いて，GEOM MULTIPATH によるマルチパスアクセスを構成してみます．長くなるの [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">GEOM MULTIPATH は，ストレージ IO を複数のインターフェイスで冗長させることができるものです．</p>



<p class="wp-block-paragraph">iSCSI 環境を用いて，GEOM MULTIPATH によるマルチパスアクセスを構成してみます．<br>長くなるので，今回は iSCSI ターゲット / イニシエーター のマルチパスに向けた設定を解説し，GEOM MULTIPATH については次回に纏めます．</p>



<ul class="wp-block-list">
<li>GEOM に関するお話
<ul class="wp-block-list">
<li><a href="https://www.seichan.org/2023/11/freebsd-geom-%e5%86%8d%e3%80%85%e5%ad%a6%e7%bf%92.html" target="_blank">FreeBSD GEOM 再々学習</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-concat-%e3%83%87%e3%82%a3%e3%82%b9%e3%82%af%e3%81%ae%e9%80%a3%e7%b5%90-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM CONCAT (ディスクの連結) を使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-stripe-%e3%82%b9%e3%83%88%e3%83%a9%e3%82%a4%e3%83%97-raid0-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM STRIPE (ストライプ/RAID0) を使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-mirror-%e3%83%9f%e3%83%a9%e3%83%bc%e3%83%aa%e3%83%b3%e3%82%b0-raid1-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b-1.html" target="_blank">GEOM MIRROR (ミラーリング/RAID1) を使ってみる (1)</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-mirror-%e3%83%9f%e3%83%a9%e3%83%bc%e3%83%aa%e3%83%b3%e3%82%b0-raid1-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b-2.html" target="_blank">GEOM MIRROR (ミラーリング/RAID1) を使ってみる (2)</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-stripe-mirror-%e3%81%a7-raid10-%e3%82%92%e6%a7%8b%e6%88%90%e3%81%97%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM STRIPE + MIRROR で RAID10 を構成してみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-raid3%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM RAID3を使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-cache-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM CACHE を使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-gvirstor%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM GVIRSTORを使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-gate-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM GATE を使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-label-%e3%81%a7%e5%90%8d%e5%89%8d%e3%81%ab%e3%82%88%e3%82%8b%e7%ae%a1%e7%90%86%e3%82%92%e8%a1%8c%e3%81%86.html" target="_blank">GEOM LABEL で名前による管理を行う</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-part-%e3%81%a7%e3%83%87%e3%82%a3%e3%82%b9%e3%82%af%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%b3%e3%81%ae%e7%ae%a1%e7%90%86%e3%82%92%e8%a1%8c%e3%81%86.html" target="_blank">GEOM PART でディスクパーティションの管理を行う</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-multipath-%e3%81%a7%e3%83%9e%e3%83%ab%e3%83%81%e3%83%91%e3%82%b9%e3%82%92%e6%a7%8b%e6%88%90%e3%81%99%e3%82%8b-1.html" target="_blank">GEOM MULTIPATH でマルチパスを構成する (1)</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-multipath-%e3%81%a7%e3%83%9e%e3%83%ab%e3%83%81%e3%83%91%e3%82%b9%e3%82%92%e6%a7%8b%e6%88%90%e3%81%99%e3%82%8b-2.html" target="_blank">GEOM MULTIPATH でマルチパスを構成する (2)</a></li>
</ul>
</li>
</ul>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-4" checked><label class="toc-title" for="toc-checkbox-4">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">FreeBSD で Multipath なターゲットを設定する</a><ol><li><a href="#toc2" tabindex="0">設定の再読み込み</a></li></ol></li><li><a href="#toc3" tabindex="0">FreeBSD で Multipath なイニシエーターを設定する</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">FreeBSD で Multipath なターゲットを設定する</span></h2>



<p class="wp-block-paragraph">先日の iSCSI ターゲット/イニシエーターは iSCSI 用ネットワークが一つでしたが，二つの iSCSI ネットワークの構成にアップグレードしていきます．<br>イメージとしてはこのようになります．</p>



<figure class="wp-block-image aligncenter size-large is-resized"><img fetchpriority="high" decoding="async" width="546" height="339" src="https://www.seichan.org/blog/wp-content/uploads/2023/12/image-27-546x339.png" alt="" class="wp-image-1045" style="width:838px;height:auto" srcset="https://www.seichan.org/blog/wp-content/uploads/2023/12/image-27-546x339.png 546w, https://www.seichan.org/blog/wp-content/uploads/2023/12/image-27-300x186.png 300w, https://www.seichan.org/blog/wp-content/uploads/2023/12/image-27.png 587w" sizes="(max-width: 546px) 100vw, 546px" /></figure>



<p class="wp-block-paragraph"><br>まずは，ターゲット (サーバー) 側でマルチパスに向けた設定に修正していきます．<br>修正と言ってもそんなに多くありません．やったこととしては，172.16.255.0/24 が元々あったネットワークです．これに 172.17.255.0/24 のネットワークを足した形となります．<br>各 auth-group および portal-group に 172.17.255.x を足しました．</p>



<p class="wp-block-paragraph">ctl.conf の詳細については「<a href="https://www.seichan.org/2023/12/freebsd-%E3%81%A7-iscsi-%E3%82%92%E5%88%A9%E7%94%A8%E3%81%99%E3%82%8B-%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC-%E3%82%BF%E3%83%BC%E3%82%B2%E3%83%83%E3%83%88%E7%B7%A8.html" target="_blank">FreeBSD で iSCSI を利用する (サーバー/ターゲット編)</a>」を参照ください．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># cat /etc/ctl.conf
auth-group ag0 {
  chap-mutual "iscsi-user1" "Password-user1" "mutual-user" "Password-mutual"
  initiator-portal 172.16.255.0/24
  initiator-portal 172.17.255.0/24
}

auth-group ag1 {
  chap "iscsi-user2" "Password-user2"
  initiator-portal 172.16.255.1/24
  initiator-portal 172.17.255.1/24
}

auth-group ag2 {
  auth-type none
  initiator-portal 172.16.255.1/24
  initiator-portal 172.17.255.1/24
}


portal-group pg0 {
  discovery-auth-group no-authentication
  listen 172.16.255.254:3260
  listen 172.17.255.254:3260
}

target iqn.2023-12.iscsi.org.seichan:target0 {
  alias "target0"
  auth-group ag0
  portal-group pg0
  lun 0 {
    path /dev/da1
    option vendor "FreeBSD"
  }
  lun 1 {
    path /mnt/lun1.img
    option vendor "FreeBSD"
    blocksize 4096
    size 10G
  }
}

target iqn.2023-12.iscsi.org.seichan:target1 {
  alias "target1"
  auth-group ag1
  portal-group pg0
  lun 2 {
    path /mnt/lun2.img
    option vendor "FreeBSD"
    blocksize 4096
    size 10G
  }
}

target iqn.2023-12.iscsi.org.seichan:target2 {
  alias "target2"
  auth-group ag2
  portal-group pg0
  lun 3 {
    path /mnt/lun3.img
    option vendor "FreeBSD"
    blocksize 4096
    size 10G
  }
}</pre>



<h3 class="wp-block-heading"><span id="toc2">設定の再読み込み</span></h3>



<p class="wp-block-paragraph">次のコマンドでサービスに新しい設定を通知します．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># /etc/rc.d/ctld reload</pre>



<p class="wp-block-paragraph">以上でターゲット側は完了です．続いてイニシエーター側になります．</p>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>



<h2 class="wp-block-heading"><span id="toc3">FreeBSD で Multipath なイニシエーターを設定する</span></h2>



<p class="wp-block-paragraph">イニシエーター側のマルチパスに向けた準備も大きな変更はありません．</p>



<p class="wp-block-paragraph">以下が元々の設定ファイルになります．これを修正していきます．<br>設定ファイルの詳細については「<a href="https://www.seichan.org/2023/12/freebsd-%E3%81%A7-iscsi-%E3%82%92%E5%88%A9%E7%94%A8%E3%81%99%E3%82%8B-%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC-%E3%82%BF%E3%83%BC%E3%82%B2%E3%83%83%E3%83%88%E7%B7%A8.html" target="_blank">FreeBSD で iSCSI を利用する (クライアント/イニシエーター編)</a>」を参照してください．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># cat /etc/iscsi.conf
iscsi_target0 {
  targetaddress = 172.16.255.254;
  targetname = iqn.2023-12.iscsi.org.seichan:target0;
  authmethod = chap;
  chapiname = "iscsi-user1";
  chapsecret = "Password-user1";
  tgtchapname = "mutual-user";
  tgtchapsecret = "Password-mutual";
}

iscsi_target1 {
  targetaddress = 172.16.255.254;
  targetname = iqn.2023-12.iscsi.org.seichan:target1;
  authmethod = chap;
  chapiname = "iscsi-user2";
  chapsecret = "Password-user2";
}

iscsi_target2 {
  targetaddress = 172.16.255.254;
  targetname = iqn.2023-12.iscsi.org.seichan:target2;
  authmethod = none;
}</pre>



<p class="wp-block-paragraph">どういう名前付けが良いのか悩みましたが，これが一番分かりやすそうだったのでこうしました．<br>各設定を 172.16.255 と 172.17.255 分増やした形となります．iscsi_target0_0 と iscsi_target_0_1 の違いはこのニックネームの部分と targetaddress のみとなります．<br>これをマルチパスを構成するデバイス分増やしていった形となります．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># cat /etc/iscsi.conf
iscsi_target0_0 {
  targetaddress = 172.16.255.254;
  targetname = iqn.2023-12.iscsi.org.seichan:target0;
  authmethod = chap;
  chapiname = "iscsi-user1";
  chapsecret = "Password-user1";
  tgtchapname = "mutual-user";
  tgtchapsecret = "Password-mutual";
}

iscsi_target0_1 {
  targetaddress = 172.17.255.254;
  targetname = iqn.2023-12.iscsi.org.seichan:target0;
  authmethod = chap;
  chapiname = "iscsi-user1";
  chapsecret = "Password-user1";
  tgtchapname = "mutual-user";
  tgtchapsecret = "Password-mutual";
}


iscsi_target1_0 {
  targetaddress = 172.16.255.254;
  targetname = iqn.2023-12.iscsi.org.seichan:target1;
  authmethod = chap;
  chapiname = "iscsi-user2";
  chapsecret = "Password-user2";
}

iscsi_target1_1 {
  targetaddress = 172.17.255.254;
  targetname = iqn.2023-12.iscsi.org.seichan:target1;
  authmethod = chap;
  chapiname = "iscsi-user2";
  chapsecret = "Password-user2";
}

iscsi_target2_0 {
  targetaddress = 172.16.255.254;
  targetname = iqn.2023-12.iscsi.org.seichan:target2;
  authmethod = none;
}

iscsi_target2_1 {
  targetaddress = 172.17.255.254;
  targetname = iqn.2023-12.iscsi.org.seichan:target2;
  authmethod = none;
}</pre>



<p class="wp-block-paragraph">設定ファイルの修正が終わったら iscsictl を再起動します．本来は手動で追加するか，再起動を入れたほうがいいかもしれません．<br>サービスの再起動時，デバイスをマウントしていない事を確認してください．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># /etc/rc.d/iscsictl restart
iscsictl not running?
Starting iscsictl.
iscsictl: ISCSISADD: Device busy
iscsictl: ISCSISADD: Device busy
iscsictl: ISCSISADD: Device busy
/etc/rc.d/iscsictl: WARNING: failed to start iscsictl

# iscsictl -L
Target name                          Target portal    State
iqn.2023-12.iscsi.org.seichan:target0 172.16.255.254   Connected: da4 da5
iqn.2023-12.iscsi.org.seichan:target1 172.16.255.254   Connected: da3
iqn.2023-12.iscsi.org.seichan:target2 172.16.255.254   Connected: da2
iqn.2023-12.iscsi.org.seichan:target0 172.17.255.254   Connected: da7 da9
iqn.2023-12.iscsi.org.seichan:target1 172.17.255.254   Connected: da8
iqn.2023-12.iscsi.org.seichan:target2 172.17.255.254   Connected: da6
</pre>



<p class="wp-block-paragraph">エラーが出ちゃってますが，iscsictl -L で見ると二つのネットワークから接続できている事が確認できました．<br>これで GEOM MULTIPATH で束ねる準備ができました．</p>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.seichan.org/2023/12/geom-multipath-%e3%81%a7%e3%83%9e%e3%83%ab%e3%83%81%e3%83%91%e3%82%b9%e3%82%92%e6%a7%8b%e6%88%90%e3%81%99%e3%82%8b-1.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>GEOM LABEL で名前による管理を行う</title>
		<link>https://www.seichan.org/2023/12/geom-label-%e3%81%a7%e5%90%8d%e5%89%8d%e3%81%ab%e3%82%88%e3%82%8b%e7%ae%a1%e7%90%86%e3%82%92%e8%a1%8c%e3%81%86.html</link>
					<comments>https://www.seichan.org/2023/12/geom-label-%e3%81%a7%e5%90%8d%e5%89%8d%e3%81%ab%e3%82%88%e3%82%8b%e7%ae%a1%e7%90%86%e3%82%92%e8%a1%8c%e3%81%86.html#respond</comments>
		
		<dc:creator><![CDATA[seichan]]></dc:creator>
		<pubDate>Tue, 12 Dec 2023 13:00:00 +0000</pubDate>
				<category><![CDATA[GEOM]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[iSCSI]]></category>
		<guid isPermaLink="false">https://www.seichan.org/blog/?p=965</guid>

					<description><![CDATA[今回は GEOM によるデバイスへのラベル付けが可能になる GEOM LABEL について纏めてみたいと思います．ラベル (名前付け) による管理を用いる事で人間が分かりやすくなる．また，デバイス番号が変わった際にも気に [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">今回は GEOM によるデバイスへのラベル付けが可能になる GEOM LABEL について纏めてみたいと思います．<br>ラベル (名前付け) による管理を用いる事で人間が分かりやすくなる．また，デバイス番号が変わった際にも気にする必要がなくなるというメリットがあります．<br>例えば，デバイスが追加されたおかげで元々のデバイス番号順が変わってしまった場合，/etc/fstab の修正が必要になったりしますが，これらもラベルを用いた設定にしておく事で修正が必要ない環境にする事ができます．</p>



<ul class="wp-block-list">
<li>GEOM に関するお話
<ul class="wp-block-list">
<li><a href="https://www.seichan.org/2023/11/freebsd-geom-%e5%86%8d%e3%80%85%e5%ad%a6%e7%bf%92.html" target="_blank">FreeBSD GEOM 再々学習</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-concat-%e3%83%87%e3%82%a3%e3%82%b9%e3%82%af%e3%81%ae%e9%80%a3%e7%b5%90-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM CONCAT (ディスクの連結) を使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-stripe-%e3%82%b9%e3%83%88%e3%83%a9%e3%82%a4%e3%83%97-raid0-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM STRIPE (ストライプ/RAID0) を使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-mirror-%e3%83%9f%e3%83%a9%e3%83%bc%e3%83%aa%e3%83%b3%e3%82%b0-raid1-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b-1.html" target="_blank">GEOM MIRROR (ミラーリング/RAID1) を使ってみる (1)</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-mirror-%e3%83%9f%e3%83%a9%e3%83%bc%e3%83%aa%e3%83%b3%e3%82%b0-raid1-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b-2.html" target="_blank">GEOM MIRROR (ミラーリング/RAID1) を使ってみる (2)</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-stripe-mirror-%e3%81%a7-raid10-%e3%82%92%e6%a7%8b%e6%88%90%e3%81%97%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM STRIPE + MIRROR で RAID10 を構成してみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-raid3%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM RAID3を使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-cache-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM CACHE を使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-gvirstor%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM GVIRSTORを使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-gate-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b.html" target="_blank">GEOM GATE を使ってみる</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-label-%e3%81%a7%e5%90%8d%e5%89%8d%e3%81%ab%e3%82%88%e3%82%8b%e7%ae%a1%e7%90%86%e3%82%92%e8%a1%8c%e3%81%86.html" target="_blank">GEOM LABEL で名前による管理を行う</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-part-%e3%81%a7%e3%83%87%e3%82%a3%e3%82%b9%e3%82%af%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%b3%e3%81%ae%e7%ae%a1%e7%90%86%e3%82%92%e8%a1%8c%e3%81%86.html" target="_blank">GEOM PART でディスクパーティションの管理を行う</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-multipath-%e3%81%a7%e3%83%9e%e3%83%ab%e3%83%81%e3%83%91%e3%82%b9%e3%82%92%e6%a7%8b%e6%88%90%e3%81%99%e3%82%8b-1.html" target="_blank">GEOM MULTIPATH でマルチパスを構成する (1)</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-multipath-%e3%81%a7%e3%83%9e%e3%83%ab%e3%83%81%e3%83%91%e3%82%b9%e3%82%92%e6%a7%8b%e6%88%90%e3%81%99%e3%82%8b-2.html" target="_blank">GEOM MULTIPATH でマルチパスを構成する (2)</a></li>
</ul>
</li>
</ul>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-6" checked><label class="toc-title" for="toc-checkbox-6">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">ラベル名での管理の利点</a><ol><li><a href="#toc2" tabindex="0">ラベル管理を行わない場合のデメリット</a></li></ol></li><li><a href="#toc3" tabindex="0">ラベルの種類</a></li><li><a href="#toc4" tabindex="0">ラベルを付ける (glabel)</a><ol><li><a href="#toc5" tabindex="0">ラベルを用いてマウントを行う</a></li></ol></li><li><a href="#toc6" tabindex="0">GEOM LABEL を管理する</a><ol><li><a href="#toc7" tabindex="0">ラベルを付ける</a></li><li><a href="#toc8" tabindex="0">ラベルの状態を確認する (status)</a></li><li><a href="#toc9" tabindex="0">ラベルの状態を確認する (list)</a></li></ol></li><li><a href="#toc10" tabindex="0">ラベルを削除する (stop/destroy)</a><ol><li><a href="#toc11" tabindex="0">ラベルを再開する (refresh)</a></li></ol></li><li><a href="#toc12" tabindex="0">ラベルを削除する (clear)</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">ラベル名での管理の利点</span></h2>



<p class="wp-block-paragraph">前書きでも書きましたが，ラベル名による管理のメリットについて以下記載します．</p>



<p class="wp-block-paragraph">ラベルは，デバイス名やパーティション名に名前を付け，マウント時にラベル名を指定したマウントが出来るようになり，デバイス名を意識しなくてもよくなります．自分や自分の環境がそうなのですが，ディスクが何個もあり，RAID を構成するために同じ型番のディスクを何個も接続していたりします．さらに，ディスクを増やしたり減らしたり．なんて事があります．こうなると増減のタイミング等でデバイス名が変わる事になりますので，デバイス名での管理だと難しくなってしまいます．</p>



<p class="wp-block-paragraph">こういったシチュエーションであらかじめラベルとしてディスクに名前を付けてあげれば，以降はラベル名での管理になるのでディスクにラベル名を印刷したテプラを貼っておくことで何かあった際のデバイス特定も容易になります．</p>



<p class="wp-block-paragraph">こういった，デバイス名(番号)の管理から名前での管理に切り替えて少し運用負荷の軽減を狙ってみてはいかがでしょうか．</p>



<h3 class="wp-block-heading"><span id="toc2">ラベル管理を行わない場合のデメリット</span></h3>



<p class="wp-block-paragraph">ラベルによる管理を行わない場合，デバイス番号が変わる事による弊害が生じる．は先に説明した通りです．例として，前回用意した iSCSI イニシエーターのマシンのローカルディスクを1つ増やしたケースでお話します．</p>



<p class="wp-block-paragraph">元々左のような構成になっている環境に，イニシエーター側にディスクを一つ追加した場合となります．</p>



<figure class="wp-block-image aligncenter size-large is-resized"><img decoding="async" width="546" height="192" src="https://www.seichan.org/blog/wp-content/uploads/2023/12/image-23-546x192.png" alt="" class="wp-image-966" style="width:840px;height:auto" srcset="https://www.seichan.org/blog/wp-content/uploads/2023/12/image-23-546x192.png 546w, https://www.seichan.org/blog/wp-content/uploads/2023/12/image-23-300x106.png 300w, https://www.seichan.org/blog/wp-content/uploads/2023/12/image-23-768x270.png 768w, https://www.seichan.org/blog/wp-content/uploads/2023/12/image-23.png 1054w" sizes="(max-width: 546px) 100vw, 546px" /></figure>



<p class="wp-block-paragraph">左の時点ではこのような状態になっています．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># iscsictl -L
Target name                          Target portal    State
iqn.2023-12.iscsi.org.seichan:target0 172.16.255.254   Connected: da2 da4
iqn.2023-12.iscsi.org.seichan:target1 172.16.255.254   Connected: da3
iqn.2023-12.iscsi.org.seichan:target2 172.16.255.254   Connected: da1

# cat /etc/fstab
# Device        Mountpoint      FStype  Options Dump    Pass#
/dev/da0p2      /               ufs     rw      1       1
/dev/da0p3      none            swap    sw      0       0
/dev/da1        /iscsi/da1      ufs     rw,late 1       0

# camcontrol devlist
&lt;NECVMWar VMware IDE CDR00 1.00>   at scbus0 target 0 lun 0 (pass0,cd0)
&lt;VMware Virtual disk 2.0>          at scbus2 target 0 lun 0 (pass1,da0)
&lt;FreeBSD CTLDISK 0001>             at scbus3 target 0 lun 3 (da1,pass2)
&lt;FreeBSD CTLDISK 0001>             at scbus4 target 0 lun 0 (da2,pass3)
&lt;FreeBSD CTLDISK 0001>             at scbus4 target 0 lun 1 (da4,pass5)
&lt;FreeBSD CTLDISK 0001>             at scbus5 target 0 lun 2 (da3,pass4)</pre>



<p class="wp-block-paragraph">このマシンにオンラインのまま1つディスクを追加してみます．<br>そうすると，daX は最後の番号にインクリメントされて生成されます．今回は da5 として認識しました．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pvscsi0: MSG: device addition at scsi0:1:0
da5 at pvscsi0 bus 0 scbus2 target 1 lun 0
da5: &lt;VMware Virtual disk 2.0> Fixed Direct Access SPC-4 SCSI device
da5: 750.000MB/s transfers
da5: Command Queueing enabled
da5: 102400MB (209715200 512 byte sectors)
da5: quirks=0x140&lt;RETRY_BUSY,STRICT_UNMAP>

# camcontrol devlist
&lt;NECVMWar VMware IDE CDR00 1.00>   at scbus0 target 0 lun 0 (pass0,cd0)
&lt;VMware Virtual disk 2.0>          at scbus2 target 0 lun 0 (pass1,da0)
&lt;VMware Virtual disk 2.0>          at scbus2 target 1 lun 0 (da5,pass6)
&lt;FreeBSD CTLDISK 0001>             at scbus3 target 0 lun 3 (da1,pass2)
&lt;FreeBSD CTLDISK 0001>             at scbus4 target 0 lun 0 (da2,pass3)
&lt;FreeBSD CTLDISK 0001>             at scbus4 target 0 lun 1 (da4,pass5)
&lt;FreeBSD CTLDISK 0001>             at scbus5 target 0 lun 2 (da3,pass4)</pre>



<p class="wp-block-paragraph">この状態で再起動を行ってみるとどうなるか見てみましょう．</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;6ab8fa3e64d6c&quot;}" data-wp-interactive="core/image" data-wp-key="6ab8fa3e64d6c" class="wp-block-image aligncenter size-full is-resized wp-lightbox-container"><img decoding="async" width="764" height="553" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://www.seichan.org/blog/wp-content/uploads/2023/12/SnapCrab_bsd13-1seichanlocal-VMware-Workstation_2023-12-11_10-15-45_No-00.png" alt="" class="wp-image-968" style="width:768px" srcset="https://www.seichan.org/blog/wp-content/uploads/2023/12/SnapCrab_bsd13-1seichanlocal-VMware-Workstation_2023-12-11_10-15-45_No-00.png 764w, https://www.seichan.org/blog/wp-content/uploads/2023/12/SnapCrab_bsd13-1seichanlocal-VMware-Workstation_2023-12-11_10-15-45_No-00-300x217.png 300w, https://www.seichan.org/blog/wp-content/uploads/2023/12/SnapCrab_bsd13-1seichanlocal-VMware-Workstation_2023-12-11_10-15-45_No-00-546x395.png 546w" sizes="(max-width: 764px) 100vw, 764px" /><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button></figure>



<p class="wp-block-paragraph">「<em><strong>/dev/da1: invalied fstype</strong></em>」というエラーが発生しました．一度 fstab の該当行をコメントアウトして起動，状態を見てみましょう．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># iscsictl -L
Target name                          Target portal    State
iqn.2023-12.iscsi.org.seichan:target0 172.16.255.254   Connected: da4 da5
iqn.2023-12.iscsi.org.seichan:target1 172.16.255.254   Connected: da3
iqn.2023-12.iscsi.org.seichan:target2 172.16.255.254   Connected: da2

# camcontrol devlist
&lt;NECVMWar VMware IDE CDR00 1.00>   at scbus0 target 0 lun 0 (pass0,cd0)
&lt;VMware Virtual disk 2.0>          at scbus2 target 0 lun 0 (pass1,da0)
&lt;VMware Virtual disk 2.0>          at scbus2 target 1 lun 0 (pass2,da1)
&lt;FreeBSD CTLDISK 0001>             at scbus3 target 0 lun 3 (da2,pass3)
&lt;FreeBSD CTLDISK 0001>             at scbus4 target 0 lun 2 (da3,pass4)
&lt;FreeBSD CTLDISK 0001>             at scbus5 target 0 lun 0 (da4,pass5)
&lt;FreeBSD CTLDISK 0001>             at scbus5 target 0 lun 1 (da5,pass6)</pre>



<p class="wp-block-paragraph">元々 iSCSI デバイスとして見えていた da1 が da2 に変更になっています．<br>そして，追加したディスクが da5 から da1 に変更になりました．</p>



<p class="wp-block-paragraph">デバイス名での管理を行っている場合，こういった番号が変更になってしまう事があり，それに伴い意図しない不具合・障害が発生する事になります．</p>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>



<h2 class="wp-block-heading"><span id="toc3">ラベルの種類</span></h2>



<p class="wp-block-paragraph">GEOM LABEL クラスではいくつかのラベルの種類があります．正確にはファイルシステム毎にラベル機構が用意されています．また，これらのファイルシステムに依存せずにラベルを管理する方法もあります．</p>



<p class="wp-block-paragraph">ファイルシステムで用意されているもので FreeBSD でよくつかわれそうなものとして以下が挙げられます．各ファイルシステム毎のディレクトリ以下にラベル名のデバイスファイルが生成されます．</p>



<ul class="wp-block-list">
<li>UFS1/UFS2 のボリューム名 (/dev/ufs)</li>



<li>UFS1/UFS2 のファイルシステムID (/dev/ufsid)</li>



<li>FAT12/16/32 等の MSDOSFS (/dev/msdosfs)</li>



<li>CD-ROM 等の ISO9660 (/dev/iso9660)</li>



<li>NTFS (/dev/ntfs)</li>
</ul>



<p class="wp-block-paragraph">また，GPT パーティションではパーティション単位でもラベルを付与出来ます．</p>



<ul class="wp-block-list">
<li>GPT ラベル&nbsp; (/dev/gpt)</li>



<li>GPT UUID (/dev/gptid)</li>
</ul>



<h2 class="wp-block-heading"><span id="toc4">ラベルを付ける (glabel)</span></h2>



<p class="wp-block-paragraph">glabel はファイルシステムに依存せずにラベルを管理する事が出来ます．ファイルシステムでラベルが用意されていない場合や複数のファイルシステムを扱うため，統一的に管理したい．なんていう場合に有用だと思います．</p>



<p class="wp-block-paragraph">ラベルを付けるには，下のように&nbsp;<em><strong>glabel label [ラベル名] [デバイス名]</strong></em>&nbsp;という引数で実行します．<br><span class="red">サブコマンドが label ではなく create の場合，ディスクにラベル名が書かれませんので再起動時にクリアされてしまいます．試験等の一時的なラベル付与等の場合は create を使いますが，恒久的にラベルを使いたい場合は label サブコマンドを指定してください．</span></p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># glabel label iscsi-lun3 /dev/da2</pre>



<p class="wp-block-paragraph">ラベルが設定されれば，以下のように <strong>status</strong> で確認することが出来ます．この例では今回設定したものだけ表示させています．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># glabel status
                                      Name  Status  Components
                    ufsid/6575ba6a5bc67fd7     N/A  da2
                  diskid/DISK-MYSERIAL0003     N/A  da2
                          label/iscsi-lun3     N/A  da2</pre>



<p class="wp-block-paragraph">また，glabel の場合は /dev/label 以下にデバイスファイルが生成されていますので，こちらでも確認が可能です．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># ls -l /dev/label
total 0
crw-r-----  1 root  operator  0x71 Dec 11 10:30 iscsi-lun3</pre>



<h3 class="wp-block-heading"><span id="toc5">ラベルを用いてマウントを行う</span></h3>



<p class="wp-block-paragraph">作成したラベルを用いたマウントを試行してみます．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># mount /dev/label/iscsi-lun3 /iscsi/da1

# df
Filesystem            1K-blocks    Used    Avail Capacity  Mounted on
/dev/da0p2             19279260 3141160 14595760    18%    /
devfs                         1       1        0   100%    /dev
/dev/label/iscsi-lun3  10144028       8  9332500     0%    /iscsi/da1</pre>



<p class="wp-block-paragraph">ラベル名によるデバイスの指定が無事出来ましたので，これを再起動後も動作するように /etc/fstab に反映します．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># cat /etc/fstab
# Device        Mountpoint      FStype  Options Dump    Pass#
/dev/da0p2      /               ufs     rw      1       1
/dev/da0p3      none            swap    sw      0       0
/dev/label/iscsi-lun3 /iscsi/da1 ufs    rw,late 1       0</pre>



<p class="wp-block-paragraph">再起動後もこの状態で起動するのかを確認します．</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;6ab8fa3e662eb&quot;}" data-wp-interactive="core/image" data-wp-key="6ab8fa3e662eb" class="wp-block-image aligncenter size-full is-resized wp-lightbox-container"><img loading="lazy" decoding="async" width="764" height="553" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://www.seichan.org/blog/wp-content/uploads/2023/12/SnapCrab_bsd13-1seichanlocal-VMware-Workstation_2023-12-11_10-43-28_No-00.png" alt="" class="wp-image-970" style="width:768px" srcset="https://www.seichan.org/blog/wp-content/uploads/2023/12/SnapCrab_bsd13-1seichanlocal-VMware-Workstation_2023-12-11_10-43-28_No-00.png 764w, https://www.seichan.org/blog/wp-content/uploads/2023/12/SnapCrab_bsd13-1seichanlocal-VMware-Workstation_2023-12-11_10-43-28_No-00-300x217.png 300w, https://www.seichan.org/blog/wp-content/uploads/2023/12/SnapCrab_bsd13-1seichanlocal-VMware-Workstation_2023-12-11_10-43-28_No-00-546x395.png 546w" sizes="(max-width: 764px) 100vw, 764px" /><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button></figure>



<p class="wp-block-paragraph">正常に起動しました．また，マウントの状況も以下のとおり正常に行われています．</p>



<h2 class="wp-block-heading"><span id="toc6">GEOM LABEL を管理する</span></h2>



<p class="wp-block-paragraph">glabel のオプション群について以下纏めていきます．<br>実際のオペレーションとしては glabel 単体よりも，gpart を使って．が多いかもしれませんが，自身の備忘録も兼ねて．</p>



<h3 class="wp-block-heading"><span id="toc7">ラベルを付ける</span></h3>



<p class="wp-block-paragraph">上でも書きましたが，ラベルを付与するには&nbsp;<em><strong>glabel label [ラベル名] [デバイス名]</strong></em>&nbsp;という引数で実行します．<br><strong><em>glabel create  [ラベル名] [デバイス名]&nbsp;</em></strong>でも付与は可能ですが一時的なものとなります．<br>指定できるデバイス名は RW なデバイス (HDD,SSD 等) になります．<br><br>以下，未使用の da1 (ローカルディスク) でコマンドを実行，結果を見ていく形とします．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># glabel label local-hdd1 da1</pre>



<h3 class="wp-block-heading"><span id="toc8">ラベルの状態を確認する (status)</span></h3>



<p class="wp-block-paragraph">ラベルの状況を確認するコマンドとして <strong>status</strong> と <strong>list</strong> があります．status がサマリーで，list が詳細です．<br><strong>status に渡せるものとしてデバイス名を渡すことができ</strong>，その場合はそのデバイスの情報だけが出力されます．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># glabel status
                                      Name  Status  Components
gptid/e49c97b1-8d16-11ee-ad0a-0050568da523     N/A  da0p1
                          label/iscsi-lun3     N/A  da2
                  diskid/DISK-MYSERIAL0002     N/A  da3
                    ufsid/6572f98e0f76158d     N/A  da4
                  diskid/DISK-MYSERIAL0000     N/A  da4
                  diskid/DISK-MYSERIAL0001     N/A  da5
                          label/local-hdd1     N/A  da1

# glabel status da1
            Name  Status  Components
label/local-hdd1     N/A  da1</pre>



<h3 class="wp-block-heading"><span id="toc9">ラベルの状態を確認する (list)</span></h3>



<p class="wp-block-paragraph">ラベルの状況を確認するコマンドとして <strong>status</strong> と <strong>list</strong> があります．status がサマリーで，list が詳細です．<br>list の場合はデバイスの容量やパーティション情報などのディスクの詳細も合わせて表示されます．</p>



<p class="wp-block-paragraph">以下 list の結果ですが，長くなるのでローカルディスクとマウントしている iSCSI ボリュームのみ掲載しています．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># glabel list
Geom name: da0p1
Providers:
1. Name: gptid/e49c97b1-8d16-11ee-ad0a-0050568da523
   Mediasize: 524288 (512K)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 20480
   Mode: r0w0e0
   secoffset: 0
   offset: 0
   seclength: 1024
   length: 524288
   index: 0
Consumers:
1. Name: da0p1
   Mediasize: 524288 (512K)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 20480
   Mode: r0w0e0

Geom name: da2
Providers:
1. Name: label/iscsi-lun3
   Mediasize: 10737414144 (10G)
   Sectorsize: 4096
   Stripesize: 32768
   Stripeoffset: 0
   Mode: r1w1e1
   secoffset: 0
   offset: 0
   seclength: 20971512
   length: 10737414144
   index: 0
Consumers:
1. Name: da2
   Mediasize: 10737418240 (10G)
   Sectorsize: 4096
   Stripesize: 32768
   Stripeoffset: 0
   Mode: r1w1e2

Geom name: da1
Providers:
1. Name: label/local-hdd1
   Mediasize: 107374181888 (100G)
   Sectorsize: 512
   Mode: r0w0e0
   secoffset: 0
   offset: 0
   seclength: 209715199
   length: 107374181888
   index: 0
Consumers:
1. Name: da1
   Mediasize: 107374182400 (100G)
   Sectorsize: 512
   Mode: r0w0e0
</pre>



<p class="wp-block-paragraph">オプションとしてデバイス名を付与する事でそのデバイスだけの詳細を表示する事ができます．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># glabel list da1
Geom name: da1
Providers:
1. Name: label/local-hdd1
   Mediasize: 107374181888 (100G)
   Sectorsize: 512
   Mode: r0w0e0
   secoffset: 0
   offset: 0
   seclength: 209715199
   length: 107374181888
   index: 0
Consumers:
1. Name: da1
   Mediasize: 107374182400 (100G)
   Sectorsize: 512
   Mode: r0w0e0</pre>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>



<h2 class="wp-block-heading"><span id="toc10">ラベルを削除する (stop/destroy)</span></h2>



<p class="wp-block-paragraph">ラベル情報を一時的に破棄したい場合 <strong>glabel destroy</strong> (または <strong>stop</strong>) コマンドを利用します．<br><span class="red">渡す引数ですが，デバイス名ではなくラベル名である事に注意してください．</span></p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># glabel destroy label/local-hdd1

# glabel status
                                      Name  Status  Components
gptid/e49c97b1-8d16-11ee-ad0a-0050568da523     N/A  da0p1
                          label/iscsi-lun3     N/A  da2
                  diskid/DISK-MYSERIAL0002     N/A  da3
                    ufsid/6572f98e0f76158d     N/A  da4
                  diskid/DISK-MYSERIAL0000     N/A  da4
                  diskid/DISK-MYSERIAL0001     N/A  da5</pre>



<p class="wp-block-paragraph">このように status に表示されない状態となります．<br>ただ，destroy / stop はメタデータの削除までは行われませんので復旧する事が可能です．</p>



<h3 class="wp-block-heading"><span id="toc11">ラベルを再開する (refresh)</span></h3>



<p class="wp-block-paragraph">destroy / stop で破棄したラベルを戻したい場合は <strong>glabel refresh</strong> コマンドを利用します．<br><span class="red">この場合はラベル名ではなく，デバイス名である事に注意してください．</span></p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># glabel refresh da1
Metadata from da1 refreshed.

# glabel status
                                      Name  Status  Components
gptid/e49c97b1-8d16-11ee-ad0a-0050568da523     N/A  da0p1
                          label/iscsi-lun3     N/A  da2
                  diskid/DISK-MYSERIAL0002     N/A  da3
                    ufsid/6572f98e0f76158d     N/A  da4
                  diskid/DISK-MYSERIAL0000     N/A  da4
                  diskid/DISK-MYSERIAL0001     N/A  da5
                          label/local-hdd1     N/A  da1</pre>



<h2 class="wp-block-heading"><span id="toc12">ラベルを削除する (clear)</span></h2>



<p class="wp-block-paragraph">destroy / stop は一時的な破棄で，メタデータは維持されると説明しました．メタデータも消去する場合は <strong>glabel clear</strong> を利用します．<br><span class="red">clear の場合，ラベル名ではなくデバイス名となり，複数のラベルを持っている場合はそれらすべてが消去されますのでその点を認識してください．</span></p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># glabel clear da1

# glabel status
                                      Name  Status  Components
gptid/e49c97b1-8d16-11ee-ad0a-0050568da523     N/A  da0p1
                          label/iscsi-lun3     N/A  da2
                  diskid/DISK-MYSERIAL0002     N/A  da3
                    ufsid/6572f98e0f76158d     N/A  da4
                  diskid/DISK-MYSERIAL0000     N/A  da4
                  diskid/DISK-MYSERIAL0001     N/A  da5</pre>



<p class="wp-block-paragraph">clear で消去した場合，refresh で戻す事は不可能ですので，ラベルを戻したい/別の名前を付けたい場合は glabel label コマンドで改めてラベルを付与してください．</p>



<p class="wp-block-paragraph">以上で GEOM LABEL についての説明を終わりたいと思います．</p>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.seichan.org/2023/12/geom-label-%e3%81%a7%e5%90%8d%e5%89%8d%e3%81%ab%e3%82%88%e3%82%8b%e7%ae%a1%e7%90%86%e3%82%92%e8%a1%8c%e3%81%86.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>FreeBSD で iSCSI を利用する (クライアント/イニシエーター編)</title>
		<link>https://www.seichan.org/2023/12/freebsd-%e3%81%a7-iscsi-%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b-%e3%82%af%e3%83%a9%e3%82%a4%e3%82%a2%e3%83%b3%e3%83%88-%e3%82%a4%e3%83%8b%e3%82%b7%e3%82%a8%e3%83%bc%e3%82%bf%e3%83%bc%e7%b7%a8.html</link>
					<comments>https://www.seichan.org/2023/12/freebsd-%e3%81%a7-iscsi-%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b-%e3%82%af%e3%83%a9%e3%82%a4%e3%82%a2%e3%83%b3%e3%83%88-%e3%82%a4%e3%83%8b%e3%82%b7%e3%82%a8%e3%83%bc%e3%82%bf%e3%83%bc%e7%b7%a8.html#respond</comments>
		
		<dc:creator><![CDATA[seichan]]></dc:creator>
		<pubDate>Mon, 11 Dec 2023 13:00:00 +0000</pubDate>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[iSCSI]]></category>
		<guid isPermaLink="false">https://www.seichan.org/blog/?p=954</guid>

					<description><![CDATA[FreeBSD 10.0 より，別途パッケージを導入する必要が無く，標準で iSCSI が利用できるようになりました．iSCSI は RFC 7143 で規定されている標準的なプロトコルになりますので FreeBSD に [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">FreeBSD 10.0 より，別途パッケージを導入する必要が無く，標準で iSCSI が利用できるようになりました．<br>iSCSI は RFC 7143 で規定されている標準的なプロトコルになりますので FreeBSD に限らず様々なシステムが利用する事ができます．(GEOM GATE と違って)</p>



<p class="wp-block-paragraph">今回は FreeBSD での iSCSI によるディスクの提供について纏めてみたいと思います．<br>ターゲットのお話および iSCSI とは? については「<a href="https://www.seichan.org/2023/12/freebsd-で-iscsi-を利用する-サーバー-ターゲット編.html" target="_blank">FreeBSD で iSCSI を利用する (サーバー/ターゲット編)</a>」に纏めていますので合わせてみて頂ければと思います．</p>



<ul class="wp-block-list">
<li>FreeBSD の iSCSI に関するお話
<ul class="wp-block-list">
<li><a href="https://www.seichan.org/2023/12/freebsd-%e3%81%a7-iscsi-%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b-%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc-%e3%82%bf%e3%83%bc%e3%82%b2%e3%83%83%e3%83%88%e7%b7%a8.html" target="_blank">FreeBSD で iSCSI を利用する (サーバー/ターゲット編)</a></li>



<li><a href="https://www.seichan.org/2023/12/freebsd-%e3%81%a7-iscsi-%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b-%e3%82%af%e3%83%a9%e3%82%a4%e3%82%a2%e3%83%b3%e3%83%88-%e3%82%a4%e3%83%8b%e3%82%b7%e3%82%a8%e3%83%bc%e3%82%bf%e3%83%bc%e7%b7%a8.html" target="_blank">FreeBSD で iSCSI を利用する (クライアント/イニシエーター編)</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-multipath-%e3%81%a7%e3%83%9e%e3%83%ab%e3%83%81%e3%83%91%e3%82%b9%e3%82%92%e6%a7%8b%e6%88%90%e3%81%99%e3%82%8b-1.html" target="_blank">GEOM MULTIPATH でマルチパスを構成する (1)</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-multipath-%e3%81%a7%e3%83%9e%e3%83%ab%e3%83%81%e3%83%91%e3%82%b9%e3%82%92%e6%a7%8b%e6%88%90%e3%81%99%e3%82%8b-2.html">GEOM MULTIPATH でマルチパスを構成する (2)</a></li>



<li><a href="https://www.seichan.org/2023/12/freebsd-%e3%81%a7-zfs-%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b-raw%e3%83%9c%e3%83%aa%e3%83%a5%e3%83%bc%e3%83%a0%e3%82%92%e5%88%87%e3%82%8a%e5%87%ba%e3%81%99-iscsi-%e3%81%a8%e3%81%97.html" target="_blank">FreeBSD で ZFS を利用する – RAWボリュームを切り出す &amp; iSCSI として提供する</a></li>
</ul>
</li>
</ul>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-8" checked><label class="toc-title" for="toc-checkbox-8">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">FreeBSD でイニシエーターを設定する</a><ol><li><a href="#toc2" tabindex="0">設定ファイルの解説</a></li></ol></li><li><a href="#toc3" tabindex="0">サービスの起動</a></li><li><a href="#toc4" tabindex="0">iscsictl コマンドを使って色々とやってみる</a><ol><li><a href="#toc5" tabindex="0">現在の状態を確認する</a></li><li><a href="#toc6" tabindex="0">セッションを無効化する</a></li><li><a href="#toc7" tabindex="0">セッションを再開する</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">FreeBSD でイニシエーターを設定する</span></h2>



<p class="wp-block-paragraph">前回設定した iSCSI ターゲットをクライアント側(イニシエーター)より利用する為の設定を行います．<br>イメージ図は前回同様で，iSCSI 用のネットワークが存在する形となります．</p>



<figure class="wp-block-image aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="483" height="371" src="https://www.seichan.org/blog/wp-content/uploads/2023/12/image-22.png" alt="" class="wp-image-935" style="width:527px;height:auto" srcset="https://www.seichan.org/blog/wp-content/uploads/2023/12/image-22.png 483w, https://www.seichan.org/blog/wp-content/uploads/2023/12/image-22-300x230.png 300w" sizes="(max-width: 483px) 100vw, 483px" /></figure>



<p class="wp-block-paragraph">FreeBSD での iSCSI イニシエーター機能は iscsid と iscsictl の二つのプログラムによって行われます．<br>イニシエーター側としてもどのデバイスを利用するのかなどの設定を用意する必要がありますので，以下に例を記載します．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># cat /etc/iscsi.conf
iscsi_target0 {
  targetaddress = 172.16.255.254;
  targetname = iqn.2023-12.iscsi.org.seichan:target0;
  authmethod = chap;
  chapiname = "iscsi-user1";
  chapsecret = "Password-user1";
  tgtchapname = "mutual-user";
  tgtchapsecret = "Password-mutual";
}

iscsi_target1 {
  targetaddress = 172.16.255.254;
  targetname = iqn.2023-12.iscsi.org.seichan:target1;
  authmethod = chap;
  chapiname = "iscsi-user2";
  chapsecret = "Password-user2";
}

iscsi_target2 {
  targetaddress = 172.16.255.254;
  targetname = iqn.2023-12.iscsi.org.seichan:target2;
  authmethod = none;
}</pre>



<h3 class="wp-block-heading"><span id="toc2">設定ファイルの解説</span></h3>



<p class="wp-block-paragraph">前回設定したターゲットに合わせた設定ファイルを用意しました．内容について以下に解説します．</p>



<ul class="wp-block-list">
<li>iscsi_target0 {<br>iscsictl コマンドで指定する際の名前(ニックネーム)です．</li>



<li>targetaddress<br>iSCSI ターゲットの IP アドレスもしくは FQDN を記載します．</li>



<li>targetname<br>iSCSI ターゲット側で設定しているターゲット名を記載します．</li>



<li>authmethod<br>iSCSI ターゲットへの接続時に認証を行うのかを指定します．none または chap が指定可能です．</li>



<li>chapiname<br>認証を行う場合のユーザー名(ログイン名)を記載します．</li>



<li>chapsecret<br>認証を行う場合のシークレット文字列(パスワード)を記載します．</li>



<li>tgtchapname<br>相互 CHAP 認証を行う場合のユーザー名(ログイン名)を記載します．</li>



<li>tgtchapsecret<br>相互 CHAP 認証を行う場合のシークレット文字列(パスワード)を記載します．</li>
</ul>



<p class="wp-block-paragraph">なお，/etc/iscsi.conf は認証情報が記載される為，パーミッションを 600 にしましょう．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># chmod 600 /etc/iscsi.conf</pre>



<h2 class="wp-block-heading"><span id="toc3">サービスの起動</span></h2>



<p class="wp-block-paragraph">/etc/rc.conf に次の文字を追加します</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># cat /etc/rc.conf
iscsid_enable="YES"
iscsictl_enable="YES"</pre>



<p class="wp-block-paragraph">では，サービスを実行してみましょう</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># /etc/rc.d/iscsid start
Starting iscsid.

# /etc/rc.d/iscsictl start
Starting iscsictl.</pre>



<p class="wp-block-paragraph">/etc/iscsi.conf の設定が間違っている場合，iscsictl 起動時にエラーが出力されます．その場合はメッセージに出力される内容をもとに修正してください．</p>



<p class="wp-block-paragraph">iscsictl を起動すると設定ファイルに従って iSCSI ターゲットへのアクセス，成功したらデバイスファイルが作成されます．<br>状態を確認するには iscsictl コマンドで行う事が可能です</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># iscsictl -L
Target name                          Target portal    State
iqn.2023-12.iscsi.org.seichan:target0 172.16.255.254   Connected: da3 da4
iqn.2023-12.iscsi.org.seichan:target1 172.16.255.254   Connected: da2
iqn.2023-12.iscsi.org.seichan:target2 172.16.255.254   Connected: da1</pre>



<p class="wp-block-paragraph">この場合，(自分が期待する順番と違いましたが&#8230;) target0 では二つのボリューム，target1, 2 からはそれぞれ一つのボリュームが見えており，daX として接続されています．<br>実際にデバイスファイルが存在する事も確認しましょう．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># ls /dev/da*
/dev/da0        /dev/da0p2      /dev/da1        /dev/da3
/dev/da0p1      /dev/da0p3      /dev/da2        /dev/da4</pre>



<p class="wp-block-paragraph">da0 がローカルディスクで OS 領域となります．da1～da4 まで作成されていますので iSCSI の接続は正しく行えています．</p>



<p class="wp-block-paragraph">では，これをフォーマットし，マウントを行ってみます．また，再起動時もマウントされるように fstab も記載します．<br>(今回は da1 のみ行います．)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># newfs /dev/da1
/dev/da1: 10240.0MB (20971520 sectors) block size 32768, fragment size 4096
        using 17 cylinder groups of 625.22MB, 20007 blks, 80128 inodes.
super-block backups (for fsck_ffs -b #) at:
 192, 1280640, 2561088, 3841536, 5121984, 6402432, 7682880, 8963328, 10243776, 11524224, 12804672, 14085120, 15365568,
 16646016, 17926464, 19206912, 20487360

# mkdir -p /iscsi/da1

# mount /dev/da1 /iscsi/da1

# df
Filesystem 1K-blocks    Used    Avail Capacity  Mounted on
/dev/da0p2  19279260 3140972 14595948    18%    /
devfs              1       1        0   100%    /dev
/dev/da1    10144028       8  9332500     0%    /iscsi/da1

# cat /etc/fstab
# Device        Mountpoint      FStype  Options Dump    Pass#
/dev/da0p2      /               ufs     rw      1       1
/dev/da0p3      none            swap    sw      0       0
/dev/da1        /iscsi/da1      ufs     rw      1       1</pre>



<p class="wp-block-paragraph">では再起動を行ったうえで再度確認を行います．</p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" width="546" height="395" src="https://www.seichan.org/blog/wp-content/uploads/2023/12/SnapCrab_bsd13-1seichanlocal-VMware-Workstation_2023-12-10_22-24-22_No-00-546x395.png" alt="" class="wp-image-959" style="width:839px;height:auto" srcset="https://www.seichan.org/blog/wp-content/uploads/2023/12/SnapCrab_bsd13-1seichanlocal-VMware-Workstation_2023-12-10_22-24-22_No-00-546x395.png 546w, https://www.seichan.org/blog/wp-content/uploads/2023/12/SnapCrab_bsd13-1seichanlocal-VMware-Workstation_2023-12-10_22-24-22_No-00-300x217.png 300w, https://www.seichan.org/blog/wp-content/uploads/2023/12/SnapCrab_bsd13-1seichanlocal-VMware-Workstation_2023-12-10_22-24-22_No-00.png 764w" sizes="(max-width: 546px) 100vw, 546px" /></figure>



<p class="wp-block-paragraph">マウントができずに起動途中で停止します．この理由は fstab の書き方に問題があるためとなります．<br>iSCSI イニシエーターのサービスが起動する前にマウントを試みておりそこで終了するという状態です．<br>/etc/rc.d 以下のスクリプト群において，ファイルシステムおよび iscsi に関連するものの順番は次のとおりです．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># rcorder /etc/rc.d/* | grep -E "mount|iscsi|fsck"
/etc/rc.d/fsck
/etc/rc.d/mountcritlocal
/etc/rc.d/autounmountd
/etc/rc.d/iscsid
/etc/rc.d/iscsictl
/etc/rc.d/mountcritremote
/etc/rc.d/automountd
/etc/rc.d/automount
/etc/rc.d/mountlate
/etc/rc.d/mountd
/etc/rc.d/bgfsck</pre>



<p class="wp-block-paragraph">mountcritlocal ここでマウントを行おうとしているためにエラーとなります．<br>また，Pass が 1 の場合，fsck によるファイルシステムチェック対象となり，これもまた mountcritlocal の前の実行になるためにエラーとなります．<br>そのため，これらを解消できるような /etc/fstab に修正します．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># cat /etc/fstab
# Device        Mountpoint      FStype  Options Dump    Pass#
/dev/da0p2      /               ufs     rw      1       1
/dev/da0p3      none            swap    sw      0       0
/dev/da1        /iscsi/da1      ufs     rw,late 1       0</pre>



<p class="wp-block-paragraph">また，状況によっては iscsictl が起動後接続に至らない可能性があります．これも合わせて対処する場合は /etc/rc.conf に次の一行を追加します．<br>デフォルトが -Aa で -w 5 を追加し，5秒のウェイトを持たせています．ここは実施可否およびウェイトの時間については実際の環境に応じて実施してください．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">iscsictl_flags="-Aa -w 5"</pre>



<p class="wp-block-paragraph">改めて再起動を行ってみます．</p>



<figure class="wp-block-image aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="546" height="395" src="https://www.seichan.org/blog/wp-content/uploads/2023/12/SnapCrab_bsd13-1seichanlocal-VMware-Workstation_2023-12-10_22-47-27_No-00-546x395.png" alt="" class="wp-image-960" style="width:840px;height:auto" srcset="https://www.seichan.org/blog/wp-content/uploads/2023/12/SnapCrab_bsd13-1seichanlocal-VMware-Workstation_2023-12-10_22-47-27_No-00-546x395.png 546w, https://www.seichan.org/blog/wp-content/uploads/2023/12/SnapCrab_bsd13-1seichanlocal-VMware-Workstation_2023-12-10_22-47-27_No-00-300x217.png 300w, https://www.seichan.org/blog/wp-content/uploads/2023/12/SnapCrab_bsd13-1seichanlocal-VMware-Workstation_2023-12-10_22-47-27_No-00.png 764w" sizes="(max-width: 546px) 100vw, 546px" /></figure>



<p class="wp-block-paragraph">このように無事起動が完了しました．マウントの状態としては次のとおりです．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># df
Filesystem 1K-blocks    Used    Avail Capacity  Mounted on
/dev/da0p2  19279260 3141104 14595816    18%    /
devfs              1       1        0   100%    /dev
/dev/da1    10144028       8  9332500     0%    /iscsi/da1</pre>



<p class="wp-block-paragraph">これで FreeBSD としてマウントまできれいに完了できる状態となりました．</p>



<h2 class="wp-block-heading"><span id="toc4">iscsictl コマンドを使って色々とやってみる</span></h2>



<p class="wp-block-paragraph">iscsictl コマンドで設定ファイルを用いない接続であったり，今接続中のセッションの切断を行ったりなどができます．<br>さらっと以下に使い方を纏めてみます．</p>



<h3 class="wp-block-heading"><span id="toc5">現在の状態を確認する</span></h3>



<p class="wp-block-paragraph">現在の状態を確認する場合は -L オプションを付けて実行します．<br>以下の場合は3つのセッションがあり，すべて接続となっており，かつ da1-4 の4つのディスクをつないでいるという状況です．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># iscsictl -L
Target name                          Target portal    State
iqn.2023-12.iscsi.org.seichan:target0 172.16.255.254   Connected: da3 da4
iqn.2023-12.iscsi.org.seichan:target1 172.16.255.254   Connected: da2
iqn.2023-12.iscsi.org.seichan:target2 172.16.255.254   Connected: da1</pre>



<h3 class="wp-block-heading"><span id="toc6">セッションを無効化する</span></h3>



<p class="wp-block-paragraph">メンテナンスなどの何らかの理由で一時的に特定のセッションを無効化したい場合は -M オプションを用います．<br>引数としてセッション ID が必要なので，まずはセッション ID の確認を行う必要があります．これには -L オプションの verbose ありで実施します．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># iscsictl -L -v
Session ID:               1
Initiator name:           iqn.1994-09.org.freebsd:bsd13-1.seichan.local
Initiator portal:
Initiator alias:
Target name:              iqn.2023-12.iscsi.org.seichan:target0
Target portal:            172.16.255.254
Target alias:             target0
User:                     iscsi-user1
Secret:                   Password-user1
Mutual user:              mutual-user
Mutual secret:            Password-mutual
Session type:             Normal
Enable:                   Yes
Session state:            Connected
Failure reason:
Header digest:            None
Data digest:              None
MaxRecvDataSegmentLength: 262144
MaxSendDataSegmentLength: 262144
MaxBurstLen:              1048576
FirstBurstLen:            1048576
ImmediateData:            Yes
iSER (RDMA):              No
Offload driver:           None
Device nodes:             da3 da4</pre>



<p class="wp-block-paragraph">一つのセッションのみ貼り付けていますが「Session ID」が指定するセッションIDになります．<br>このセッション (ID:1) を切断するとした場合は次のように実行します．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># iscsictl -M -i 1 -e off

# iscsictl -L
Target name                          Target portal    State
iqn.2023-12.iscsi.org.seichan:target0 172.16.255.254   Disabled
iqn.2023-12.iscsi.org.seichan:target1 172.16.255.254   Connected: da2
iqn.2023-12.iscsi.org.seichan:target2 172.16.255.254   Connected: da1</pre>



<p class="wp-block-paragraph">このように，セッション1 (da3, da4) が Disabled となります．<br><strong>なお，ファイルシステムのアンマウントは先に行ってください．マウント状況にかかわらずセッションは無効化されますので，マウントしているパスへのアクセスが入った瞬間に刺さります．</strong></p>



<h3 class="wp-block-heading"><span id="toc7">セッションを再開する</span></h3>



<p class="wp-block-paragraph">無効化したセッションを再開させる場合は次のように実行します．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># iscsictl -M -i 1 -e on

# iscsictl -L
Target name                          Target portal    State
iqn.2023-12.iscsi.org.seichan:target0 172.16.255.254   Connected: da3 da4
iqn.2023-12.iscsi.org.seichan:target1 172.16.255.254   Connected: da2
iqn.2023-12.iscsi.org.seichan:target2 172.16.255.254   Connected: da1</pre>



<p class="wp-block-paragraph">セッションが再開され，Connected となり，da3, da4 が復活します．</p>



<p class="wp-block-paragraph">設定ファイルを用いずに接続・切断なども実施できるのですが，ここでは扱いません．<br>詳しく把握したい方はマニュアル「<a rel="noopener" href="http://www.koganemaru.co.jp/cgi-bin/mroff.cgi?subdir=man&amp;lc=1&amp;cmd=&amp;man=iscsictl&amp;dir=jpman-13.2.2%2Fman&amp;sect=0" target="_blank">iscsictl</a>」を参照ください．</p>



<p class="wp-block-paragraph">以上で iSCSI のターゲットとイニシエーターについての解説を一旦終わります．<br>一旦というのは，次は GEOM も合わせてのお話で引き続き iSCSI 環境を用いてやっていく予定で考えているからとなります．</p>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.seichan.org/2023/12/freebsd-%e3%81%a7-iscsi-%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b-%e3%82%af%e3%83%a9%e3%82%a4%e3%82%a2%e3%83%b3%e3%83%88-%e3%82%a4%e3%83%8b%e3%82%b7%e3%82%a8%e3%83%bc%e3%82%bf%e3%83%bc%e7%b7%a8.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>FreeBSD で iSCSI を利用する (サーバー/ターゲット編)</title>
		<link>https://www.seichan.org/2023/12/freebsd-%e3%81%a7-iscsi-%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b-%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc-%e3%82%bf%e3%83%bc%e3%82%b2%e3%83%83%e3%83%88%e7%b7%a8.html</link>
					<comments>https://www.seichan.org/2023/12/freebsd-%e3%81%a7-iscsi-%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b-%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc-%e3%82%bf%e3%83%bc%e3%82%b2%e3%83%83%e3%83%88%e7%b7%a8.html#respond</comments>
		
		<dc:creator><![CDATA[seichan]]></dc:creator>
		<pubDate>Sun, 10 Dec 2023 13:00:00 +0000</pubDate>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[iSCSI]]></category>
		<guid isPermaLink="false">https://www.seichan.org/blog/?p=933</guid>

					<description><![CDATA[FreeBSD 10.0 より，別途パッケージを導入する必要が無く，標準で iSCSI が利用できるようになりました．iSCSI は RFC 7143 で規定されている標準的なプロトコルになりますので FreeBSD に [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">FreeBSD 10.0 より，別途パッケージを導入する必要が無く，標準で iSCSI が利用できるようになりました．<br>iSCSI は RFC 7143 で規定されている標準的なプロトコルになりますので FreeBSD に限らず様々なシステムが利用する事ができます．(GEOM GATE と違って)</p>



<p class="wp-block-paragraph">今回は FreeBSD での iSCSI によるディスクの提供について纏めてみたいと思います．</p>



<ul class="wp-block-list">
<li>FreeBSD の iSCSI に関するお話
<ul class="wp-block-list">
<li><a href="https://www.seichan.org/2023/12/freebsd-%e3%81%a7-iscsi-%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b-%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc-%e3%82%bf%e3%83%bc%e3%82%b2%e3%83%83%e3%83%88%e7%b7%a8.html" target="_blank">FreeBSD で iSCSI を利用する (サーバー/ターゲット編)</a></li>



<li><a href="https://www.seichan.org/2023/12/freebsd-%e3%81%a7-iscsi-%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b-%e3%82%af%e3%83%a9%e3%82%a4%e3%82%a2%e3%83%b3%e3%83%88-%e3%82%a4%e3%83%8b%e3%82%b7%e3%82%a8%e3%83%bc%e3%82%bf%e3%83%bc%e7%b7%a8.html" target="_blank">FreeBSD で iSCSI を利用する (クライアント/イニシエーター編)</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-multipath-%e3%81%a7%e3%83%9e%e3%83%ab%e3%83%81%e3%83%91%e3%82%b9%e3%82%92%e6%a7%8b%e6%88%90%e3%81%99%e3%82%8b-1.html" target="_blank">GEOM MULTIPATH でマルチパスを構成する (1)</a></li>



<li><a href="https://www.seichan.org/2023/12/geom-multipath-%e3%81%a7%e3%83%9e%e3%83%ab%e3%83%81%e3%83%91%e3%82%b9%e3%82%92%e6%a7%8b%e6%88%90%e3%81%99%e3%82%8b-2.html">GEOM MULTIPATH でマルチパスを構成する (2)</a></li>



<li><a href="https://www.seichan.org/2023/12/freebsd-%e3%81%a7-zfs-%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b-raw%e3%83%9c%e3%83%aa%e3%83%a5%e3%83%bc%e3%83%a0%e3%82%92%e5%88%87%e3%82%8a%e5%87%ba%e3%81%99-iscsi-%e3%81%a8%e3%81%97.html" target="_blank">FreeBSD で ZFS を利用する – RAWボリュームを切り出す &amp; iSCSI として提供する</a></li>
</ul>
</li>
</ul>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-10" checked><label class="toc-title" for="toc-checkbox-10">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">そもそも iSCSI とは</a><ol><li><a href="#toc2" tabindex="0">iSCSI で出てくる用語</a></li></ol></li><li><a href="#toc3" tabindex="0">FreeBSD でターゲットを設定する</a><ol><li><a href="#toc4" tabindex="0">設定ファイルの解説</a></li><li><a href="#toc5" tabindex="0">設定ファイルの確認</a></li></ol></li><li><a href="#toc6" tabindex="0">サービスの起動</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">そもそも iSCSI とは</span></h2>



<p class="wp-block-paragraph">iSCSI は Internet Small Computer System Interface の略称で RFC 7143 で規定されています．<br>SCSI はハードディスクやテープドライブなどのデバイスを接続する為のインターフェイス規格で，これを IP 化したものが iSCSI となります．</p>



<p class="wp-block-paragraph">メリットは何といっても IP ネットワークがあれば利用可能な点です．SCSI であれば SCSI カード (SCSI HBA)，SAS であれば SAS カード (SAS HBA)，FC であれば FC カード (FC HBA) が必要です．<br>HBA はホストバスアダプター (Host Bus Adapter) の略称です．</p>



<p class="wp-block-paragraph">iSCSI はイーサネットカード/ネットワークアダプターさえあれば利用が可能ですので，導入の敷居がとても低いです．</p>



<p class="wp-block-paragraph">デメリットは，SCSI/SAS/FC のような専用のシステムに比べてパフォーマンスに劣る点になります．iSCSI の処理をソフトウェア処理 (CPU) が行う場合はその分のオーバーヘッドが発生します．<br>もっとも，最近の CPU は高性能ですのでそこまで気にする必要はないと思います．<br>ですが，ストレージメーカーの資料でも FC と iSCSI の比較の場合は明確に iSCSI のパフォーマンスが低く提示されていますので，パフォーマンスを最大限に求める場合には向かないです．</p>



<p class="wp-block-paragraph">ネットワークアダプターがあれば利用できる．がメリットでありデメリットにもなり得ます．一つのネットワークアダプターに通常のトラフィックと iSCSI トラフィックを同居させるとその分パフォーマンスに影響が生じます．<br>ですので，多くの場合は (特に企業で導入する場合) iSCSI 専用のネットワークを用意します．<br>イメージとしてはこのような形です．</p>



<figure class="wp-block-image aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="546" height="292" src="https://www.seichan.org/blog/wp-content/uploads/2023/12/image-21-546x292.png" alt="" class="wp-image-934" style="width:838px;height:auto" srcset="https://www.seichan.org/blog/wp-content/uploads/2023/12/image-21-546x292.png 546w, https://www.seichan.org/blog/wp-content/uploads/2023/12/image-21-300x160.png 300w, https://www.seichan.org/blog/wp-content/uploads/2023/12/image-21.png 686w" sizes="(max-width: 546px) 100vw, 546px" /></figure>



<p class="wp-block-paragraph">このように，iSCSI 専用のネットワークを用いる事でストレージアクセス時のパフォーマンスを担保する構成が一般的です．</p>



<h3 class="wp-block-heading"><span id="toc2">iSCSI で出てくる用語</span></h3>



<p class="wp-block-paragraph">iSCSI で出てくる用語について以下解説します．</p>



<ul class="wp-block-list">
<li>ターゲット<br>iSCSI でデバイスを提供する側を指します．iSCSI ストレージ側 (iSCSI サーバー側) です．<br>専用のストレージの場合もあれば，今回解説するような OS の機能での提供もあります．</li>



<li>イニシエーター<br>iSCSI でデバイスを利用する側を指します．iSCSI 処理をオフロードできる NIC (iSCSI HBA) もありますし，今回のような OS/アプリが提供するソフトウェア処理による方法もあります．</li>



<li>EUI<br>iSCSI のターゲット，イニシエーターの命名規則の一つで IEEE が規定している規則です．<br>イーサネットの MAC アドレスに近く，64bit で表すため EUI-64 というのが正式な名称のようです．<br>先頭の 24bit が Company ID で IEEE Registration Authority が指定しています．イーサネット MAC アドレスのベンダー ID と同等です．<br>残りの 40bit が各社が自由に設定できるフィールドになります．<br>MAC アドレスもそうですが，人が見て分かりづらい表記になります．</li>



<li>IQN<br>iSCSI Qualified Name の略称で，直訳で iSCSI の修飾名です．<br>命名規則はiqn.yyyy-mm.naming-authority:unique-name となります．例えば iqn.2023-12.org.seichan.iscsi.volume01 というような名前になります．<br>
<ul class="wp-block-list">
<li>yyyy-mm<br>命名機関が設立された年月になります．</li>



<li>naming-authority<br>命名機関のドメイン名を逆順に並べたものになります．</li>



<li>unique-name<br>任意の一意な名前です．</li>
</ul>
</li>
</ul>



<p class="wp-block-paragraph">EUI と IQN 両方ともターゲットの指定で利用できますが，ほぼほぼ IQN の利用が多いです．</p>



<h2 class="wp-block-heading"><span id="toc3">FreeBSD でターゲットを設定する</span></h2>



<p class="wp-block-paragraph">本題の，FreeBSD で iSCSI Target を設定し，そのほかのデバイスへディスク領域を提供してみます．<br>FreeBSD でターゲットを構築するという事なので，イメージはこのようになります．</p>



<figure class="wp-block-image aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="483" height="371" src="https://www.seichan.org/blog/wp-content/uploads/2023/12/image-22.png" alt="" class="wp-image-935" style="width:527px;height:auto" srcset="https://www.seichan.org/blog/wp-content/uploads/2023/12/image-22.png 483w, https://www.seichan.org/blog/wp-content/uploads/2023/12/image-22-300x230.png 300w" sizes="(max-width: 483px) 100vw, 483px" /></figure>



<p class="wp-block-paragraph">FreeBSD での iSCSI ターゲット機能は ctld というプログラムによって行われます．<br>まずは，ターゲット (サーバー) 側でデバイスを提供する設定を用意する必要がありますので，以下に例を記載します．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># cat /etc/ctl.conf
auth-group ag0 {
  chap-mutual "iscsi-user1" "Password-user1" "mutual-user" "Password-mutual"
  initiator-portal 172.16.255.0/24
}

auth-group ag1 {
  chap "iscsi-user2" "Password"
  initiator-portal 172.16.255.1/24
}

auth-group ag2 {
  auth-type none
  initiator-portal 172.16.255.1/24
}


portal-group pg0 {
  discovery-auth-group no-authentication
  listen 172.16.255.254:3260
}

target iqn.2023-12.iscsi.org.seichan:target0 {
  alias "target0"
  auth-group ag0
  portal-group pg0
  lun 0 {
    path /dev/da1
    option vendor "FreeBSD"
  }
  lun 1 {
    path /mnt/lun1.img
    option vendor "FreeBSD"
    blocksize 4096
    size 10G
  }
}

target iqn.2023-12.iscsi.org.seichan:target1 {
  alias "target1"
  auth-group ag1
  portal-group pg0
  lun 2 {
    path /mnt/lun2.img
    option vendor "FreeBSD"
    blocksize 4096
    size 10G
  }
}

target iqn.2023-12.iscsi.org.seichan:target2 {
  alias "target2"
  auth-group ag2
  portal-group pg0
  lun 3 {
    path /mnt/lun3.img
    option vendor "FreeBSD"
    blocksize 4096
    size 10G
  }
}</pre>



<h3 class="wp-block-heading"><span id="toc4">設定ファイルの解説</span></h3>



<p class="wp-block-paragraph">ちょっと長い設定ファイルを用意してしまいましたが，内容について以下に解説します．</p>



<ul class="wp-block-list">
<li>auth-group<br>iSCSI の利用には認証の有無を選択できます．「相互 CHAP」「CHAP」「認証無し」のいずれかを利用可能です．(強固な順番で記載しました．)
<ul class="wp-block-list">
<li>chap-mutual<br>相互 CHAP を利用した認証を行う方式となり，ターゲットとイニシエーター両方で認証を行います．これが一番強固なものとなります．<br>製品，ソフトウェアによってはこれが利用できないものがあるようです．</li>



<li>chap<br>CHAP を利用した認証を行う方式となり，イニシエーターからターゲットへ認証を行います．<br>通常認証有りで構成する場合に用いられる方式です</li>



<li>none<br>認証をしない方式です．initiator-portal に許可されている接続元アドレスからの要求は受け付ける形となります．<br>本来は望ましくないと考えているのですが，iSCSI 専用のネットワークを用意して導入する事が多いのですが，よくこの設定で導入，納品する事があります．</li>



<li>initiator-portal<br>接続元の許可/拒否を判定させるものとなります．サブネット単位，ホスト単位のいずれも指定が可能です．<br>今回の場合，相互 CHAP はサブネット単位，CHAP と認証無しはホスト単位として設定を用意しました．</li>
</ul>
</li>



<li>portal-group<br>iSCSI のターゲットポータルを用意する設定です．イニシエーターからの iSCSI 探索要求や接続要求にどのアドレス (インターフェイス) から受け付けるのか．や，探索時も認証を要求するのかの設定を行います．
<ul class="wp-block-list">
<li>discovery-auth-group<br>探索時の認証の有無を指定します．先に設定してある ag (auth-group) の値を用いた認証が必要な状態もしくは，今回のように認証を求めない．という設定が可能です．</li>



<li>listen<br>iSCSI ターゲットとしてどのインターフェイスを用いるかを指定しています．<br>今回は iSCSI 専用のインターフェイスを持っている想定で IPアドレスを指定している形としています．<br>全てのインターフェイスにバインドさせる場合は 0.0.0.0:3260 というような記載も可能です．</li>
</ul>
</li>



<li>target<br>提供するデバイスの詳細を記載する設定項目です．今回は幾つも例を用いる為に3つのターゲット設定を用意しています．
<ul class="wp-block-list">
<li>target iqn.xxx<br>上で説明した IQN となります．:から先がターゲット名としてイニシエーターから見えるようになります．</li>



<li>alias<br>ターゲット名を人間が判別しやすいように別名を用いる事が可能です．今回だと特段必要はないと思いますが一応付けています．</li>



<li>auth-group<br>先に定義してある，auth-group のどれを利用するか．の指定になります．</li>



<li>portal-group<br>先に定義してある，portal-group のどれを利用するか．の指定になります．</li>



<li>lun<br>iSCSI の論理ユニット番号になります．lun に付与できる ID は 0-255 となります．</li>
</ul>
</li>



<li>lun の中身について<br>iSCSI として領域を提供する方法として，デバイス全体もしくはファイルをディスク領域として提供する事が可能です．
<ul class="wp-block-list">
<li>path /dev/da1<br>このようにデバイスファイルを指定した場合はそのデバイス全体を iSCSI として提供する事になります．</li>



<li>path /mnt/lun1.img<br>このようにファイルを指定した場合は，iSCSI として提供するディスクの実態をファイルとすることが可能です．<br>付随して，提供するボリュームサイズ (ファイルサイズ) を指定します．</li>
</ul>
</li>
</ul>



<h3 class="wp-block-heading"><span id="toc5">設定ファイルの確認</span></h3>



<p class="wp-block-paragraph">作成した設定ファイルに問題がないか，確認する事が可能です．(稼働後の設定追加の場合は反映前に必須です)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># ctld -t
ctld: secret for user "iscsi-user2", auth-group "ag1", is too short; it should be at least 12 characters long
ctld: /etc/ctl.conf is world-readable</pre>



<p class="wp-block-paragraph">まず「it should be at least 12 characters long」と怒られました．CHAP のパスワード (シークレット) の文字数は12文字以上にしなさいとの事です．<br>そして一番大事な所ですが「/etc/ctl.conf is world-readable」と怒られています．これは作成したファイルのパーミッションが 644 である為，other が読める状態 (パスワードが見れる状態) である為です．</p>



<p class="wp-block-paragraph">こういった指摘を修正しましょう．<br>iscsi-user2 のパスワードを iscsi-user1 同様に修正しています．<br>world-readable は以下のとおり修正します．そうするとそこの警告は消えました．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># ctld -t
#</pre>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>



<h2 class="wp-block-heading"><span id="toc6">サービスの起動</span></h2>



<p class="wp-block-paragraph">/etc/rc.conf に次の文字を追加します</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># cat /etc/rc.conf | grep ctld
ctld_enable="YES"</pre>



<p class="wp-block-paragraph">では，サービスを実行してみましょう</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># /etc/rc.d/ctld start
Starting ctld.
ctld: LUN creation warning: error opening /mnt/lun1.img: 2
ctld: LUN creation warning: error opening /mnt/lun2.img: 2
ctld: LUN creation warning: error opening /mnt/lun3.img: 2</pre>



<p class="wp-block-paragraph">「LUN creation warning: error opening /mnt/lun1.img」などと怒られました．<br>これは事前にファイルを作っていないからとなります．<br>touch で空の構いませんので作成をしておきます．また，このサービス以外で読める必要もありませんのでパーミッションを落としておきます．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># touch /mnt/lun1.img
# touch /mnt/lun2.img
# touch /mnt/lun3.img

# chmod 600 /mnt/lun1.img
# chmod 600 /mnt/lun2.img
# chmod 600 /mnt/lun3.img</pre>



<p class="wp-block-paragraph">改めてサービスを再起動してみましょう．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># /etc/rc.d/ctld restart
Stopping ctld.
Waiting for PIDS: 944.
Starting ctld.</pre>



<p class="wp-block-paragraph">今度はエラーや警告もなくサービスが起動しました．<br>これでターゲット側の準備は完了となります．次はクライアント側の設定になります．</p>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.seichan.org/2023/12/freebsd-%e3%81%a7-iscsi-%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b-%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc-%e3%82%bf%e3%83%bc%e3%82%b2%e3%83%83%e3%83%88%e7%b7%a8.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
