NetApp and Linux: Difference between revisions
From Lolly's Wiki
Jump to navigationJump to search
(→Links) |
No edit summary |
||
Line 22: | Line 22: | ||
Partition 2 does not matter because it is just metadata of partitioning. We are aligned! | 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>: | |||
<source lang=bash> | |||
( sanlun lun show -p <filer> ; echo ) | gawk ' | |||
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; | |||
} | |||
' | |||
</source> | |||
==Links== | ==Links== | ||
* [https://kb.netapp.com/index?page=content&id=3011193 NetApp KB ID: 3011193 - What is an unaligned I/O?] | * [https://kb.netapp.com/index?page=content&id=3011193 NetApp KB ID: 3011193 - What is an unaligned I/O?] |
Revision as of 11:44, 24 May 2019
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>:
( sanlun lun show -p <filer> ; echo ) | gawk '
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;
}
'