-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_iscsi.txt
113 lines (79 loc) · 2.96 KB
/
test_iscsi.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
iSCSI test
- hjkim, 2022.07.19
OS: Ubuntu 20.04 LTS
Device: file (VFS)
------------------------------------------
Target (SCSI Storage)
------------------------------------------
// 1 GiB image file
$ dd if=/dev/zero of=/tmp/test.img bs=1024k count=1000
//$ sudo losetup /dev/loop0 ./test.img
// tgt conf for new device
(CREATE)
/etc/tgt/conf.d/test_img.conf
<target iqn.2022-07.test.com:lun1>
#backing-store /dev/loop0
backing-store /tmp/test.img
initiator-address <Initiator IP>
incominguser iscsi_test iscsi_test
outgoinguser iscsi_test2 iscsi_test2
</target>
$ sudo systemctl restart tgt
$ sudo tgtadm --mode target --op show
------------------------------------------
Initiator (Connect to iSCSI Target Device)
------------------------------------------
$ sudo apt-get install open-iscsi
$ sudo iscsiadm -m discovery -t st -p <Target Host IP>
<Target Host IP>:3260,1 iqn.2022-07.test.com:lun1
$ sudo vim /etc/iscsi/initiatorname.iscsi
(ADD)
InitiatorName=<Target Host IP>:3260,1 iqn.2022-07.test.com:lun1
/*
# DO NOT USE THIS
$ vim /etc/iscsi/nodes/iqn.2022-07.test.com\:lun1/<Target Host IP>,3260,1/default
(ADD or MODIFY)
#node.startup = manual
node.startup = automatic
#node.session.auth.authmethod = None
node.session.auth.authmethod = CHAP
node.session.auth.username = iscsi_test // incominguser
node.session.auth.password = iscsi_test // incominguser
node.session.auth.username_in = iscsi_test2 // incominguser
node.session.auth.password_in = iscsi_test2 // incominguser
*/
$ vim /etc/iscsi/iscsid.conf
(MODIFY)
#node.startup = manual
node.startup = automatic
#node.session.auth.authmethod = None
node.session.auth.authmethod = CHAP
node.session.auth.username = iscsi_test // incominguser
node.session.auth.password = iscsi_test // incominguser
# DO NOT USE THIS
#node.session.auth.username_in = iscsi_test2 // incominguser
#node.session.auth.password_in = iscsi_test2 // incominguser
$ sudo systemctl restart open-iscsi iscsid
//$ sudo iscsiadm -m node --login
$ sudo iscsiadm -m session -o show
tcp: [3] <Target Host IP>:3260,1 iqn.2022-07.test.com:lun1 (non-flash)
// Creates partition and mount
$ sudo fdisk -l
$ sudo fdisk /dev/sde
$ sudo mkfs.ext4 /dev/sde1
$ sudo mkdir /mnt/test_iscsi
$ sudo mount -t ext4 /dev/sde1 /mnt/test_iscsi/
------------------------------------------
delete
------------------------------------------
Reference:
- https://helpdesk.kaseya.com/hc/en-gb/articles/4407512021521-Remove-ISCSI-sessions-using-the-Linux-command-line
- https://bugzilla.redhat.com/show_bug.cgi?id=797079
$ sudo iscsiadm -m session -o show
tcp: [4] <Target Host IP>:3260,1 iqn.2022-07.test.com:lun1 (non-flash)
$ sudo iscsiadm -m node -p <Target Host IP>:3260 --logout
Logging out of session [sid: 4, target: iqn.2022-07.test.com:lun1, portal: <Target Host IP>,3260]
Logout of [sid: 4, target: iqn.2022-07.test.com:lun1, portal: <Target Host IP>,3260] successful.
$ sudo iscsiadm -m session -o show
iscsiadm: No active sessions.
__EOF__