<?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>ひろぽっぽれす &#187; bash</title>
	<atom:link href="http://hiropo.co.uk/archives/category/bash/feed" rel="self" type="application/rss+xml" />
	<link>http://hiropo.co.uk</link>
	<description>Web系エンジニアの適当なブログです。どうでも酔いものばかり作ってます。</description>
	<lastBuildDate>Sun, 25 Jul 2010 17:09:15 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Linux標準コマンドでローレベルフォーマット</title>
		<link>http://hiropo.co.uk/archives/366</link>
		<comments>http://hiropo.co.uk/archives/366#comments</comments>
		<pubDate>Sat, 30 Jan 2010 20:00:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://hiropo.co.uk/?p=366</guid>
		<description><![CDATA[ローレベルフォーマットって物理フォーマットのことなんだけど、厳密にはローレベルフォーマットって個人レベルじゃできないようです。 ここでいうローレベルフォーマットってのは、データを0の値で上書きすることをさします。0で上書きすることによって実質データの完全削除です。 0と1しかないんだから0で書いちゃえばなんもないじゃんってことです！ ってとこで、ローレベルフォーマットってツール使ったりすることが多いですが、最近はUSBやCDからブートできるubuntuとかLinuxがたくさんあるので、Linux標準のddコマンド使っちゃえばできちゃうようです。 参考サイト http://www.cybernetic-survival.net/dd.htm ウチのDELLノートちゃんのパーティションキレてるDドライブちゃんとキレイに全消ししたかったので、下記のコマンドを実行してみた。 PLAIN TEXT CODE: #dd if=/dev/zero of=/dev/sda2 デバイスは環境によってことなるのでその都度確認しないと大変なことになりますよ！ これでウチのDELLノートちゃんは無事にデータが消えやがってくれましたよ。 dd便利すな！]]></description>
			<content:encoded><![CDATA[<p>ローレベルフォーマットって物理フォーマットのことなんだけど、厳密にはローレベルフォーマットって個人レベルじゃできないようです。<br />
ここでいうローレベルフォーマットってのは、データを0の値で上書きすることをさします。0で上書きすることによって実質データの完全削除です。</p>
<p>0と1しかないんだから0で書いちゃえばなんもないじゃんってことです！</p>
<p>ってとこで、ローレベルフォーマットってツール使ったりすることが多いですが、最近はUSBやCDからブートできるubuntuとかLinuxがたくさんあるので、Linux標準のddコマンド使っちゃえばできちゃうようです。</p>
<p>参考サイト<br />
<a href="http://www.cybernetic-survival.net/dd.htm" target="_blank">http://www.cybernetic-survival.net/dd.htm</a></p>
<p>ウチのDELLノートちゃんのパーティションキレてるDドライブちゃんとキレイに全消ししたかったので、下記のコマンドを実行してみた。</p>
<div class="igBar"><span id="lcode-2"><a href="#" onclick="javascript:showCodeTxt('code-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-2">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#dd if=/dev/zero of=/dev/sda2 </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>デバイスは環境によってことなるのでその都度確認しないと大変なことになりますよ！<br />
これでウチのDELLノートちゃんは無事にデータが消えやがってくれましたよ。</p>
<p>dd便利すな！</p>
]]></content:encoded>
			<wfw:commentRss>http://hiropo.co.uk/archives/366/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>起動スクリプトの作成 /etc/rc.d/init.d/</title>
		<link>http://hiropo.co.uk/archives/313</link>
		<comments>http://hiropo.co.uk/archives/313#comments</comments>
		<pubDate>Sat, 10 Oct 2009 17:34:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://hiropo.co.uk/?p=312</guid>
		<description><![CDATA[bash、面白いよ、bash。 bashを全然使いこなせないので、ちょっと頑張ってもろもろ勉強せなあかんですなと思ったので、まずはいつも手作業で行っていた作業を自動化していくことにした。 ウチのサーバちゃんでは、sambaでファイルサーバも使っているのだが、バックアップもかねて、外部HDDをUSBでつないで、それをsamba内で管理しているディレクトリにマウントして使っている。 このマウント作業を手作業で行っていたため、マシンをリブートした時に、また再度手作業で行わなくてはいけない。毎回これはめんどくさいので、いい加減自動化しようと思ったのがことの経緯であるわけです。 外部HDDはwindowsでも使えるようにNTFSでフォーマットしてあるため、下記のコマンドでいつもマウントしている PLAIN TEXT CODE: host# mount.ntfs-3g /dev/sdb1 /home/hiroki/samba/mnt/ このコマンドをサーバが立ち上がった時に自動でブートするようにする。 /etc/rc.d/init.d/ ディレクトリにbashでスクリプトを組む。 startとstopで起動、終了を制御するため、start関数とstop関数を用意する。 PLAIN TEXT CODE: host# vi /etc/rc.d/init.d/mnt_music スクリプトの中身 PLAIN TEXT CODE: #!/bin/bash &#160; # chkconfig: 2345 97 97 # description: mnt_music &#160; start&#40;&#41;&#123; &#160; &#160; if mount.ntfs-3g /dev/sdb1 /home/hiroki/samba/mnt/; then &#160; &#160; &#160; &#160; echo "mount success!!" &#160; &#160; fi [...]]]></description>
			<content:encoded><![CDATA[<p>bash、面白いよ、bash。</p>
<p>bashを全然使いこなせないので、ちょっと頑張ってもろもろ勉強せなあかんですなと思ったので、まずはいつも手作業で行っていた作業を自動化していくことにした。</p>
<p>ウチのサーバちゃんでは、sambaでファイルサーバも使っているのだが、バックアップもかねて、外部HDDをUSBでつないで、それをsamba内で管理しているディレクトリにマウントして使っている。<br />
このマウント作業を手作業で行っていたため、マシンをリブートした時に、また再度手作業で行わなくてはいけない。毎回これはめんどくさいので、いい加減自動化しようと思ったのがことの経緯であるわけです。</p>
<p>外部HDDはwindowsでも使えるようにNTFSでフォーマットしてあるため、下記のコマンドでいつもマウントしている</p>
<div class="igBar"><span id="lcode-9"><a href="#" onclick="javascript:showCodeTxt('code-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-9">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">host# mount.<span style="">ntfs</span>-3g /dev/sdb1 /home/hiroki/samba/mnt/ </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>このコマンドをサーバが立ち上がった時に自動でブートするようにする。</p>
<p>/etc/rc.d/init.d/ ディレクトリにbashでスクリプトを組む。<br />
startとstopで起動、終了を制御するため、start関数とstop関数を用意する。</p>
<div class="igBar"><span id="lcode-10"><a href="#" onclick="javascript:showCodeTxt('code-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-10">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">host# vi /etc/rc.<span style="">d</span>/init.<span style="">d</span>/mnt_music </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>スクリプトの中身</p>
<div class="igBar"><span id="lcode-11"><a href="#" onclick="javascript:showCodeTxt('code-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-11">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#!/bin/bash</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"># chkconfig: <span style="color:#800000;color:#800000;">2345</span> <span style="color:#800000;color:#800000;">97</span> <span style="color:#800000;color:#800000;">97</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"># description: mnt_music</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">start<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; if mount.<span style="">ntfs</span>-3g /dev/sdb1 /home/hiroki/samba/mnt/; then</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; echo <span style="color:#CC0000;">"mount success!!"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; fi</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">stop<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; if umount /home/hiroki/samba/mnt/; then</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; echo <span style="color:#CC0000;">"umount success!!"</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; fi</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">case <span style="color:#CC0000;">"$1"</span> in</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; start<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; start;;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; stop<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; stop;;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">esac </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>3行目の "# chkconfig" は、chkconfigに登録できるようにする記述である。<br />
数値部分は、「ランレベル」「起動プライオリティ」「終了プライオリティ」の順である。</p>
<p>スクリプトを実行する。</p>
<div class="igBar"><span id="lcode-12"><a href="#" onclick="javascript:showCodeTxt('code-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-12">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">host# /etc/rc.<span style="">d</span>/init.<span style="">d</span>/mnt_music start</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">umount success!! </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>ランレベル3に、シンボリックリンクを登録する。</p>
<div class="igBar"><span id="lcode-13"><a href="#" onclick="javascript:showCodeTxt('code-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-13">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">host# ln -s /etc/rc.<span style="">d</span>/init.<span style="">d</span>/mnt_music /etc/rc3.<span style="">d</span>/S97mnt_music </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>chkconfigに "mnt_music" を登録し、起動時のブートを有効にする。</p>
<div class="igBar"><span id="lcode-14"><a href="#" onclick="javascript:showCodeTxt('code-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-14">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">host# chkconfig --add mnt_music</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">host# chkconfig mnt_music on </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>これで、毎回手作業でコマンドを実行することなく、自動でHDDをマウントすることができるようになった。</p>
]]></content:encoded>
			<wfw:commentRss>http://hiropo.co.uk/archives/313/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
