<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Otmanix' Blog &#187; fmthard</title>
	<atom:link href="http://otmanix.de/tag/fmthard/feed/" rel="self" type="application/rss+xml" />
	<link>http://otmanix.de</link>
	<description>Wissenswertes und Belangloses aus dem Leben eines Admins</description>
	<lastBuildDate>Thu, 26 Apr 2012 22:39:02 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Automatisiertes Schreiben von disk label unter Solaris</title>
		<link>http://otmanix.de/2009/03/18/automatisiertes-schreiben-von-disk-label-unter-solaris/</link>
		<comments>http://otmanix.de/2009/03/18/automatisiertes-schreiben-von-disk-label-unter-solaris/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 20:16:11 +0000</pubDate>
		<dc:creator>otmanix</dc:creator>
				<category><![CDATA[OpenSolaris]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[fmthard]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[prtvtoc]]></category>
		<category><![CDATA[svm]]></category>

		<guid isPermaLink="false">http://otmanix.de/?p=1133</guid>
		<description><![CDATA[Wer unter Solaris mit UFS-Filesystemen arbeitet muss vor der Benutzung einer Platte selbige mit einem disk label (vtoc bzw. Partitionstabelle) versehen. Dazu startet man den Befehl &#8220;format&#8221;, w&#228;hlt die gew&#252;nschte Disk aus, &#228;ndert unter &#8220;partition&#8221; die Gr&#246;&#223;en f&#252;r die Partitionen, &#8230; <a href="http://otmanix.de/2009/03/18/automatisiertes-schreiben-von-disk-label-unter-solaris/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Wer unter Solaris mit UFS-Filesystemen arbeitet muss vor der Benutzung einer Platte selbige mit einem disk label (vtoc bzw. Partitionstabelle) versehen. Dazu startet man den Befehl &#8220;format&#8221;, w&#228;hlt die gew&#252;nschte Disk aus, &#228;ndert unter &#8220;partition&#8221; die Gr&#246;&#223;en f&#252;r die Partitionen, speichert das mit &#8220;label&#8221; und beendet das Programm mit &#8220;quit&#8221;.</p>
<pre>root@server # <strong>format</strong>
Searching for disks...done

AVAILABLE DISK SELECTIONS:
       0. c0t0d0 &lt;SUN36G cyl 24620 alt 2 hd 27 sec 107&gt;
          /ssm@0,0/pci@1a,700000/pci@1/SUNW,isptwo@4/sd@0,0
       1. c1t0d0 &lt;SUN36G cyl 24620 alt 2 hd 27 sec 107&gt;
          /ssm@0,0/pci@1b,700000/pci@1/SUNW,isptwo@4/sd@0,0
       2. c2t40d41 &lt;EMC-SYMMETRIX-5772 cyl 49598 alt 2 hd 30 sec 128&gt;
          /ssm@0,0/pci@1a,600000/pci@1/lpfc@4/sd@28,29
...</pre>
<pre>Specify disk (enter its number): <strong>0</strong>
selecting c0t0d0
[disk formatted]

FORMAT MENU:
        disk       - select a disk
        type       - select (define) a disk type
        partition  - select (define) a partition table
        current    - describe the current disk
        format     - format and analyze the disk
        repair     - repair a defective sector
        label      - write label to the disk
        analyze    - surface analysis
        defect     - defect list management
        backup     - search for backup labels
        verify     - read and display labels
        save       - save new disk/partition definitions
        inquiry    - show vendor, product and revision
        volname    - set 8-character volume name
        !&lt;cmd&gt;     - execute &lt;cmd&gt;, then return
        quit
format&gt; <strong>partition</strong>

PARTITION MENU:
        0      - change `0' partition
        1      - change `1' partition
        2      - change `2' partition
        3      - change `3' partition
        4      - change `4' partition
        5      - change `5' partition
        6      - change `6' partition
        7      - change `7' partition
        select - select a predefined table
        modify - modify a predefined partition table
        name   - name the current table
        print  - display the current table
        label  - write partition map and label to the disk
        !&lt;cmd&gt; - execute &lt;cmd&gt;, then return
        quit
partition&gt; <strong>print</strong>
Current partition table (original):
Total disk cylinders available: 24620 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders         Size            Blocks
  0       root    wm       0 -  6812        9.39GB    (6813/0/0)  19682757
  1       swap    wu    6813 - 21330       20.00GB    (14518/0/0) 41942502
  2     backup    wm       0 - 24619       33.92GB    (24620/0/0) 71127180
  3 unassigned    wm       0                0         (0/0/0)            0
  4 unassigned    wm       0                0         (0/0/0)            0
  5        var    wm   21331 - 24233        4.00GB    (2903/0/0)   8386767
  6 unassigned    wm   24234 - 24596      512.06MB    (363/0/0)    1048707
  7 unassigned    wm   24597 - 24619       32.44MB    (23/0/0)       66447

partition&gt; <strong>quit</strong>

FORMAT MENU:
        disk       - select a disk
        type       - select (define) a disk type
        partition  - select (define) a partition table
        current    - describe the current disk
        format     - format and analyze the disk
        repair     - repair a defective sector
        label      - write label to the disk
        analyze    - surface analysis
        defect     - defect list management
        backup     - search for backup labels
        verify     - read and display labels
        save       - save new disk/partition definitions
        inquiry    - show vendor, product and revision
        volname    - set 8-character volume name
        !&lt;cmd&gt;     - execute &lt;cmd&gt;, then return
        quit
format&gt; <strong>quit</strong></pre>
<p>Im Bereich &#8220;partition&#8221; kann man mit &#8220;print&#8221; die aktuelle Partitionstabelle ansehen. Bei neuen Platten wird ein Standardvorschlag zur Partitionierung angezeigt, der nat&#252;rlich abge&#228;ndert werden kann. Wird dies nicht getan und trotzdem &#8220;label&#8221; ausgef&#252;hrt, wird dieser default-label geschrieben.</p>
<p>Hat man nun die Aufgabe eine gr&#246;&#223;ere Anzahl Platten zu partitionieren m&#246;chte man dann den Vorgang doch irgendwie automatisieren. Dazu gibt es die Tools prtvtoc und fmthard. Mit prtvtoc kann die Partitionstabelle einer Platte als Text in genormter Form ausgegeben werden.</p>
<pre>root@server # <strong>prtvtoc /dev/rdsk/c0t0d0s0</strong></pre>
<pre>* /dev/rdsk/c0t0d0s2 partition map</pre>
<pre>*</pre>
<pre>* Dimensions:</pre>
<pre>*     512 bytes/sector</pre>
<pre>*     107 sectors/track</pre>
<pre>*      27 tracks/cylinder</pre>
<pre>*    2889 sectors/cylinder</pre>
<pre>*   24622 cylinders</pre>
<pre>*   24620 accessible cylinders</pre>
<pre>*</pre>
<pre>* Flags:</pre>
<pre>*   1: unmountable</pre>
<pre>*  10: read-only</pre>
<pre>*</pre>
<pre>*                          First     Sector    Last</pre>
<pre>* Partition  Tag  Flags    Sector     Count    Sector  Mount Directory</pre>
<pre>       0      2    00          0  19682757  19682756</pre>
<pre>       1      3    01   19682757  41942502  61625258</pre>
<pre>       2      5    00          0  71127180  71127179</pre>
<pre>       5      7    00   61625259   8386767  70012025</pre>
<pre>       6      0    00   70012026   1048707  71060732</pre>
<pre>       7      0    00   71060733     66447  71127179</pre>
<p>Diese Ausgabe l&#228;&#223;t sich nun als Vorlage nutzen um Platten mit &#8220;fmthard&#8221; zu partitionieren. Sinn ergibt das nat&#252;rlich nur bei Disks mit gleicher Gr&#246;&#223;e.</p>
<pre>prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c1t0d0s2</pre>
<p>Dummerweise bekommt man nun ziemlich wahrscheinlich einen I/O-error beim Schreiben der Partitionstabelle auf die zweite Platte (wenn diese neu ist). Hier des R&#228;tsels L&#246;sung:</p>
<p><em>manpage zu &#8220;fmthard</em>&#8221;</p>
<blockquote><p>For disks under one terabyte, fmthard cannot write a VTOC on an unlabeled disk. Use format(1M) for this purpose.<br />
SunOS 5.10          Last change: 11 Apr 2005</p></blockquote>
<p>Na klasse, da l&#228;&#223;t sich das Tool zum Automatisieren in der Masse der Anwendungsf&#228;lle also nicht nutzen. Weniger bekannt ist der folgende Workaround:</p>
<p>Man automatisiert das Schreiben eines Standard disk label mit &#8220;Format&#8221; und benutzt im Anschluss wie oben gezeigt &#8220;prtvtoc&#8221; und &#8220;fmthard&#8221; (&#252;blicherweise wird immer die Slice 2 angegeben, da diese per Definition die komplette Disk umfassen sollte!).</p>
<pre class="MsoNormal">echo label &gt; /tmp/input
echo quit &gt;&gt; /tmp/input
format -d c1t0d0  -f /tmp/input
prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c1t0d0s2</pre>
<p>Um eine gr&#246;&#223;ere Zahl Disks zu partitionieren schreibt man ein kleines Skript:</p>
<pre>cd /dev/rdsk/
echo label &gt; /tmp/input
echo quit &gt;&gt; /tmp/input
DISKS=$(ls c4t50d*s2|sed 's/s2//')
export DISKS
for i in $DISKS
do
format -d $i -f /tmp/input
done</pre>
<p>In diesem Beispiel werden alle LUNs am Controller 4 / Target 50 mit einem Standard disk label versehen.</p>
<p>Danach kann man z.B. das Partitionslayout einer Platte auf alle neuen Platten &#252;bertragen:</p>
<pre>for i in $DISKS
do
prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/${i}s2
done</pre>
<p>Alternativ k&#246;nnte man aber auch die neuen Platten einem Diskset hinzuf&#252;gen:</p>
<pre>for i in $DISKS
do
<span lang="EN-US">metaset -s oradb -a $i</span>
done</pre>
<p>P.S.</p>
<p>Die Skripte kann man nat&#252;rlich noch sch&#246;ner schreiben. Ich will hier nur das Prinzip zeigen&#8230;</p>
<p>Hier noch etwas Lesestoff: <a href="http://docs.sun.com/app/docs/doc/817-5093/disksprep-103?a=view">http://docs.sun.com/app/docs/doc/817-5093/disksprep-103?a=view</a></p>
]]></content:encoded>
			<wfw:commentRss>http://otmanix.de/2009/03/18/automatisiertes-schreiben-von-disk-label-unter-solaris/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

