Solved How to fix device name for iscsi disk

I am using 2 or more iscsi disk in FreeBSD.

I dont know how to fix the device name to particular disk.

For example:


Target name Target portal State
iqn.2017-08.freenas:freebsd02 192.168.1.1 Connected: da3
iqn.2017-08.freenas:freebsd01 192.168.1.2 Connected: da4


The da3 and da4 were assigned by FreeBSD automatically.

I guess the number could be changed by booting. for example in case the target freebsd02 no connection then freebsd01 would be assigned to da3 instead of da4.

can I have a way to assign them the fixed device name?
 
You can achieve this by labeling your disks with geom-glabel.
Then you can address your drives /dev/da0 ... as /dev/label/xxx.
The label will not change in between reboots.
 
You can achieve this by labeling your disks with geom-glabel.
Then you can address your drives /dev/da0 ... as /dev/label/xxx.
The label will not change in between reboots.
I dont think it would work since my problem is that one iscsi disk would be load as da0 or da1. I could not control it.
To label da0 would not solve problem.
 
The device names are irrelevant if you refer to the labels, the labels will always be the same, regardless if the disk is actually da0, da1 or even da99.
 
Sorry to Duffyx, I made mistake.

But the glabel is not working. Maybe not available for iSCSI disk?

Code:
$ sudo glabel label idata1 /dev/da4
glabel: Can't store metadata on /dev/da4: Operation not permitted.

$ sudo glabel label idata2 /dev/da4p1
glabel: Can't store metadata on /dev/da4p1: Operation not permitted.

da4p1 was mounted as:
Code:
/dev/da4p1 on /foo (ufs, local, soft-updates)
 
If you are using GPT to partition the disk, then don't use glabel(8). Instead, use gpart(8) to label the GPT partition directly (it's built-in to GPT).

Code:
# umount /dev/da4p1
# umount /dev/da3p1
# gpart modify -i 1 -l idata1 da4
# gpart modify -i 1 -l idata2 da3
# mount /dev/gpt/idata1 /foo1
# mount /dev/gpt/idata2 /foo2
The -i 1 tells it to modify the first partition. The -l idata* tells it to add a label to that partition.

GPT labels create device nodes under /dev/gpt so you can reference those anywhere you would normally reference the disk device.

You can view the partition table with # gpart show da4 and you can view the labels with # gpart show -l da4
 
If you are using GPT to partition the disk, then don't use glabel(8). Instead, use gpart(8) to label the GPT partition directly (it's built-in to GPT).

Code:
# umount /dev/da4p1
# umount /dev/da3p1
# gpart modify -i 1 -l idata1 da4
# gpart modify -i 1 -l idata2 da3
# mount /dev/gpt/idata1 /foo1
# mount /dev/gpt/idata2 /foo2
The -i 1 tells it to modify the first partition. The -l idata* tells it to add a label to that partition.

GPT labels create device nodes under /dev/gpt so you can reference those anywhere you would normally reference the disk device.

You can view the partition table with # gpart show da4 and you can view the labels with # gpart show -l da4

Thanks, it is working fine.
 
Back
Top