anduin revised this gist . Go to revision
1 file changed, 3 insertions, 3 deletions
mount.sh
@@ -12,7 +12,7 @@ echo " | |||
12 | 12 | initiator-address 10.0.0.3 | |
13 | 13 | initiator-address 10.0.0.4 # Add more if needed. These are the IPs of the clients | |
14 | 14 | incominguser iscsi-user password | |
15 | - | outgoinguser iscsi-user password | |
15 | + | outgoinguser iscsi-target secretpass | |
16 | 16 | </target>" | tee /etc/tgt/conf.d/iscsi.conf | |
17 | 17 | ||
18 | 18 | systemctl restart tgt | |
@@ -34,8 +34,8 @@ echo " | |||
34 | 34 | node.session.auth.authmethod = CHAP | |
35 | 35 | node.session.auth.username = iscsi-user | |
36 | 36 | node.session.auth.password = password | |
37 | - | node.session.auth.username_in = iscsi-user | |
38 | - | node.session.auth.password_in = password | |
37 | + | node.session.auth.username_in = iscsi-target | |
38 | + | node.session.auth.password_in = secretpass | |
39 | 39 | node.startup = automatic" | tee /etc/iscsi/nodes/iqn.2024-03.iscsi.server\:lun1/10.0.0.1\,3260\,1/default | |
40 | 40 | systemctl restart open-iscsi iscsid | |
41 | 41 | iscsiadm -m session -o show |
anduin revised this gist . Go to revision
1 file changed, 1 insertion, 1 deletion
mount.sh
@@ -36,7 +36,7 @@ node.session.auth.username = iscsi-user | |||
36 | 36 | node.session.auth.password = password | |
37 | 37 | node.session.auth.username_in = iscsi-user | |
38 | 38 | node.session.auth.password_in = password | |
39 | - | node.startup = automatic" | tee /etc/iscsi/nodes/iqn.2024-03.iscsi.server\:lun1/ | |
39 | + | node.startup = automatic" | tee /etc/iscsi/nodes/iqn.2024-03.iscsi.server\:lun1/10.0.0.1\,3260\,1/default | |
40 | 40 | systemctl restart open-iscsi iscsid | |
41 | 41 | iscsiadm -m session -o show | |
42 | 42 | lsblk |
anduin revised this gist . Go to revision
1 file changed, 42 insertions
mount.sh(file created)
@@ -0,0 +1,42 @@ | |||
1 | + | # Ubuntu install ISCSI Server | |
2 | + | # Assuming the IP of the server is 10.0.0.1 | |
3 | + | ||
4 | + | # Mount a disk as /dev/sdb first | |
5 | + | apt install tgt -y | |
6 | + | ||
7 | + | # Edit /etc/tgt/conf.d/iscsi.conf | |
8 | + | echo " | |
9 | + | <target iqn.2024-03.iscsi.server:lun1> | |
10 | + | backing-store /dev/sdb | |
11 | + | initiator-address 10.0.0.2 | |
12 | + | initiator-address 10.0.0.3 | |
13 | + | initiator-address 10.0.0.4 # Add more if needed. These are the IPs of the clients | |
14 | + | incominguser iscsi-user password | |
15 | + | outgoinguser iscsi-user password | |
16 | + | </target>" | tee /etc/tgt/conf.d/iscsi.conf | |
17 | + | ||
18 | + | systemctl restart tgt | |
19 | + | tgtadm --mode target --op show | |
20 | + | ||
21 | + | # Ubuntu install ISCSI Client | |
22 | + | # Assuming the IP of the server is 10.0.0.2 | |
23 | + | ||
24 | + | apt install open-iscsi -y | |
25 | + | iscsiadm -m discovery -t sendtargets -p 10.0.0.1 # This IP is the server IP | |
26 | + | # You should see: | |
27 | + | # 10.0.0.2:3260,1 iqn.2024-03.iscsi.server:lun1 | |
28 | + | ||
29 | + | # Edit /etc/iscsi/initiatorname.iscsi | |
30 | + | echo "InitiatorName=iqn.2024-03.iscsi.server:lun1" | tee /etc/iscsi/initiatorname.iscsi | |
31 | + | ||
32 | + | # Edit /etc/iscsi/nodes/iqn.2024-03.iscsi.server\:lun1/10.0.0.1\,3260\,1/default | |
33 | + | echo " | |
34 | + | node.session.auth.authmethod = CHAP | |
35 | + | node.session.auth.username = iscsi-user | |
36 | + | node.session.auth.password = password | |
37 | + | node.session.auth.username_in = iscsi-user | |
38 | + | node.session.auth.password_in = password | |
39 | + | node.startup = automatic" | tee /etc/iscsi/nodes/iqn.2024-03.iscsi.server\:lun1/ | |
40 | + | systemctl restart open-iscsi iscsid | |
41 | + | iscsiadm -m session -o show | |
42 | + | lsblk |