NetApp and Linux: Difference between revisions
From Lolly's Wiki
Jump to navigationJump to search
No edit summary |
m (Text replacement - "</source" to "</syntaxhighlight") |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[ | [[Category:NetApp|Linux]] | ||
[[ | [[Category:Linux|NetApp]] | ||
==Check partitioning== | ==Check partitioning== | ||
Maybe this works: | Maybe this works: | ||
< | <syntaxhighlight lang=bash> | ||
# fdisk -l /dev/sda | awk '/^\/dev\//{fieldnum=2;if($fielnum=="*"){fieldnum++}blockalign=$fieldnum/8;if(blockalign!=int(blockalign)){match($0,$fieldnum);printf "%s <<<<<<< Bucket %d\n",substr($0,0,RSTART-2)"_"substr($0,RSTART,RLENGTH)"_"substr($0,RSTART+RLENGTH+1),8*(blockalign-int(blockalign));}else{print $0;}next;}{print;}' | # fdisk -l /dev/sda | awk '/^\/dev\//{fieldnum=2;if($fielnum=="*"){fieldnum++}blockalign=$fieldnum/8;if(blockalign!=int(blockalign)){match($0,$fieldnum);printf "%s <<<<<<< Bucket %d\n",substr($0,0,RSTART-2)"_"substr($0,RSTART,RLENGTH)"_"substr($0,RSTART+RLENGTH+1),8*(blockalign-int(blockalign));}else{print $0;}next;}{print;}' | ||
Line 19: | Line 19: | ||
/dev/sda5 13674496 25391103 5858304 83 Linux | /dev/sda5 13674496 25391103 5858304 83 Linux | ||
/dev/sda6 25393152 33552383 4079616 82 Linux swap / Solaris | /dev/sda6 25393152 33552383 4079616 82 Linux swap / Solaris | ||
</ | </syntaxhighlight> | ||
Partition 2 does not matter because it is just metadata of partitioning. We are aligned! | |||
==Remove multipath LUNs== | |||
This writes out the commands to delete multipathed devices for filer <filer> (empty volumes parameter to gawk means all volumes): | |||
<syntaxhighlight lang=bash> | |||
( sanlun lun show -p <filer> ; echo ) | gawk -v volumes="/vol/vol1:/vol/vol2"' | |||
BEGIN { | |||
split(volumes,vols,":"); | |||
} | |||
/ONTAP Path:/,/^$/ { | |||
if(/ONTAP Path:/){ | |||
opath=$NF; | |||
if (volumes==""){ | |||
todelete="yes"; | |||
}else{ | |||
odev=$NF; | |||
gsub(/^.*:/,"",odev); | |||
for(vol in vols){ | |||
if (odev == vols[vol] || volumes==""){ | |||
todelete="yes"; | |||
} | |||
} | |||
} | |||
} | |||
if(todelete!="yes")next; | |||
if(/Host Device:/){ | |||
command="dmsetup info --columns --noheadings -o open /dev/mapper/"$NF; | |||
command | getline inuse; | |||
close(command); | |||
if (inuse!=0) { | |||
printf "#\n## Device %s (%s) is in use!!!\n## check with: lsof | grep \"$(dmsetup info --columns --noheadings --separator \",\" -omajor,minor /dev/mapper/%s)\"\n#\n",$NF,opath,$NF; | |||
} else { | |||
printf "multipath -w %s\n",$NF; | |||
printf "multipath -f /dev/mapper/%s && (\n",$NF; | |||
} | |||
}; | |||
if(inuse==0 && $2 ~ /(primary|secondary)/){ | |||
printf "echo 1 > /sys/block/%s/device/delete\n",$3; | |||
} | |||
if (inuse==0 && /^$/) { printf ")\n";} | |||
} | |||
/^$/ { | |||
mpathdevice=""; | |||
todelete="no"; | |||
delete devices; | |||
} | |||
' | |||
</syntaxhighlight> | |||
==Links== | |||
* [https://kb.netapp.com/index?page=content&id=3011193 NetApp KB ID: 3011193 - What is an unaligned I/O?] |
Latest revision as of 22:33, 25 November 2021
Check partitioning
Maybe this works:
# fdisk -l /dev/sda | awk '/^\/dev\//{fieldnum=2;if($fielnum=="*"){fieldnum++}blockalign=$fieldnum/8;if(blockalign!=int(blockalign)){match($0,$fieldnum);printf "%s <<<<<<< Bucket %d\n",substr($0,0,RSTART-2)"_"substr($0,RSTART,RLENGTH)"_"substr($0,RSTART+RLENGTH+1),8*(blockalign-int(blockalign));}else{print $0;}next;}{print;}'
Disk /dev/sda: 17.2 GB, 17179869184 bytes
64 heads, 32 sectors/track, 16384 cylinders, total 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d6bea
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 13672447 6835200 83 Linux
/dev/sda2 _13674494_ 33552383 9938945 5 Extended <<<<<<< Bucket 6
/dev/sda5 13674496 25391103 5858304 83 Linux
/dev/sda6 25393152 33552383 4079616 82 Linux swap / Solaris
Partition 2 does not matter because it is just metadata of partitioning. We are aligned!
Remove multipath LUNs
This writes out the commands to delete multipathed devices for filer <filer> (empty volumes parameter to gawk means all volumes):
( sanlun lun show -p <filer> ; echo ) | gawk -v volumes="/vol/vol1:/vol/vol2"'
BEGIN {
split(volumes,vols,":");
}
/ONTAP Path:/,/^$/ {
if(/ONTAP Path:/){
opath=$NF;
if (volumes==""){
todelete="yes";
}else{
odev=$NF;
gsub(/^.*:/,"",odev);
for(vol in vols){
if (odev == vols[vol] || volumes==""){
todelete="yes";
}
}
}
}
if(todelete!="yes")next;
if(/Host Device:/){
command="dmsetup info --columns --noheadings -o open /dev/mapper/"$NF;
command | getline inuse;
close(command);
if (inuse!=0) {
printf "#\n## Device %s (%s) is in use!!!\n## check with: lsof | grep \"$(dmsetup info --columns --noheadings --separator \",\" -omajor,minor /dev/mapper/%s)\"\n#\n",$NF,opath,$NF;
} else {
printf "multipath -w %s\n",$NF;
printf "multipath -f /dev/mapper/%s && (\n",$NF;
}
};
if(inuse==0 && $2 ~ /(primary|secondary)/){
printf "echo 1 > /sys/block/%s/device/delete\n",$3;
}
if (inuse==0 && /^$/) { printf ")\n";}
}
/^$/ {
mpathdevice="";
todelete="no";
delete devices;
}
'