<?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>systemBash &#187; Shell</title>
	<atom:link href="http://systembash.com/tags/code-samples/shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://systembash.com</link>
	<description>Technology and System Administration</description>
	<lastBuildDate>Fri, 13 Jan 2012 03:18:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>What a Resilver Looks Like in ZFS (and a Bug and/or Feature)</title>
		<link>http://systembash.com/content/what-a-resilver-looks-like-in-zfs/</link>
		<comments>http://systembash.com/content/what-a-resilver-looks-like-in-zfs/#comments</comments>
		<pubDate>Sun, 15 May 2011 12:16:08 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[RAID]]></category>
		<category><![CDATA[zfs]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=974</guid>
		<description><![CDATA[At home I have an (admittedly small) ZFS array set up to experiment with this neat newish raid technology. I think it has been around long enough that it can be used in production, but I'm still getting used to the little bugs/features, and here is one that I just found.

After figuring out that I had 2 out of 3 of my 1TB Seagate Barracuda hard drives fail, I had to give the array up for a loss and test out my backup strategy. Fortunately it worked and there was no data loss. After receiving the replacement drives in from RMA, I rebuilt the ZFS array (using raidz again) and went along my merry way. After 6 months or so, I started getting some funky results from my other drive. Thinking it might have some issue as with the others, I removed the drive and ran Seatools on it (by the way, Seatools doesn't offer a 64-bit Windows version - what year is this?).

The drive didn't show any signs of failure, so I decided to wipe it and add it back into the array to see what happens. That, of course, is easier said than done.]]></description>
			<content:encoded><![CDATA[<p>At home I have an (admittedly small) <a href="http://en.wikipedia.org/wiki/ZFS">ZFS</a> array set up to experiment with this awesome newish <a href="http://en.wikipedia.org/wiki/RAID">RAID</a> technology. I think it has been around long enough that it can now be used in production, but I&#8217;m still getting used to the little bugs/features, and here is one that I just found.</p>
<p>After figuring out that I had 2 out of 3 of my 1TB Seagate Barracuda hard drives in the array fail, I had to give the entire array up for a loss and test out my backup strategy. Fortunately it worked and there was no data loss. After receiving the replacement drives in from Seagate, I rebuilt the ZFS array (using <a href="http://www.solarisinternals.com/wiki/index.php/ZFS_Best_Practices_Guide#Should_I_Configure_a_RAIDZ.2C_RAIDZ-2.2C_RAIDZ-3.2C_or_a_Mirrored_Storage_Pool.3F">raidz</a> again) and went along my merry way. After another 6 months or so, I started getting some funky results from my other drive. Thinking it might have some issue as with the others, I removed the drive and ran <a href="http://www.seagate.com/www/en-us/support/downloads/seatools">Seatools</a> on it (by the way, Seatools doesn&#8217;t offer a 64-bit Windows version &#8211; what year is this?).</p>
<p>The drive didn&#8217;t show any signs of failure, so I decided to wipe it and add it back into the array to see what happens. That, of course, is easier said than done.</p>
<p>One of the problems I ran into is that I am using <a href="http://www.ubuntu.com/">Ubuntu</a> and <a href="http://fuse.sourceforge.net/">fuse</a> to run zfs. Ubuntu has this nasty habit of changing around drive identifiers when USB devices are plugged in. So now when this drive is plugged in, it is on /dev/sde instead of /dev/sdd, which is now a USB attached drive. </p>
<p>No problem, I figure, I&#8217;ll offline the bad drive in the zpool and replace it with the new drive location. No such luck.</p>
<p>First I offlined the drive using <code class="codecolorer text mac-classic"><span class="text">zpool offline media /dev/sdd</span></code>:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">dave@cerberus:~$ sudo zpool status<br />
&nbsp; pool: media<br />
&nbsp;state: DEGRADED<br />
status: One or more devices has been taken offline by the administrator.<br />
&nbsp; &nbsp; &nbsp; &nbsp; Sufficient replicas exist for the pool to continue functioning in a<br />
&nbsp; &nbsp; &nbsp; &nbsp; degraded state.<br />
action: Online the device using 'zpool online' or replace the device with<br />
&nbsp; &nbsp; &nbsp; &nbsp; 'zpool replace'.<br />
&nbsp;scrub: none requested<br />
config:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; NAME &nbsp; &nbsp; &nbsp; &nbsp;STATE &nbsp; &nbsp; READ WRITE CKSUM<br />
&nbsp; &nbsp; &nbsp; &nbsp; media &nbsp; &nbsp; &nbsp; DEGRADED &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raidz1-0 &nbsp;DEGRADED &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdd &nbsp; &nbsp; OFFLINE &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdb &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdc &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0</div></td></tr></tbody></table></div>
<p>Now that it&#8217;s offline, I thought you should be able to detach it. No such luck &#8211; since it is a &#8216;primary&#8217; device of the zpool it does not allow you to remove it.</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">dave@cerberus:~$ sudo zpool detach media /dev/sdd<br />
cannot detach /dev/sdd: only applicable to mirror and replacing vdevs</div></td></tr></tbody></table></div>
<p>What they <em>want</em> you to do is replace the drive with another drive. This drive (the same drive, with all info wiped from it) is now on /dev/sde. I try to replace it:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">dave@cerberus:~$ sudo zpool replace media /dev/sdd /dev/sde<br />
invalid vdev specification<br />
use '-f' to override the following errors:<br />
/dev/sde is part of active pool 'media'<br />
dave@cerberus:~$ sudo zpool replace -f media /dev/sdd /dev/sde<br />
invalid vdev specification<br />
the following errors must be manually repaired:<br />
/dev/sde is part of active pool 'media'</div></td></tr></tbody></table></div>
<p>Even with -f it doesn&#8217;t allow the replacement, because the system thinks that the drive is part of another pool.</p>
<p>So basically you are stuck if trying to test a replacement with a drive that already been used in the pool. I&#8217;m sure I could replace it with another 1TB disk but what is the point of that? </p>
<p>I ended up resolving the problem by removing the external USB drive, therefore putting the drive back into the original /dev/sdd slot. Without issuing any commands, the system now sees the drive as the old one, and starts resilvering the drive.</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@cerberus:/home/dave# zpool status<br />
&nbsp; pool: media<br />
&nbsp;state: ONLINE<br />
status: One or more devices has experienced an unrecoverable error. &nbsp;An<br />
&nbsp; &nbsp; &nbsp; &nbsp; attempt was made to correct the error. &nbsp;Applications are unaffected.<br />
action: Determine if the device needs to be replaced, and clear the errors<br />
&nbsp; &nbsp; &nbsp; &nbsp; using 'zpool clear' or replace the device with 'zpool replace'.<br />
&nbsp; &nbsp;see: http://www.sun.com/msg/ZFS-8000-9P<br />
&nbsp;scrub: resilver in progress for 0h9m, 4.62% done, 3h18m to go<br />
config:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; NAME &nbsp; &nbsp; &nbsp; &nbsp;STATE &nbsp; &nbsp; READ WRITE CKSUM<br />
&nbsp; &nbsp; &nbsp; &nbsp; media &nbsp; &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raidz1-0 &nbsp;ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdd &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp;13 &nbsp;30.2G resilvered<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdb &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdc &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0</div></td></tr></tbody></table></div>
<p>It is interesting to see what it looks like from an i/o perspective. The system reads from the two good drives and writes to the new (bad) one. Using <code class="codecolorer text mac-classic"><span class="text">iostat -x</span></code>:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">avg-cpu: &nbsp;%user &nbsp; %nice %system %iowait &nbsp;%steal &nbsp; %idle<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 29.77 &nbsp; &nbsp;0.00 &nbsp; 13.81 &nbsp; 32.81 &nbsp; &nbsp;0.00 &nbsp; 23.60<br />
<br />
Device: &nbsp; &nbsp; &nbsp; &nbsp; rrqm/s &nbsp; wrqm/s &nbsp; &nbsp; r/s &nbsp; &nbsp; w/s &nbsp; rsec/s &nbsp; wsec/s avgrq-sz avgqu-sz &nbsp; await &nbsp;svctm &nbsp;%util<br />
sda &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.00 &nbsp; &nbsp; 0.00 &nbsp; &nbsp;0.80 &nbsp; &nbsp;0.00 &nbsp; &nbsp;33.60 &nbsp; &nbsp; 0.00 &nbsp; &nbsp;42.00 &nbsp; &nbsp; 0.01 &nbsp; 15.00 &nbsp;15.00 &nbsp; 1.20<br />
sdb &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.00 &nbsp; &nbsp; 0.00 &nbsp;625.00 &nbsp; &nbsp;0.00 108033.20 &nbsp; &nbsp; 0.00 &nbsp; 172.85 &nbsp; &nbsp; 0.56 &nbsp; &nbsp;0.90 &nbsp; 0.49 &nbsp;30.80<br />
sdc &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.00 &nbsp; &nbsp; 0.00 &nbsp;624.20 &nbsp; &nbsp;0.00 107828.40 &nbsp; &nbsp; 0.00 &nbsp; 172.75 &nbsp; &nbsp; 0.50 &nbsp; &nbsp;0.81 &nbsp; 0.47 &nbsp;29.60<br />
sdd &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.00 &nbsp; &nbsp; 1.20 &nbsp; &nbsp;0.00 &nbsp;504.40 &nbsp; &nbsp; 0.00 107729.60 &nbsp; 213.58 &nbsp; &nbsp; 9.52 &nbsp; 18.85 &nbsp; 1.98 100.00</div></td></tr></tbody></table></div>
<p>It seems that ZFS is able to identify a hard drive by GID somehow but doesn&#8217;t automatically use it in the pool. This makes it so that you can&#8217;t test a drive by removing it, formatting it, and putting it into a new location. <strong>Basically, zfs assumes that your drives are always going to be in the same /dev location, which isn&#8217;t always true</strong>. As soon as you attach a USB drive in Ubuntu things are going to shift around.</p>
<p>After the resilver is complete, the zpool status is:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@cerberus:/home/dave# zpool status<br />
&nbsp; pool: media<br />
&nbsp;state: ONLINE<br />
status: One or more devices has experienced an unrecoverable error. &nbsp;An<br />
&nbsp; &nbsp; &nbsp; &nbsp; attempt was made to correct the error. &nbsp;Applications are unaffected.<br />
action: Determine if the device needs to be replaced, and clear the errors<br />
&nbsp; &nbsp; &nbsp; &nbsp; using 'zpool clear' or replace the device with 'zpool replace'.<br />
&nbsp; &nbsp;see: http://www.sun.com/msg/ZFS-8000-9P<br />
&nbsp;scrub: resilver completed after 0h16m with 0 errors on Sun May 15 07:35:46 2011<br />
config:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; NAME &nbsp; &nbsp; &nbsp; &nbsp;STATE &nbsp; &nbsp; READ WRITE CKSUM<br />
&nbsp; &nbsp; &nbsp; &nbsp; media &nbsp; &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raidz1-0 &nbsp;ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdd &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp;13 &nbsp;50.0G resilvered<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdb &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdc &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
<br />
errors: No known data errors</div></td></tr></tbody></table></div>
<p>You can now clear the error with:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@cerberus:/home/dave# zpool clear media<br />
root@cerberus:/home/dave#</div></td></tr></tbody></table></div>
<p>Zpool status now shows no errors:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@cerberus:/home/dave# zpool status<br />
&nbsp; pool: media<br />
&nbsp;state: ONLINE<br />
&nbsp;scrub: resilver completed after 0h16m with 0 errors on Sun May 15 07:35:46 2011<br />
config:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; NAME &nbsp; &nbsp; &nbsp; &nbsp;STATE &nbsp; &nbsp; READ WRITE CKSUM<br />
&nbsp; &nbsp; &nbsp; &nbsp; media &nbsp; &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raidz1-0 &nbsp;ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdd &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp;50.0G resilvered<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdb &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sdc &nbsp; &nbsp; ONLINE &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0<br />
<br />
errors: No known data errors</div></td></tr></tbody></table></div>
<p>So now the question I have is this: <em>Are you able to manually update or remove the drive status somewhere in your system?</em> How did zfs know that this drive already had a pool installed on it? I zeroed the drive and verified with fdisk there were no partition on it. Is there a file somewhere on the system that stores this information, or is it written somewhere on the drive?</p>
<p>ZFS is great, but it still has some little issues like this that give me pause before using it in a production system. Then again, I suppose all massive disk array systems have their little quirks!</p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/what-a-resilver-looks-like-in-zfs/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Disabling The hald-addon-storage Service On CentOS/RedHat</title>
		<link>http://systembash.com/content/disabling-the-hald-addon-storage-service-on-centosredhat/</link>
		<comments>http://systembash.com/content/disabling-the-hald-addon-storage-service-on-centosredhat/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 16:13:53 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Configurations]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[daemon]]></category>
		<category><![CDATA[hald]]></category>
		<category><![CDATA[hardware access layer]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=961</guid>
		<description><![CDATA[The hald &#8211; Hardware Access Layer Daemon &#8211; runs several processes in order to keep track of what hardware is installed on your system. This includes polling USB Drives and &#8216;hot-swap&#8217; devices to check for changes along with a host of other tasks. You might see it running on your system as follows: 12342474 ? &#160; &#160; &#160; &#160;S &#160; &#160; &#160;0:00 &#160;\_ hald-runner 2481 ? &#160; &#160; &#160; &#160;S &#160; &#160; &#160;0:00 &#160; &#160; &#160;\_ hald-addon-acpi: listening on acpid socket /var/run/acpid.socket 2487 ? &#160; &#160; &#160; &#160;S &#160; &#160; &#160;0:00 &#160; &#160; &#160;\_ hald-addon-keyboard: listening on /dev/input/event0 2495 ? &#160; &#160; &#160; &#160;S &#160; &#160; 41:47 &#160; &#160; &#160;\_ hald-addon-storage: polling /dev/hdc If your system is static and the devices do not change, you can actually disable this service using a policy entry. Create a file in your policy directory, for example /etc/hal/fdi/policy/99-custom.fdi. Add the text: 123456789&#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62;....]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://linux.die.net/man/8/hald">hald</a> &#8211; <em>Hardware Access Layer Daemon</em> &#8211; runs several processes in order to keep track of what hardware is installed on your system. This includes polling USB Drives and &#8216;hot-swap&#8217; devices to check for changes along with a host of other tasks. </p>
<p>You might see it running on your system as follows:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">2474 ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp; &nbsp;0:00 &nbsp;\_ hald-runner<br />
2481 ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp; &nbsp;0:00 &nbsp; &nbsp; &nbsp;\_ hald-addon-acpi: listening on acpid socket /var/run/acpid.socket<br />
2487 ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp; &nbsp;0:00 &nbsp; &nbsp; &nbsp;\_ hald-addon-keyboard: listening on /dev/input/event0<br />
2495 ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp; 41:47 &nbsp; &nbsp; &nbsp;\_ hald-addon-storage: polling /dev/hdc</div></td></tr></tbody></table></div>
<p>If your system is static and the devices do not change, you can actually disable this service using a policy entry. </p>
<p>Create a file in your policy directory, for example /etc/hal/fdi/policy/99-custom.fdi. Add the text:</p>
<div class="codecolorer-container xml mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;deviceinfo</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;0.2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;device<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;match</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;storage.removable&quot;</span> <span style="color: #000066;">bool</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;remove</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;info.addons&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;strlist&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>hald-addon-storage<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/remove<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/match<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/device<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/deviceinfo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<p>Save and reload the hald using <code class="codecolorer text mac-classic"><span class="text">/etc/init.d/haldaemon restart</span></code>.</p>
<p>And you will find that service no longer is polling your hardware.</p>
<p>Of course to turn it back on, remove that policy entry and restart the haldaemon again, it will be back in service.</p>
<p><em>Solution Credit: <a href="http://www.linuxforums.org/forum/newbie/160675-solved-completely-disabling-hald-addon-storage-not-just-stop-polling.html">Linuxforums User cn77</a></em></p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/disabling-the-hald-addon-storage-service-on-centosredhat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Random Quotes to the Bash Login Screen</title>
		<link>http://systembash.com/content/adding-random-quotes-to-the-bash-login-screen/</link>
		<comments>http://systembash.com/content/adding-random-quotes-to-the-bash-login-screen/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 13:49:13 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[quotes]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=873</guid>
		<description><![CDATA[According to &#8220;official&#8221; system administrator rules and guidelines you shouldn&#8217;t be adding so-called vain scripts to the login prompt &#8211; only utilities that will add something useful to the system (for example, current system load, memory and disk usage, etc). However I have some systems that I frequently connect to and thought it would be neat to add a random quote script to my bash login. That being said, this should only be done on &#8216;non-production&#8217; systems and adds a security vector so please be careful where you use this. The goal of this is to add a little quote, at random, every time you log into your system. My thoughts were to do it not only as a little source of inspiration but also to add perspective to what I&#8217;m doing sitting in front of the computer all of the time. Originally I was going to try to write....]]></description>
			<content:encoded><![CDATA[<p>According to &#8220;official&#8221; system administrator rules and guidelines you shouldn&#8217;t be adding so-called vain scripts to the login prompt &#8211; only utilities that will add something useful to the system (for example, current system load, memory and disk usage, etc). However I have some systems that I frequently connect to and thought it would be neat to add a random quote script to my bash login. That being said, this should only be done on &#8216;non-production&#8217; systems and adds a security vector so please be careful where you use this. </p>
<p>The goal of this is to add a little quote, at random, every time you log into your system. My thoughts were to do it not only as a little source of inspiration but also to add perspective to what I&#8217;m doing sitting in front of the computer all of the time. </p>
<p>Originally I was going to try to write the script solely in bash since it is so flexible (and just as a proof of concept) but dealing with RSS in bash isn&#8217;t exactly pretty and I just wanted to get this together as quick as possible. PHP makes parsing XML easy, there are a number of ways to accomplish it. I chose to use the ready-made script at <a href="http://rssphp.net/">rssphp.net</a> to do this, if you are curious about how you can handle this yourself using SimpleXML check out <a href="http://www.pixel2life.com/publish/tutorials/102/xml_parsing_using_built_in_libraries_in_php5/">this tutorial</a> over at Pixel2Life. The end result of my solution is a bash script calling a php script to grab the quote.</p>
<h2>The Code</h2>
<p>First create a file named <code class="codecolorer text mac-classic"><span class="text">/etc/update-motd.d/10-quote</span></code>. The name does not matter much &#8211; the number will decide what order the script is called in of all the scripts in /etc/update-motd.d. Do an <code class="codecolorer text mac-classic"><span class="text">ls</span></code> on that directory to see what all is being called when you log in. Add the following lines to this file, assuming you are placing your scripts in /etc/scripts/:</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/sh</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span><br />
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>getquote.php<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span></div></td></tr></tbody></table></div>
<p><a href="http://rssphp.net/download/">Download v1 of rssphp</a> and extract it to the <code class="codecolorer text mac-classic"><span class="text">/etc/scripts/</span></code> directory. We will require that file in our php code.</p>
<p>Create the file <code class="codecolorer text mac-classic"><span class="text">/etc/scripts/getquote.php</span></code> and add the following:</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'rss_php.php'</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$rss</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> rss_php<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$rss</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://www.quotedb.com/quote/quote.php?action=random_quote_rss'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$rssitems</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$rss</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getItems</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$rssitems</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// print_r($rssitems);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$rssitems</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' :: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$rssitems</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<p>I am using the RSS source from <a href="http://www.quotedb.com">QuoteDB</a> as the source of my quotes. Of all the places I checked (and I checked a lot) they seemed to have the most appropriate ones for this use. Feel free to use any source you wish &#8211; as long as the XML fields title/description hold the quote you will be able to use it. The RSS url was not obvious from the site and I had to do some digging to find it, in the end I am using <code class="codecolorer text mac-classic"><span class="text">http://www.quotedb.com/quote/quote.php?action=random_quote_rss</span></code>.</p>
<p>We also add the <em>if</em> statement to allow it to degrade nicely in case you have no network connectivity to the server. After a short period &#8211; a second or two &#8211; it will time out and let you log in. </p>
<p>The end result is a pretty quote in our motd:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Linux vps01.[redacted].com 2.6.18-2-pve #1 SMP Mon Feb 1 10:45:26 CET 2010 x86_64 GNU/Linux<br />
Ubuntu 10.04.1 LTS<br />
<br />
&quot;The absence of alternatives clears the mind marvelously.&quot; :: Henry Kissinger<br />
<br />
root@vps01:~#</div></td></tr></tbody></table></div>
<p>It should be pretty strait forward; let me know if you run into any problems!</p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/adding-random-quotes-to-the-bash-login-screen/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Another Bash One Liner To Delete Old Directories</title>
		<link>http://systembash.com/content/another-bash-one-liner-to-delete-old-directories/</link>
		<comments>http://systembash.com/content/another-bash-one-liner-to-delete-old-directories/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 22:05:58 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=685</guid>
		<description><![CDATA[We received a tip from blog readers Christian and Michael for alternatives to the command to delete all directories older than a certain period of time. These both work in bash and can be used in scripts to clean up old backup directories or any situation where you need to delete old directories from the command line. From Christian: find /home/backup/ -maxdepth 1 -type d -mtime +7 -exec rm -r {} \; From Michael: find /home/backup/ -maxdepth 1 -type d -mtime +7 -exec echo “Removing Directory =&#62; {}” \; -exec rm -rf “{}” \; The first one works quietly, while the second one will display what is being deleted. These are probably faster than putting it into a for loop, so feel free to use whatever works best in your particular situation!]]></description>
			<content:encoded><![CDATA[<p>We received a tip from blog readers Christian and Michael for alternatives to the <a href="http://systembash.com/content/delete-directories-older-than-week/">command to delete all directories older than a certain period of time</a>. These both work in bash and can be used in scripts to clean up old backup directories or any situation where you need to delete old directories from the command line.</p>
<p>From Christian:</p>
<pre>find /home/backup/ -maxdepth 1 -type d -mtime +7 -exec rm -r {} \;</pre>
<p>From Michael:</p>
<pre>find /home/backup/ -maxdepth 1 -type d -mtime +7 -exec echo “Removing Directory =&gt; {}” \; -exec rm -rf “{}” \;</pre>
<p>The first one works quietly, while the second one will display what is being deleted. These are probably faster than putting it into a for loop, so feel free to use whatever works best in your particular situation!</p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/another-bash-one-liner-to-delete-old-directories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One Line Linux Command to Print Out Directory Tree Listing</title>
		<link>http://systembash.com/content/one-line-linux-command-to-print-out-directory-tree-listing/</link>
		<comments>http://systembash.com/content/one-line-linux-command-to-print-out-directory-tree-listing/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 21:41:55 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=650</guid>
		<description><![CDATA[My professor sent us this little one liner (ok, I had to format it to 2 lines to fit in this blog. You know what I mean) which prints out the current directory tree: ls -R &#124; grep ":$" &#124; sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' \ -e 's/^/ /' -e 's/-/&#124;/' What&#8217;s going on here? 1ls -R &#8211; list files and directories recursively 1grep &#34;:$&#34; &#8211; find lines with : at the end (so only the directories) 1sed -e &#8211; evaluate expressions on the lines 1s/:$// &#8211; remove &#8216;:&#8217; at the end of the line 1s/[^-][^\/]*\//--/g &#8211; replaces text between / / lines (parent directories) with &#8212; , globally on each line 1s/^/ / &#8211; add space at the beginning of the lines 1s/-/&#124;/ &#8211; replace first &#8211; of the line with &#124; I reduced this using the following command. The most notable difference is that I use find instead....]]></description>
			<content:encoded><![CDATA[<p>My professor sent us this little one liner (ok, I had to format it to 2 lines to fit in this blog. You know what I mean) which prints out the current directory tree:</p>
<pre>ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' \
-e 's/^/ /' -e 's/-/|/'</pre>
<p>What&#8217;s going on here?<br />
<span id="more-650"></span></p>
<ul>
<li>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ls -R</div></td></tr></tbody></table></div>
<p>&#8211; list files and directories recursively</li>
<li>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">grep &quot;:$&quot;</div></td></tr></tbody></table></div>
<p>&#8211; find lines with : at the end (so only the directories)</li>
<li>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sed -e</div></td></tr></tbody></table></div>
<p>&#8211;  evaluate expressions on the lines</li>
<li>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">s/:$//</div></td></tr></tbody></table></div>
<p>&#8211; remove &#8216;:&#8217; at the end of the line</li>
<li>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">s/[^-][^\/]*\//--/g</div></td></tr></tbody></table></div>
<p>&#8211; replaces text between / / lines (parent directories) with &#8212; , globally on each line</li>
<li>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">s/^/ /</div></td></tr></tbody></table></div>
<p>&#8211; add space at the beginning of the lines</li>
<li>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">s/-/|/</div></td></tr></tbody></table></div>
<p>&#8211; replace first &#8211; of the line with |</li>
</ul>
<p>I reduced this using the following command. The most notable difference is that I use find instead of ls, which results in also viewing .hidden directories. I&#8217;m not sure which command is faster.</p>
<pre>find ./ -type d | sed -e 's/[^-][^\/]*\//--/g;s/--/ |-/'</pre>
<p>Both commands result in a formatted directory listing, demonstrated below:</p>
<pre>|-sitetransfer
 |---redacteddomain.com
 |-----cache
 |-----templates
 |-------skidoo_too
 |---------images
 |-----------_vti_cnf
 |---------css
 |-----------_vti_cnf
 |---------js
 |-----------scriptaculous
 |-------------src
 |-------------lib
 |---------admin_templates</pre>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/one-line-linux-command-to-print-out-directory-tree-listing/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>One Line Batch Rename Files Using CSV Input File and awk</title>
		<link>http://systembash.com/content/one-line-batch-rename-files-using-csv-input-file-and-awk/</link>
		<comments>http://systembash.com/content/one-line-batch-rename-files-using-csv-input-file-and-awk/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 17:12:32 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[csv]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=614</guid>
		<description><![CDATA[The Bash command environment, which is the namesake of this blog, is very flexible in that it allows you to manipulate the filesystem in many ways. Awk and sed are very powerful tools that allow you to do this rename with a simple one line command. This post will walk you through doing this with a Comma Separated Value (CSV) file and also using a simple regular expression to rename many files. The goal is  to rename a whole folder, hundreds of files, to a proper format for viewing in Boxee. The old listing, for example using ls -1, was: Seinfeld-(The Wig Master)-2003-09-26-0(1).avi Seinfeld-(The Wink)-2004-01-03-0.avi Seinfeld-(The Wizard)-2004-02-26-0.avi Seinfeld-(The Yada Yada)-2003-06-04-0.avi Seinfeld-(The Pen)-2004-06-22-0.avi I created a CSV file, and from the powers of the Amazon Mechanical Turk services, generated an entire list of the correct filenames, in the format: Seinfeld.7x19.The.Wig.Master.avi Seinfeld.7x04.The.Wink.avi Seinfeld.9x15.The.Wizard.avi Seinfeld.8x19.The.Yada.Yada.avi Seinfeld.3x03.The.Pen.avi Now I just needed a way to....]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.gnu.org/software/bash/manual/bashref.html#What-is-Bash_003f">Bash</a> command environment, which is the namesake of this blog, is very flexible in that it allows you to manipulate the filesystem in many ways. <a href="http://linux.die.net/man/1/awk">Awk</a> and <a href="http://linux.die.net/man/1/sed">sed</a> are very powerful tools that allow you to do this rename with a simple one line command. This post will walk you through doing this with a Comma Separated Value (CSV) file and also using a simple regular expression to rename many files.<br />
<span id="more-614"></span><br />
The goal is  to rename a whole folder, hundreds of files, to a <a href="http://forum.boxee.tv/showthread.php?t=5214">proper format</a> for viewing in Boxee. The old listing, for example using ls -1, was:</p>
<pre>Seinfeld-(The Wig Master)-2003-09-26-0(1).avi
Seinfeld-(The Wink)-2004-01-03-0.avi
Seinfeld-(The Wizard)-2004-02-26-0.avi
Seinfeld-(The Yada Yada)-2003-06-04-0.avi
Seinfeld-(The Pen)-2004-06-22-0.avi</pre>
<p>I created a CSV file, and from the powers of the <a href="https://www.mturk.com/mturk/welcome">Amazon Mechanical Turk</a> services, generated an entire list of the correct filenames, in the format:</p>
<pre>Seinfeld.7x19.The.Wig.Master.avi
Seinfeld.7x04.The.Wink.avi
Seinfeld.9x15.The.Wizard.avi
Seinfeld.8x19.The.Yada.Yada.avi
Seinfeld.3x03.The.Pen.avi</pre>
<p>Now I just needed a way to actually do the rename.</p>
<p>The final CSV file I generated is in the format:</p>
<pre>Seinfeld-(The Wig Master)-2003-09-26-0(1).avi,Seinfeld.7x19.The.Wig.Master.avi
Seinfeld-(The Wink)-2004-01-03-0.avi,Seinfeld.7x04.The.Wink.avi
Seinfeld-(The Wizard)-2004-02-26-0.avi,Seinfeld.9x15.The.Wizard.avi
Seinfeld-(The Yada Yada)-2003-06-04-0.avi,Seinfeld.8x19.The.Yada.Yada.avi
Seinfeld-(The Pen)-2004-06-22-0.avi,Seinfeld.3x03.The.Pen.avi</pre>
<p>Note that in my format, there could be no commas in the file names; but you can use any other delimiter such as = or ;, it would work equally as well with a character change in the script.</p>
<p>Using awk, you can get a correct command line output from this file:</p>
<pre>awk -F',' '{print("mv &#92;"" $1 "&#92;" &#92;"" $2 "&#92;"")}' input.txt</pre>
<p>Results in a preview of your commands, like so:</p>
<pre>mv "Seinfeld-(The Wig Master)-2003-09-26-0(1).avi" "Seinfeld.7x19.The.Wig.Master.avi"
mv "Seinfeld-(The Wink)-2004-01-03-0.avi" "Seinfeld.7x04.The.Wink.avi"
mv "Seinfeld-(The Wizard)-2004-02-26-0.avi" "Seinfeld.9x15.The.Wizard.avi"
mv "Seinfeld-(The Yada Yada)-2003-06-04-0.avi" "Seinfeld.8x19.The.Yada.Yada.avi"
mv "Seinfeld-(The Pen)-2004-06-22-0.avi" "Seinfeld.3x03.The.Pen.avi"</pre>
<p>Note that we put the file names in quotes because they contain spaces, and linux won&#8217;t recognize the filenames if you don&#8217;t include that. The -F command in awk is where you specify your delimiter, so feel free to use another character. Once you have &#8216;proofed&#8217; the script to make sure it is doing what you expect it to, you execute it by adding |/bin/sh to the end, to pipe it directly to bash.</p>
<pre>awk -F',' '{print("mv &#92;"" $1 "&#92;" &#92;"" $2 "&#92;"")}' input.txt | /bin/sh</pre>
<p>This won&#8217;t result in any output, but you will see that it changed the names of your files, just as if you would have typed in the commands (proofed above) yourself.</p>
<p>If you don&#8217;t want to go through the bother of generating a CSV file, but you still want to use bash to rename files using awk, you can use a similar command which I found over at <a href="http://snipplr.com/view/3648/batch-file-rename-with-awk-and-sed/">Snipplr</a>.</p>
<pre>ls foo*.jpg | awk '{print("mv "$1" "$1)}' | sed 's/foo/bar/2'</pre>
<p>As with the other one, this will output the command to move the file but instead uses sed to do a search/replace of the string in the filename. Append |/bin/sh to execute the commands on your system.</p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/one-line-batch-rename-files-using-csv-input-file-and-awk/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Linux Command Line, Generating a Random File</title>
		<link>http://systembash.com/content/linux-command-line-generating-a-random-file/</link>
		<comments>http://systembash.com/content/linux-command-line-generating-a-random-file/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 01:53:41 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=581</guid>
		<description><![CDATA[It is very easy to create a random file using the linux command line. Much like the command to fill a file with all zeros, for example a 1 Meg file: dd if=/dev/zero of=zero.filename bs=1024 count=1000 You do the same using /dev/urandom: dd if=/dev/urandom of=random.filename bs=1024 count=1000 Resulting in a 1MB file: 1000+0 records in 1000+0 records out 1024000 bytes (1.0 MB) copied, 0.0294247 s, 34.8 MB/s This is transferring random data from the virtual device urandom to the output file. We use /dev/urandom instead of /dev/random because the /dev/random source generates random data very slowly. urandom is much faster at this but remains very random, if not quite a random as /dev/random. This should work with any system with dd and /dev/urandom.]]></description>
			<content:encoded><![CDATA[<p>It is very easy to create a random file using the linux command line. Much like the command to fill a file with all zeros, for example a 1 Meg file:</p>
<pre>dd if=/dev/zero of=zero.filename bs=1024 count=1000</pre>
<p>You do the same using /dev/urandom:</p>
<pre>dd if=/dev/urandom of=random.filename bs=1024 count=1000</pre>
<p>Resulting in a 1MB file:</p>
<pre>1000+0 records in
1000+0 records out
1024000 bytes (1.0 MB) copied, 0.0294247 s, 34.8 MB/s</pre>
<p>This is transferring random data from the virtual device urandom to the output file. We use /dev/urandom instead of /dev/random because the /dev/random source generates random data very slowly. urandom is much faster at this but remains very random, <a href="http://vinitsworld.blogspot.com/2008/10/difference-between-devrandom-and.htmlh">if not quite a random</a> as /dev/random. This should work with any system with <a href="http://linux.die.net/man/1/dd">dd</a> and /dev/urandom.</p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/linux-command-line-generating-a-random-file/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Install SNMP on Tomato Router Firmware and Graph Traffic with Cacti</title>
		<link>http://systembash.com/content/how-to-install-snmp-on-tomato-router-firmware-and-graph-traffic-with-cacti/</link>
		<comments>http://systembash.com/content/how-to-install-snmp-on-tomato-router-firmware-and-graph-traffic-with-cacti/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 01:16:39 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Configurations]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Other Code]]></category>
		<category><![CDATA[Other Technology]]></category>
		<category><![CDATA[Programs]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[cacti]]></category>
		<category><![CDATA[firmware]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[SNMP]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=406</guid>
		<description><![CDATA[You&#8217;ve flashed your old WRT54G or other vanilla router with the Tomato firmware. This itself turns your router into a lean, mean routing machine with QOS, SSH and more, but let&#8217;s say we want to take it a bit further. What it we want to get some more stats out of it? In order to do this, we first need to set up a way to pull this information from the router. The best way to do this is to install an SNMP (Simple Network Management Protocol) daemon on the system. The main roadblock we face here is that the system mainly runs in volatile system memory, meaning that every time the system is rebooted the filesystem is reset. Fortunately Tomato provides a way to get around this using CIFS shares. Follow the steps below (as modified from here) to install an SNMP server on a Tomato router. Create a....]]></description>
			<content:encoded><![CDATA[<p>You&#8217;ve flashed your old WRT54G or other vanilla router with the <a href="http://www.polarcloud.com/tomato">Tomato firmware</a>. This itself turns your router into a lean, mean routing machine with QOS, SSH and more, but let&#8217;s say we want to take it a bit further. What it we want to get some more stats out of it?</p>
<p>In order to do this, we first need to set up a way to pull this information from the router. The best way to do this is to install an SNMP (<strong><span style="text-decoration: underline;">S</span></strong>imple <span style="text-decoration: underline;"><strong>N</strong></span>etwork <strong><span style="text-decoration: underline;">M</span></strong>anagement <strong><span style="text-decoration: underline;">P</span></strong>rotocol) daemon on the system.</p>
<p>The main roadblock we face here is that the system mainly runs in volatile system memory, meaning that every time the system is rebooted the filesystem is reset. Fortunately Tomato provides a way to get around this using CIFS shares. Follow the steps below (as modified from <a href="http://www.linksysinfo.org/forums/showthread.php?t=51064">here</a>) to install an SNMP server on a Tomato router.</p>
<ol>
<li>Create a network (samba, CIFS) share somewhere on the network. This computer must be on all of the time in order for Tomato to run the SNMP server.</li>
<li>Download the snmpd.zip file from one of these locations:<br />
[<a href="http://bok.xs4all.nl/downloads/snmpd.zip">xs4all.nl</a>]<br />
[<a href="http://systembash.com/source/snmpd.zip">systembash</a>]</p>
<p>expand the binary and .conf file into the share or a subdirectory (for example, &lt;share name&gt;/snmp)</p>
<p>MD5 for snmpd binary is ae0d622648efdb8dceb7b3b5a63e23ac</li>
<li style="text-align: center; ">Set up the shared directory on the router. Visit Administration-&gt;CIFS Client. Add the share as follows, with your correct share information:<img class="aligncenter size-full wp-image-428" title="cifs1" src="http://systembash.com/wp-content/uploads/2009/08/cifs11.png" alt="cifs1" width="360" height="258" /></li>
<li>Log into the Tomato router via ssh, and start SNMPd on the router by issuing the command:
<pre>/cifs1/snmp/snmpd -c /cifs1/snmp/snmpd.conf &amp;</pre>
</li>
<li> Test that SNMP is running and can be accessed on another computer on the network. To test it, you can use snmpwalk like so:
<pre>snmpwalk -c public -v 2c &lt;IP Address of Router&gt;</pre>
<p>If it works properly, it will list the available OIDs from the router. You do not need to take note of these, but they will be used in the graphing software later.</li>
<li>Finally, we need to launch the SNMP server when the router is restarted. You do this by adding the command to start it in the area Administration -&gt; Scripts -&gt; Firewall:
<pre>sleep 30
/cifs1/snmp/snmpd -c /cifs1/snmp/snmpd.conf -s &amp;</pre>
<p>This launches the snmp server 30 seconds after the router is started or rebooted.</li>
</ol>
<p>Thats it! SNMP is now running on the router.</p>
<p>Now to add this SNMP host to your graphing software. For this example, I will use <a href="http://www.cacti.net/">Cacti</a>, which I will assume you have already set up. If you need to set it up, please <a href="http://www.cacti.net/documentation.php">follow the directions</a> on the Cacti site for installation.</p>
<p>First, add the router as a new device, using the information below (change IP to suite your needs):</p>
<p><center><img class="aligncenter size-full wp-image-430" title="adddevice" src="http://systembash.com/wp-content/uploads/2009/08/adddevice.png" alt="adddevice" width="338" height="768" /></center></p>
<p>After adding the device, you have several options depending on what sort of data you are looking for. For system information on the router &#8211; for example CPU usage, memory usage, etc; you can go directly to Create -&gt; New Graphs. Select your device and then add the graph you are looking for.</p>
<p>The graph will show as a broken image at first, or a blank graph with &#8220;NaN&#8221; as the data source. Give it a few minutes to update, and the information should start to flow through. The ucd/net options work best, but feel free to experiment.</p>
<p>To get traffic stats on the interface, you first need to &#8220;Walk&#8221; the device.  Go back to your device list, and edit the device you added. Under &#8220;Associated Data Queries&#8221;, Add Data Query, add &#8220;SNMP &#8211; Interface Statistics&#8221; with Re-Index period as &#8220;Uptime goes backwards&#8221;. After adding it you should see under status something like: Success [39 Items, 6 Rows].</p>
<p>Since these data sources are now added, you can go back to Add a new Graph. After selecting the device, you should see a list of these new interfaces. Select the interfaces you wish to graph, and select the graph type (I suggest In/Out bits with Total).</p>
<p>After a few minutes, the data should start filling in. After a while, you will get a graph like this:</p>
<p><center><a href="http://systembash.com/wp-content/uploads/2009/08/graph_image.php1.png"><img src="http://systembash.com/wp-content/uploads/2009/08/graph_image.php1-300x120.png" alt="graph_image.php" title="graph_image.php" width="300" height="120" class="aligncenter size-medium wp-image-435" /></a></center></p>
<p><em>In conclusion</em>, with a little work, you can get enterprise class graphing from your consumer router. The total project took me about 45 minutes, and I was trying to figure out all of the data sources and the correct way to enter everything.</p>
<p>Let me know your experiences, suggestions and corrections!</p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/how-to-install-snmp-on-tomato-router-firmware-and-graph-traffic-with-cacti/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Command Line Packet Sniff Existing Running Process in Linux</title>
		<link>http://systembash.com/content/command-line-packet-sniffing-existing-running-process-in-linux/</link>
		<comments>http://systembash.com/content/command-line-packet-sniffing-existing-running-process-in-linux/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 13:57:23 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[system admin]]></category>
		<category><![CDATA[traffic]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=398</guid>
		<description><![CDATA[Have you ever come across a server that is doing a lot of traffic? Maybe you have logged in to see a process running at 100% CPU, so you know the culprit, but instead of kill -9ing it, wouldn&#8217;t it be great to see what exactly it is up to? Or even if you see a process and don&#8217;t know exactly what it is doing, and you are just curious what it is up to? As with most issues there are several ways to skin this cat. You can use tcpdump or wireshark to sniff the all of the network traffic on the device. If you know the port the program is running on (you can use lsof for that), you can restrict traffic to that port. But what if the program is jumping ports, or even uses a side-port for some sort of data transmission (UDP?). The main problem....]]></description>
			<content:encoded><![CDATA[<p>Have you ever come across a server that is doing a lot of traffic? Maybe you have logged in to see a process running at 100% CPU, so you know the culprit, but instead of kill -9ing it, wouldn&#8217;t it be great to see what exactly it is up to? Or even if you see a process and don&#8217;t know exactly what it is doing, and you are just curious what it is up to?</p>
<p><img src="http://systembash.com/wp-content/uploads/2009/07/terminal-icon-64x64.png" alt="terminal-icon-64x64" title="terminal-icon-64x64" width="64" height="64" class="alignnone size-full wp-image-401" style="float: right; padding: 0 0 15px 15px;"/>As with most issues there are several ways to skin this cat. You can use <a href="http://www.chm.tu-dresden.de/edv/manuals/aix/cmds/aixcmds5/tcpdump.htm">tcpdump</a> or <a href="http://www.wireshark.org/">wireshark </a>to sniff the all of the network traffic on the device. If you know the port the program is running on (you can use <a href="http://en.wikipedia.org/wiki/Lsof">lsof</a> for that), you can restrict traffic to that port. But what if the program is jumping ports, or even uses a side-port for some sort of data transmission (UDP?).</p>
<p>The main problem going down this route is that on a server that is doing any significant bit of traffic, it is like sorting through a needle in a haystack. If you have a single process that is taking up all of your bandwidth, you can probably find it pretty fast. But if the process is not doing a ton of traffic it can be hard to track down.</p>
<h2>Strace to the rescue</h2>
<p>You can use the great program strace to sniff the network data that an executed program is doing, or even a currently running program. This works well because if you are trying to isolate the network traffic a currently running process, your options can be limited. Using strace is the only way that I know of to see ALL of the traffic coming from a process.</p>
<p>To check the traffic of a currently running process X:</p>
<pre class="prettyprint lang-bsh">strace -p X -f -e trace=network -s 10000</pre>
<p>The command breaks down:</p>
<ul>
<li>-p: process ID</li>
<li>-f: follow forks</li>
<li>-e: follow set of system calls. In our case, we use trace=network, which follows network system calls.</li>
<li>-s: set output string sizes. default is 32, which does not  give a lot of information.</li>
</ul>
<p>Finally if you have a new program to execute and you want to watch the network traffic on it, you execute that command with strace. This would be good to use if you work in a highly secure environment and need to find out what sort of network traffic a distributed binary is doing. Checking for a program &#8216;Phoning home&#8217; is a good example of that.</p>
<p>Here is the command that launches a new process:</p>
<pre class="prettyprint lang-bsh">strace -f -e trace=network -s 10000 /usr/bin/command arguments</pre>
<p>Hopefully using strace in this manner will help you debug some issues on your server &#8211; I know I have used it several times.</p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/command-line-packet-sniffing-existing-running-process-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error While Mounting an ISO Image in Linux: ioctl: LOOP_SET_FD: Invalid argument</title>
		<link>http://systembash.com/content/error-while-mounting-an-iso-image-in-linux-ioctl-loop_set_fd-invalid-argument/</link>
		<comments>http://systembash.com/content/error-while-mounting-an-iso-image-in-linux-ioctl-loop_set_fd-invalid-argument/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 01:18:47 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Shell]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[cdrom]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[iso]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[loopback]]></category>

		<guid isPermaLink="false">http://systembash.com/?p=383</guid>
		<description><![CDATA[I recently received this error while mounting an iso image in a CentOS 5.3 install: 12[root@host ~]# mount -t iso9660 -o loop /mnt/glusterfs/ecp-spe-4867.iso /mnt/iso/ ioctl: LOOP_SET_FD: Invalid argument For more detail: 1234[root@host ~]# mount -v -t iso9660 -o loop /mnt/glusterfs/ecp-spe-4867.iso /mnt/iso/ mount: going to use the loop device /dev/loop0 ioctl: LOOP_SET_FD: Invalid argument mount: failed setting up loop device So what could this mean? The confusing error message &#8220;ioctl: LOOP_SET_FD: Invalid argument&#8221; means that your ISO image is on a filesystem that is not supported for the loopback device on your system. In my case, that was a GlusterFS mount that was hosting the image. I copied it into another directory on my root ext3 filesystem and it mounted just fine!]]></description>
			<content:encoded><![CDATA[<p>I recently received this error while mounting an iso image in a <a href="http://www.centos.org/">CentOS</a> 5.3 install:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[root@host ~]# mount -t iso9660 -o loop /mnt/glusterfs/ecp-spe-4867.iso /mnt/iso/<br />
ioctl: LOOP_SET_FD: Invalid argument</div></td></tr></tbody></table></div>
<p>For more detail:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[root@host ~]# mount -v -t iso9660 -o loop /mnt/glusterfs/ecp-spe-4867.iso /mnt/iso/<br />
mount: going to use the loop device /dev/loop0<br />
ioctl: LOOP_SET_FD: Invalid argument<br />
mount: failed setting up loop device</div></td></tr></tbody></table></div>
<p>So what could this mean? The confusing error message &#8220;ioctl: LOOP_SET_FD: Invalid argument&#8221; means that your ISO image is on a filesystem that is not supported for the loopback device on your system. In my case, that was a <a href="http://www.gluster.org/docs/index.php/GlusterFS">GlusterFS</a> mount that was hosting the image. </p>
<p>I copied it into another directory on my root <a href="http://en.wikipedia.org/wiki/Ext3">ext3</a> filesystem and it mounted just fine!</p>
]]></content:encoded>
			<wfw:commentRss>http://systembash.com/content/error-while-mounting-an-iso-image-in-linux-ioctl-loop_set_fd-invalid-argument/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching 1/18 queries in 0.006 seconds using disk: basic

Served from: systembash.com @ 2012-02-09 00:47:14 -->
