unix:linux:iscsi_tricks_and_techniques
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| unix:linux:iscsi_tricks_and_techniques [2019/08/14 19:43] – rodolico | unix:linux:iscsi_tricks_and_techniques [2025/11/27 17:15] (current) – [Resizing your target] rodolico | ||
|---|---|---|---|
| Line 30: | Line 30: | ||
| <code perl addAlliSCSIS.pl> | <code perl addAlliSCSIS.pl> | ||
| - | #! / | + | #! /usr/bin/env perl |
| - | my @servers = ( '10.5.136.1' ); | + | use strict; |
| + | use warnings; | ||
| + | |||
| + | # change following to be a list of 1 or more iSCSI targets to be queried | ||
| + | my @servers = ( '10.10.10.10',' | ||
| my %targets; | my %targets; | ||
| foreach my $server ( @servers ) { | foreach my $server ( @servers ) { | ||
| + | print " | ||
| my @list = `iscsiadm -m discovery -t st -p $server`; | my @list = `iscsiadm -m discovery -t st -p $server`; | ||
| chomp @list; | chomp @list; | ||
| Line 50: | Line 55: | ||
| # only add them if they are in this IP | # only add them if they are in this IP | ||
| $targets{ $targetName } = $portal if $portal =~ m/ | $targets{ $targetName } = $portal if $portal =~ m/ | ||
| + | print " | ||
| } | } | ||
| } | } | ||
| + | print " | ||
| # now, get active sessions so we can filter them | # now, get active sessions so we can filter them | ||
| my @activeSessions = `iscsiadm -m session`; | my @activeSessions = `iscsiadm -m session`; | ||
| chomp @activeSessions; | chomp @activeSessions; | ||
| - | foreach $session ( @activeSessions ) { | + | foreach |
| - | | + | |
| my ( $portal, | my ( $portal, | ||
| - | delete | + | print "$portal\t$targetName"; |
| + | if ( exists( $targets{$targetName} ) ) { | ||
| + | print "\tNOT updating\n" | ||
| + | delete $targets{ $targetName }; | ||
| + | } else { | ||
| + | print "Needs to be added\n"; | ||
| + | } | ||
| } | } | ||
| Line 74: | Line 87: | ||
| } | } | ||
| # print `ls / | # print `ls / | ||
| + | |||
| </ | </ | ||
| Line 107: | Line 121: | ||
| </ | </ | ||
| - | Edit / | + | Edit / |
| < | < | ||
| Line 115: | Line 129: | ||
| </ | </ | ||
| Restart iet | Restart iet | ||
| - | <code bash> | + | <code bash>/ |
| + | service ctld reload # FreeBSD | ||
| + | </ | ||
| ==== Adding new target to initiator ==== | ==== Adding new target to initiator ==== | ||
| Line 147: | Line 163: | ||
| Ok, you messed up and the target is too small. If you are using LVM2 partitions for your exports (good idea), simply take it offline on the initiators, then add space on the target. Now (and I'm not sure this is required), restart iscsi on the target. | Ok, you messed up and the target is too small. If you are using LVM2 partitions for your exports (good idea), simply take it offline on the initiators, then add space on the target. Now (and I'm not sure this is required), restart iscsi on the target. | ||
| - | When you modify | + | However, I generally use a FreeBSD |
| + | |||
| + | <WRAP center round alert 60%> | ||
| + | Warning: Do not allow anything | ||
| + | </ | ||
| + | |||
| + | |||
| + | === On FreeBSD target === | ||
| <code bash> | <code bash> | ||
| - | # log out, then back into target | + | # set the new size on the target |
| - | iscsiadm -m node --target='name of target' --portal " | + | zfs set quota=< |
| + | # let ctld know about the change. reload may work instead | ||
| + | service ctld restart | ||
| </ | </ | ||
| - | The size of the target | + | |
| + | === On initiator === | ||
| + | |||
| + | You now need to rescan the target from the initiators. | ||
| + | <code bash> | ||
| + | # probably not the best, since it rescans everything. | ||
| + | # see next code block. | ||
| + | iscsiadm -m session --rescan | ||
| + | </ | ||
| + | |||
| + | Better to only scan the one you actually changed. This assumes the target has the substring //thing1// in it. | ||
| + | |||
| + | <code bash> | ||
| + | # find the Session ID of the target | ||
| + | # NOTE: that you can just do iscsiadm -m session for the whole | ||
| + | # list and manually find the SID (number surrounded by square brackets) | ||
| + | iscsiadm -m session -P 0 | grep thing1 | cut -d' | ||
| + | # now, rescan only that SID (that one target) | ||
| + | iscsiadm --mode session --sid=15 --rescan | ||
| + | # use any tool you like to check the new size. I use fdisk -l, which will | ||
| + | # return the size on the first line | ||
| + | fdisk -l /dev/disk/by-path/ip-..... | ||
| + | </code> | ||
| + | |||
| + | At this point, | ||
| ==== Remove a target ==== | ==== Remove a target ==== | ||
| Line 162: | Line 211: | ||
| # first, log out of the session | # first, log out of the session | ||
| iscsiadm -m node --target=' | iscsiadm -m node --target=' | ||
| - | # now, do a discovery and delete the entry from your local database | + | # now, do a remove it from the session |
| - | iscsiadm -m discovery | + | iscsiadm -m node --target=' |
| </ | </ | ||
unix/linux/iscsi_tricks_and_techniques.1565829800.txt.gz · Last modified: 2019/08/14 19:43 by rodolico
