NetApp and Linux

From Lolly's Wiki
Revision as of 22:11, 25 November 2021 by Lollypop (talk | contribs) (Text replacement - "<source" to "<syntaxhighlight")
Jump to navigationJump to search

Check partitioning

Maybe this works: <syntaxhighlight lang=bash>

  1. 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 </source>

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;

} ' </source>

Links