<?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>Carbon Silk &#187; Unix</title>
	<atom:link href="http://www.carbonsilk.com/tag/unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.carbonsilk.com</link>
	<description>Developing Ideas by James Broad</description>
	<lastBuildDate>Sun, 20 Mar 2011 00:28:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.2</generator>
		<item>
		<title>Convert a series of images to a movie</title>
		<link>http://www.carbonsilk.com/development/images-to-movie/</link>
		<comments>http://www.carbonsilk.com/development/images-to-movie/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 01:25:57 +0000</pubDate>
		<dc:creator>James Broad</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[timelapse]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.carbonsilk.com/?p=203</guid>
		<description><![CDATA[I have talked in the past about how to get a fully working time lapse system on a Mac using a webcam and some command line scripting. That was great but could do with some tweaks to get a more elegant solution which I attempted to reach here. I wanted to get more use out [...]]]></description>
			<content:encoded><![CDATA[<p><object type="application/x-shockwave-flash" width="550" height="309" data="http://www.flickr.com/apps/video/stewart.swf?v=71377" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="flashvars" value="intl_lang=en-us&#038;photo_secret=163e39a9dd&#038;photo_id=4010869516"></param><param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=71377"></param><param name="bgcolor" value="#000000"></param><param name="allowFullScreen" value="true"></param><embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/video/stewart.swf?v=71377" bgcolor="#000000" allowfullscreen="true" flashvars="intl_lang=en-us&#038;photo_secret=163e39a9dd&#038;photo_id=4010869516" height="309" width="550"></embed></object></p>
<p>I have talked in the past about how to get a <a href="http://www.carbonsilk.com/development/timelapse-video-mac/">fully working time lapse system on a Mac</a> using a webcam and some command line scripting. That was great but could do with some tweaks to get a more elegant solution which I attempted to reach here.</p>
<p>I wanted to get more use out of my digital SLR camera so I set my camera up on a tripod, connected it up to an intervalometer (my mac) and gained a bunch of files that needed to be processed and turned into a movie. I created the following script to turn my images into a movie.</p>
<p>This script will run on any unix like environment with a bash shell and uses <code>ffmpeg</code> so make sure you have it installed on your *nix machine.</p>
<ol>
<li>Download <a href="http://github.com/kulor/images2movie/blob/master/images2movie">images2movie</a></li>
<li>Change the permissions to allow the script to be executed <code>chmod a+x images2movie</code></li>
<li>Copy file to /usr/bin/ <code>sudo cp images2movie /usr/bin/</code></li>
<li>Run by <code>images2movie &lt;directory&gt; 30</code></li>
</ol>
<p>If it all goes well, you should see the following output:</p>
<pre>
Movie generated: timelapse.mov
</pre>
<p>Some more work could be done to resize images in advance to ensure that ffmpeg doesn&#8217;t choke on the image sizes but I will save that for another time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.carbonsilk.com/development/images-to-movie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing your first shell script</title>
		<link>http://www.carbonsilk.com/development/writing-your-first-shell-script/</link>
		<comments>http://www.carbonsilk.com/development/writing-your-first-shell-script/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 13:32:26 +0000</pubDate>
		<dc:creator>James Broad</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[vi]]></category>

		<guid isPermaLink="false">http://www.carbonsilk.com/?p=181</guid>
		<description><![CDATA[Shell scripts are a simple way of completing (repetitive) tasks on the command line, much like many programming languages will be used. You will see ~ something &#8212; ignore the &#8216;~&#8217; this is to signify that it is a command entered onto the command line itself. Writing the code ~ vi helloworld.sh #!/bin/bash # My [...]]]></description>
			<content:encoded><![CDATA[<div><a href="http://www.flickr.com/photos/hindesite/37052873/"><img src="http://farm1.static.flickr.com/33/37052873_2d8bfe13ba_d.jpg" alt="Shell"/></a></div>
<p class="clear">Shell scripts are a simple way of completing (repetitive) tasks on the command line, much like many programming languages will be used. You will see <code>~ something</code> &#8212; ignore the &#8216;~&#8217; this is to signify that it is a command entered onto the command line itself.</p>
<h3>Writing the code</h3>
<p><code>~ vi helloworld.sh</code></p>
<pre>
#!/bin/bash
# My first script
MESSAGE="Hello World!"
echo $MESSAGE
</pre>
<p>Here we have just entered a really simple example of using variables and returning the value.</p>
<h3>Setting the permissions</h3>
<p>We need to set permission to allow the script to be executed, this is needed to be done on all unix environments for something to be run</p>
<p><code>~ chmod +x helloworld.sh</code></p>
<h3>Running the script</h3>
<p><code>~ sh helloworld.sh</code></p>
<pre>Hello World!</pre>
<p>Now you should have the response &#8220;Hello World!&#8221; from running this script.</p>
<h3>Going more advanced</h3>
<p>Lets explore some of the basic options we have to play with in the shell by example.</p>
<h4>Loop test</h4>
<p><code>~ vi looptest.sh</code></p>
<pre>
#!/bin/bash
# My first loop
FILETYPES="xml html css js"
for TYPE in $FILETYPES
    do
        echo 'Looking for' $TYPE 'files'
        find . -name '*'$TYPE
    done
</pre>
<p>Now set the correct permissions and run the script</p>
<p><code>~ chmod +x looptest.sh</code><br />
<code>~ sh looptest.sh</code></p>
<pre>
Looking for xml files
./somefile.xml
Looking for html files
./somefile.html
Looking for css files
./somefile.css
Looking for js files
./somefile.js
</pre>
<h4>If conditional test</h4>
<p><code>~ vi iftest.sh</code></p>
<pre>
#!/bin/bash
# If the file does not exist, make it
FILE='test'
if [ ! -f $FILE ] ; then
    mkdir -p $FILE
fi
ls -las $FILE
</pre>
<p>Now set the correct permissions and run the script</p>
<p><code>~ chmod +x iftest.sh</code><br />
<code>~ sh iftest.sh</code></p>
<p>Hopefully this is enough to help you on your way to making more use of the powers of Unix&#8230;</p>
<h3>Further reading</h3>
<p><a href="http://www.gnu.org/software/bash/manual/html_node/index.html">Bash Manual</a><br />
<a href="http://blog.emson.co.uk/2009/06/18-useful-bash-scripts-for-web-developers/">Useful bash one liner scripts</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.carbonsilk.com/development/writing-your-first-shell-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Making a time lapse video on Mac</title>
		<link>http://www.carbonsilk.com/development/timelapse-video-mac/</link>
		<comments>http://www.carbonsilk.com/development/timelapse-video-mac/#comments</comments>
		<pubDate>Fri, 01 May 2009 12:42:20 +0000</pubDate>
		<dc:creator>James Broad</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[me]]></category>
		<category><![CDATA[timelapse]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[webcam]]></category>

		<guid isPermaLink="false">http://www.carbonsilk.com/?p=122</guid>
		<description><![CDATA[Me on a time lapse from James Broad on Vimeo. This video is what you can create (that or something similar) by following these steps on your Mac. Step 1 Download &#38; install a command line webcam capture utility, we will be using isightcapture http://www.macupdate.com/info.php/id/18598 Open the DMG and extract the binary to /usr/bin/ sudo [...]]]></description>
			<content:encoded><![CDATA[<p><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4426507&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4426507&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>
<p><a href="http://vimeo.com/4426507">Me on a time lapse</a> from <a href="http://vimeo.com/kulor">James Broad</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>This video is what you can create (that or something similar) by following these steps on your Mac.</p>
<h3>Step 1</h3>
<p>Download &amp; install a command line webcam capture utility, we will be using isightcapture<br />
<a href="http://www.macupdate.com/info.php/id/18598">http://www.macupdate.com/info.php/id/18598</a><br />
Open the DMG and extract the binary to <code>/usr/bin/</code><br />
<code>sudo cp /Volumes/isightcapture1_1/isightcapture /usr/bin/</code></p>
<h3>Step 2</h3>
<p>Set up new directory to work in.<br />
Lets use ~/captures/<br />
<code>cd ~</code><br />
<code>mkdir captures</code><br />
<code>mkdir captures/scripts</code><br />
<code>mkdir captures/series</code></p>
<h3>Step 3</h3>
<p>Make script to take photo and save it<br />
<code>cd ~/captures/scripts</code><br />
<code>vi captureme.sh</code></p>
<p>Insert the contents into the file:</p>
<pre>
CAPTURE="isightcapture -t jpg"
cd $HOME/captures
D1=`date +%y%m%d/%H`
D2=`date +%y%m%d.%H%M%S`

# If the date directory does not exist, create it
if [ ! -d $D1 ] ; then
mkdir -p $D1
fi

# Construct the filename and path and capture a pic
FN="$D1/$D2.jpg"
$CAPTURE $FN

# Make a symlinked image of the last photo taken
if [ -h 'last.jpg' ] ; then
rm last.jpg
fi
ln -s $FN last.jpg
</pre>
<p>Save and quit (:wq)</p>
<p>To be able to run this script we need to allow execution permission on this file.</p>
<p><code>chmod a+x captureme.sh</code></p>
<h3>Step 4</h3>
<p>Put your capture script on cron<br />
<code>crontab -e</code></p>
<p>Write the contents:</p>
<pre>* * * * * ~/captures/scripts/captureme.sh</pre>
<h3>Step 5</h3>
<p>Install a utility to convert a series of images to a movie. We will be using <a href="http://www.ffmpeg.org/">ffmpeg</a><br />
<code>cd /tmp/</code><br />
<code>svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg</code><br />
<code>cd ffmpeg</code></p>
<p>We need to install ffmpeg to our machine, this process is going to basically compile the code. Hopefully nothing will go wrong for you here, if it does though, take a look on <a href="http://stephenjungels.com/jungels.net/articles/ffmpeg-howto.html">http://stephenjungels.com/jungels.net/articles/ffmpeg-howto.html</a></p>
<p><code>./configure --enable-shared --disable-mmx</code><br />
<code>sudo make</code><br />
<code>sudo make install</code></p>
<h3>Step 5</h3>
<p>Make script to grab photos and run them through ffmpeg<br />
<code>mkdir ~/captures/videos/</code><br />
<code>cd ~/captures/scripts</code><br />
<code>vi make_complete_sequence.sh</code></p>
<p>Write the contents to the file:</p>
<pre>
COUNTER=0;
rm ~/captures/series/*.jpg
for i in `find ~/captures -name '*.jpg'` ;
do
#Write the filename to be friendly with ffmpeg's odd filename input
FILENAME=`printf '%03d.jpg' $COUNTER`
cp $i ~/captures/series/$FILENAME
let COUNTER=COUNTER+1;
done
nice ffmpeg -r 20 -vcodec copy  -i ~/captures/series/%3d.jpg ~/captures/videos/timelapse_complete.mov
</pre>
<p>Again setting the permissions to be able to run the script and then run it to generate a movie based on the images taken so far.</p>
<p><code>chmod a+x make_complete_sequence.sh</code><br />
<code>./make_complete_sequence.sh</code></p>
<h3>Step 6</h3>
<p>View the finished result<br />
Browse in finder to your home directory &gt; captures/videos and watch the result.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.carbonsilk.com/development/timelapse-video-mac/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Ejecting a OS X mount when files are in use</title>
		<link>http://www.carbonsilk.com/development/ejecting-a-os-x-mount-when-files-are-in-use/</link>
		<comments>http://www.carbonsilk.com/development/ejecting-a-os-x-mount-when-files-are-in-use/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 10:10:24 +0000</pubDate>
		<dc:creator>James Broad</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[disk]]></category>
		<category><![CDATA[dmg]]></category>
		<category><![CDATA[lsof]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[mount]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[remove]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.carbonsilk.com/?p=104</guid>
		<description><![CDATA[So the problem is that you want to eject a disk/DMG/mount on your Mac and it says it is still in use &#8220;The disk &#8220;x&#8221; is in use and could not be ejected.&#8221;. Here is the solution using your command line (Terminal.app) to be able to safely eject the mount. lsof +D /Volumes/{VolumeName}/ This will [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.carbonsilk.com/wp-content/uploads/2009/04/untitled.png" alt="Eject disk" title="Eject disk" /></p>
<p class="clear">So the problem is that you want to eject a disk/DMG/mount on your Mac and it says it is still in use &#8220;The disk &#8220;x&#8221; is in use and could not be ejected.&#8221;. Here is the solution using your command line (Terminal.app) to be able to safely eject the <a href="http://en.wikipedia.org/wiki/Mount_(Unix)">mount</a>.</p>
<p><code>lsof +D /Volumes/{VolumeName}/</code></p>
<p>This will give you some results like:</p>
<pre class="php"  name="code">COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
HoggingApp 69668 myuser  txt    REG   14,5  3791772   27 /Volumes/{VolumeName}/App.app/Contents/MacOS/App</pre>
<p>Hopefully you will recognise the application that is using that resource (in this example <em>HoggingApp</em>). If you can close this application you should be able to eject your mount now.</p>
<p>If closing the application did not work for some reason you could try the following command using the <a href="http://en.wikipedia.org/wiki/Process_identifier">PID</a> found from the above result(s)</p>
<p><code>kill <strong>69668</strong></code></p>
<p>Or If running a kill has a permissions based issue just add &#8216;<code>sudo</code>&#8216; to the beginning of the line (assuming you have sudo access).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.carbonsilk.com/development/ejecting-a-os-x-mount-when-files-are-in-use/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to monitor your site status</title>
		<link>http://www.carbonsilk.com/development/monitor-your-site-status/</link>
		<comments>http://www.carbonsilk.com/development/monitor-your-site-status/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 17:36:26 +0000</pubDate>
		<dc:creator>James Broad</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[crontab]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[siteup]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.carbonsilk.com/?p=44</guid>
		<description><![CDATA[If you are running and administering your own website, the chances are that your reputation relies on you having a stable site, or at least one that your users can reach. The problem is; how often do you check your site is up and running or how you expect it to look? Probably not often. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flickr.com/photos/petecarr/475437514/"><img src="http://farm1.static.flickr.com/219/475437514_1565355424_m.jpg" alt="Traffic Lights" /></a>If you are running and administering your own website, the chances are that your reputation relies on you having a stable site, or at least one that your users can reach. The problem is; how often do you check your site is up and running or how you expect it to look? Probably not often.</p>
<p class="clear">I have produced a simple script that will let you check your sites are up and running.</p>
<p>The PHP script is hosted on GitHub at <a href="http://github.com/kulor/siteup/tree/master">http://github.com/kulor/siteup/tree/master</a>. You can see the output at <a href="http://carbonsilk.com/sandbox/siteup/">http://carbonsilk.com/sandbox/siteup/</a></p>
<p>To get this script running, you will need to change some of the defaults found in <a href="http://github.com/kulor/siteup/tree/master/index.php">index.php</a> and place both the files in a web accessible directory on your server</p>
<h3>Automating the script</h3>
<p>The best application of this script would be to deploy on your server (<strong>not on the server you are checking is up</strong>) and run on a <a href="http://en.wikipedia.org/wiki/Cron">crontab</a> at a fairly liberal interval (2 hours) to save server overload. To do this:</p>
<p>On your command line:<br />
<code>$ crontab -e</code></p>
<p>This will take you into an editor window. Enter the line below <strong>replacing {$path} with the location of your script</strong><br />
<code>0       */2     *     *     *   php -q /{$path}/siteup/index.php</code></p>
<p>Now you will receive an email if any of your programmed domains are down.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.carbonsilk.com/development/monitor-your-site-status/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using Vim as a diff tool</title>
		<link>http://www.carbonsilk.com/development/vim-diff/</link>
		<comments>http://www.carbonsilk.com/development/vim-diff/#comments</comments>
		<pubDate>Tue, 27 May 2008 17:13:25 +0000</pubDate>
		<dc:creator>James Broad</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[diff]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.carbonsilk.com/?p=23</guid>
		<description><![CDATA[Firstly I will start with why to not use diff. I am not suggesting a replacement, I have simply found that Vim offers a much better interface, that is available on most (*nix based) server environments for comparing and merging files side by side. Getting started vim -d file_original.txt file_new.txt Your tool of choice here [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.carbonsilk.com/wp-content/uploads/2008/05/vim-diff.jpg'><img src="http://www.carbonsilk.com/wp-content/uploads/2008/05/vim-diff-300x191.jpg" alt="" title="vim-diff" /></a></p>
<p>Firstly I will start with why to not use <code>diff</code>. I am not suggesting a replacement, I have simply found that Vim offers a much better interface, that is available on most (*nix based) server environments for comparing and merging files side by side.</p>
<h3>Getting started</h3>
<p><code>vim -d file_original.txt file_new.txt</code></p>
<p>Your tool of choice here is <code>vim -d</code>, so if you like this as a &#8216;patch&#8217; to <code>diff</code>, why not be naughty and alias it? I have aliased <code>alias diff='vim -d'</code> in my shell preferences.</p>
<h3>Getting fancy</h3>
<p>Wow, i can see the difference between 2 files, big deal! Try adding more files to the arguments, suddenly we have loads more power to compare multiple files, easily.</p>
<p><code>vim -d file_original.txt file_new.txt file_new_ammendments.txt</code></p>
<h3>Commands</h3>
<p><code>ctrl+ww</code> &#8211; will let you navigate buffers.</p>
<p>When comparing just 2 files, these commands will be handy when you select the lines to merge</p>
<ul>
<li><code>dp</code> &#8211; diff put</li>
<li><code>do</code> &#8211; diff obtain/get</li>
</ul>
<p>If you are in multi diff mode, these may be handy as you need to write long hand commands;</p>
<ul>
<li><code>:diffget 3</code> If you were in buffer 1, writing this command would obtain the difference in buffer 3</li>
<li><code>:diffpu 1</code> Again, write this in buffer 3 and it will place the change in buffer 1</li>
</ul>
<p>Writing/saving changes<br />
<code>:wqall</code></p>
<h3>Further Reading</h3>
<ul>
<li><a href="http://www.vim.org/htmldoc/diff.html">http://www.vim.org/htmldoc/diff.html</a>
<li><a href="http://en.wikipedia.org/wiki/Diff">http://en.wikipedia.org/wiki/Diff</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.carbonsilk.com/development/vim-diff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing a broken FileVault image on OSX</title>
		<link>http://www.carbonsilk.com/development/fixing-a-broken-filevault-image-on-osx/</link>
		<comments>http://www.carbonsilk.com/development/fixing-a-broken-filevault-image-on-osx/#comments</comments>
		<pubDate>Sun, 02 Mar 2008 22:36:53 +0000</pubDate>
		<dc:creator>James Broad</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[FileVault]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[users]]></category>

		<guid isPermaLink="false">http://www.carbonsilk.com/2008/03/02/fixing-a-broken-filevault-image-on-osx/</guid>
		<description><![CDATA[It all begins when i became somewhat frustrated when my Mac Book Pro became increasingly unstable. If it was not alt-tabbing or trivial operations including opening new applications, everything and anything seemed to lock up my machine, almost as if MS Windows had somehow taken over Unix in an evil way. I persevered with this [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flickr.com/photos/lukejtharries/453314292/"><img src="http://farm1.static.flickr.com/181/453314292_f7510645eb_t_d.jpg" alt="Apple FileVault Logo" /></a> It all begins when i became somewhat frustrated when my Mac Book Pro became increasingly unstable.</p>
<p>If it was not alt-tabbing or trivial operations including opening new applications, everything and anything seemed to lock up my machine, almost as if MS Windows had somehow taken over Unix in an evil way.</p>
<p>I persevered with this poor standard of working/coping for just over 3 days, when the final straw came, i could no longer use my Instant Message client Adium or read my RSS feeds in Vienna. Time for me to go on a hunt to track down the culprit to the nagging issues.</p>
<p>My first thoughts were that something was going amiss with the application preferences; as Vienna no longer knew what feeds i was once subscribed to and it was as if Adium had some form of Amnesia, prompting me to set up an IM connection for the `first time`.</p>
<h4>Time to investigate</h4>
<p><code>ls -las ~/Library</code></p>
<p>This is a problem, but an odd one. I had no results from my previous <code>ls</code>. How could this be? Well i consulted with a fellow system engineer and colleague, <a href="http://www.gilesrapkin.com/">Giles Rapkin</a>, whom advised me to do a disk checkup. Great idea, so i went off, firstly restoring permissions (just in case), no joy there, so disk check it was.</p>
<p>The disk check returned no conclusive results. So came the thought, could it be a problem with FileVault?</p>
<p>I logged out of my account, and logged in as root on my machine. I then dragged my FileVault image from /Users/$$USER$$ to Disk Utility and did a disk check. This returned my problem; i had a corrupt FileVault image. This was most likely caused by doing a hard reset whilst my machine was still doing stuff when the image was mounted.</p>
<h4>Sorting out the problem</h4>
<p>Problem diagnosed, time to move on and deal with the matter of getting my machine up and running in a stable fashion again.</p>
<p><strong>Note, my solution will suspend the use of Filevault, see a guide on <a href="http://muffinresearch.co.uk/archives/2007/04/05/encrypt-your-homedir-on-your-mac-without-filevault/">Encrypt your homedir on your mac without FileVault</a> by <a href="http://muffinresearch.co.uk">Stuart Colville</a></strong></p>
<p>Steps taken to fix my broken machine:</p>
<ol>
<li>Ensure you are logged in as <em>root</em> (<a href="http://docs.info.apple.com/article.html?artnum=106290">Enabling and using the &#8220;root&#8221; user in Mac OS X</a>)</li>
<li>Mount the FileVault image from the account directory</li>
<li>Copy all the files to a backup location: <code>sudo cp -r /Volumes/$$USER$$ /Users/$$USER_backup$$</code></li>
<li>Check the backup worked: <code>ls -las /Users/$$USER_backup$$</code></li>
<li>Delete the user in question in from the Accounts preference pane</li>
<li>Create the same user again, still in the Accounts preference pane</li>
<li>Copy all the backup files over to the newly created user: <code>sudo cp -r /Users/$$USER_backup$$ /Users/$$USER$$</code></li>
<li>Change permissions on the moved files: <code>sudo chown -R $$USER$$ /Users/$$USER$$</code></li>
<li>Logout of root and log back in to $$USER$$</li>
</ol>
<h4>Conclusion</h4>
<p>This seemed to fix the problem and luckily everything is up and running again, smoothly, and this time without FileVault.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.carbonsilk.com/development/fixing-a-broken-filevault-image-on-osx/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

