{"id":332,"date":"2012-04-13T09:57:10","date_gmt":"2012-04-13T01:57:10","guid":{"rendered":"http:\/\/www.sysadmindayph.com\/blog\/?p=332"},"modified":"2012-04-13T09:57:10","modified_gmt":"2012-04-13T01:57:10","slug":"how-to-detach-mirror-in-solaris-script","status":"publish","type":"post","link":"http:\/\/www.sysadmindayph.com\/blog\/how-to-detach-mirror-in-solaris-script\/","title":{"rendered":"How To Detach Mirror in Solaris &#8211; Script"},"content":{"rendered":"<p>How to detach mirror disks in Solaris? Assuming we us SVM, we normally do this like this, manually:<\/p>\n<p>metastat -c d0  (verify disk components)<br \/>\neeprom bood-device (further verify the boot disk)<br \/>\nsynch;<br \/>\nmetadetach rootdev detachdevice<\/p>\n<p>or put it a script for repetitive use and to avoice typo mistakes:<\/p>\n<p><code><br \/>\ncat detach_mirror.ksh<br \/>\n#!\/bin\/ksh<\/p>\n<p>rootdev=`df -k \/|tail -1|awk '{print $1}'|cut -d\"\/\" -f5`<br \/>\nbootdisk=`eeprom boot-device|cut -d\"=\" -f2|awk '{print $1}'`<\/p>\n<p>if [[ $bootdisk = \"disk\" || $bootdisk = \"disk0\" ]]; then<br \/>\n        detachdev=`metastat -p $rootdev|tail -2|grep -v \"t0d0\"|awk '{print $1}'`<br \/>\nelif [[ $bootdisk = \"disk1\" ]]; then<br \/>\n        detachdev=`metastat -p $rootdev|tail -2|grep -v \"t1d0\"|awk '{print $1}'`<br \/>\nelif [[ $bootdisk = \"disk2\" ]]; then<br \/>\n        detachdev=`metastat -p $rootdev|tail -2|grep -v \"t2d0\"|awk '{print $1}'`<br \/>\nelse<br \/>\n        echo \"Unknown disk to detach\"<br \/>\n        exit<br \/>\nfi<\/p>\n<p>echo \"boot-disk is $bootdisk\"<br \/>\necho \"root device is $rootdev\"<br \/>\necho \"\\nmetastat -p $rootdev\"<br \/>\nmetastat -p $rootdev<\/p>\n<p>echo \"\\ncommands:\"<br \/>\necho \"sync; metadetach $rootdev $detachdev\"<br \/>\necho \"sleep 10\"<\/p>\n<p>detachdiskname=`metastat -p $detachdev|awk '{print $NF}'`<br \/>\necho \"mkdir \/a\"<br \/>\necho \"mount \/dev\/dsk\/$detachdiskname \/a\"<br \/>\necho \"cp -p \/a\/etc\/vfstab \/a\/etc\/vfstab.md\"<\/p>\n<p>#echo awk '$1==\"\/dev\/md\/dsk\/'$rootdev'\" {print \"\/dev\/dsk\/'$detachdiskname'\\t\/dev\/rdsk\/'$detachdiskname'\\t\"$3\"\\t\"$4\"\\t\"$5\"\\t\"$6\"\\t\"$7; next} {print}' \/etc\/vfstab<br \/>\necho \"awk '\\$1==\\\"\/dev\/md\/dsk\/$rootdev\\\" {print \\\"\/dev\/dsk\/$detachdiskname\\\\\\t\/dev\/rdsk\/$detachdiskname\\\\\\t\\\"\\$3\\\"\\\\\\t\\\"\\$4\\\"\\\\\\t\\\"\\$5\\\"\\\\\\t\\\"\\$6\\\"\\\\\\t\\\"\\$7; next} {print}' \/etc\/vfstab\" \\> \/a\/etc\/vfstab<br \/>\necho \"egrep -v \\\"rootdev.*md|MDD root info\\\" \/etc\/system > \/a\/etc\/system\"<\/p>\n<p>echo \"\\ncd \/\"<br \/>\necho \"umount \/a\"<br \/>\necho \"rmdir \/a\"<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to detach mirror disks in Solaris? Assuming we us SVM, we normally do this like this, manually: metastat -c d0 (verify disk components) eeprom bood-device (further verify the boot disk) synch; metadetach rootdev detachdevice &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[212,5],"tags":[],"class_list":["post-332","post","type-post","status-publish","format-standard","hentry","category-script","category-solaris"],"_links":{"self":[{"href":"http:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/posts\/332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/comments?post=332"}],"version-history":[{"count":1,"href":"http:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/posts\/332\/revisions"}],"predecessor-version":[{"id":333,"href":"http:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/posts\/332\/revisions\/333"}],"wp:attachment":[{"href":"http:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/media?parent=332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/categories?post=332"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.sysadmindayph.com\/blog\/wp-json\/wp\/v2\/tags?post=332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}