Tools installation
yum install targetcli sg3_utils
Create loopback scsi target
modprobe tcm_loop
mount -t configfs configfs /sys/kernel/config/
mkdir -p /disks
targetcli backstores/fileio create disk1 /disks/disk.img 1G
targetcli loopback/ create 50014051998a423d
targetcli loopback/naa.50014051998a423d/luns create /backstores/fileio/disk1
System preparation for executing SCSI persistent reservation
mkdir -p /etc/target/pr
Clean up
targetcli loopback/ delete 50014057c28948ab
targetcli backstores/fileio delete disk1
Test scsi reservation
sg_persist -i -k /dev/sda
LIO-ORG disk1 4.0
Peripheral device type: disk
PR generation=0x0, there are NO registered reservation keys
sg_persist -o -G --param-sark=12345678 /dev/sda
LIO-ORG disk1 4.0
Peripheral device type: disk
sg_persist -i -k /dev/sda
LIO-ORG disk1 4.0
Peripheral device type: disk
PR generation=0x1, 1 registered reservation key follows:
0x12345678
sg_persist -o -R --prout-type 5 --param-rk=12345678 /dev/sda
LIO-ORG disk1 4.0
Peripheral device type: disk
sg_persist -i -k /dev/sda
LIO-ORG disk1 4.0
Peripheral device type: disk
PR generation=0x1, 1 registered reservation key follows:
0x12345678
sg_persist -i -r /dev/sda
LIO-ORG disk1 4.0
Peripheral device type: disk
PR generation=0x1, Reservation follows:
Key=0x12345678
scope: LU_SCOPE, type: Write Exclusive, registrants only
sg_persist -o -L --prout-type 5 --param-rk=12345678 /dev/sda
LIO-ORG disk1 4.0
Peripheral device type: disk