<?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>The HyRax Macrocosm &#187; Backup</title>
	<atom:link href="http://www.serenux.com/tag/backup/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.serenux.com</link>
	<description>Life, the Universe and Ubuntu.</description>
	<lastBuildDate>Sun, 29 Aug 2010 21:35:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>HowTo: Rip a Blu-ray movie using an LG GGC-H20L Blu-ray drive with Ubuntu</title>
		<link>http://www.serenux.com/2009/01/howto-rip-a-blu-ray-movie-using-an-lg-ggc-h20l-blu-ray-drive-with-ubuntu/</link>
		<comments>http://www.serenux.com/2009/01/howto-rip-a-blu-ray-movie-using-an-lg-ggc-h20l-blu-ray-drive-with-ubuntu/#comments</comments>
		<pubDate>Sat, 24 Jan 2009 00:50:03 +0000</pubDate>
		<dc:creator>HyRax</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Blu-ray]]></category>
		<category><![CDATA[High-Definition]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Intrepid]]></category>
		<category><![CDATA[LG]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MPlayer]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://www.serenux.com/?p=356</guid>
		<description><![CDATA[The Blu-ray disc format has brought with it the ability to easily provide the next generation of High-Definition 1080p movie content. There&#8217;s just one problem &#8211; Ubuntu and Linux in general has no official support for Blu-ray, and its encryption scheme is vastly different to that of DVD &#8211; it&#8217;s not just a simple case [...]]]></description>
			<content:encoded><![CDATA[<p>The Blu-ray disc format has brought with it the ability to easily provide the next generation of High-Definition 1080p movie content. There&#8217;s just one problem &#8211; Ubuntu and Linux in general has no official support for Blu-ray, and its encryption scheme is vastly different to that of DVD &#8211; it&#8217;s not just a simple case of installing a library like the libdvdcss2 library for decrypting DVD&#8217;s &#8211; the protection is done both at a software and hardware level.</p>
<p>This article discusses how I used my recently purchased LG GGC-H20L Blu-ray ROM drive to successfully read and watch movies using Ubuntu Intrepid.</p>
<p><span id="more-356"></span><em>DISCLAIMER: This article describes decrypting BD titles using an Intel or AMD based PC with Ubuntu Linux. While you can use a PlayStation3&#8242;s BD drive to read and decrypt a title using <strong>known</strong> decryption keys using the PS3 version of Ubuntu, at this time of writing you <strong>cannot</strong> use Ubuntu installed on a PlayStation3 console to identify <strong>unknown</strong> decryption keys of a given BD title because the application used to derive those keys from the disc is not available for the PPC processor used by the PS3. You must use a consumer BD-ROM drive on an Intel or AMD based PC instead.<br />
</em></p>
<p>Hang on, you say &#8211; if there is no support for playback of Blu-ray movies on Linux, then why buy a Blu-ray drive if you can&#8217;t watch the movies? Well, I might not be able to watch them directly, but I can certainly rip the little buggers and watch a file version of it instead. But wait again, you say, if there&#8217;s no official Blu-ray support, and you can&#8217;t watch the discs directly, then how on earth do you rip them?? I&#8217;m glad you asked, and even if you didn&#8217;t ask, I&#8217;m about to tell you anyway. <img src='http://www.serenux.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>First up, a little Blu-ray 101.</p>
<p>Blu-ray movies feature Digital Rights Management (DRM). Like DVD&#8217;s before it, most Blu-ray movies are encrypted. This is to stop those naughty pirate types from making illegal backups of the movie and giving or selling it to their mates. In the case of DVD&#8217;s, however, there was only one decryption key which was eventually discovered and from then on allowed all DVD&#8217;s to be easily decrypted using a simple library (called libdvdcss2). The movie industry as a whole were not impressed by this and insisted that the next format be more difficult (preferably impossible) to decrypt, so Blu-rays (and HD-DVD&#8217;s, but I&#8217;ll concentrate on Blu-ray for this article) each have a different decryption key now. But to complicate this further, this key is kept hidden from you by an authentication mechanism to ensure that there isn&#8217;t a repeat of the De-CSS scandal that brought the DVD encryption scheme undone.</p>
<p>Each and every player out there, hardware or software, has a unique player authentication key which is passed to the Blu-ray optical drive, essentially like giving your passport to Customs at the country border, to validate whether or not you are legally authorised to  playback a movie. If the drive has not got a blacklisted record of your authentication key, and the key is accepted as a generally valid key that has been paid for, THEN the drive will give up the movie&#8217;s decryption key and movie playback can commence.</p>
<p>Blacklist?? What blacklist? Well, like DVD players, it&#8217;s not difficult to pick up a Blu-ray player&#8217;s authentication key that is used to prompt the drive for the disc&#8217;s decryption key, after all, it has to be held in memory somewhere. Once an industry authority discovers that an authentication key has been compromised, it is added to a blacklist so that it will not work anymore. This is why hardware Blu-ray players need to be firmware-upgradable, and why software players need to be upgraded to the next version periodically with patches, etc, so that new, non-blacklisted authentication keys can be provided.</p>
<p>OK, that sounds all well and good, but if the Blu-ray drive itself is doing the blacklisting, how exactly does it know when a given authentication key is no longer valid? Simple &#8211; its blacklist will get updated with the next latest-release movie you buy.</p>
<p>Say what?</p>
<p>Every Blu-ray movie you buy has a little file on the disc under the &#8220;AACS&#8221; folder called &#8220;ContentRevocation.lst&#8221;. This file contains a complete list of blacklisted authentication keys for the drive to update itself with, and &#8211; get this &#8211; you can&#8217;t stop the drive loading it. Well, actually to be more accurate this file is simply a copy of the same list that is actually hidden in a non-tamperable, non-user-readable area elsewhere on the disc for the drive to read, but basically the instant you stick that movie disc in, the hidden version of this file is read and the drive automatically updates its blacklist right away with any new blacklist data, even before the disc icon appears on your desktop. Sneaky, huh?</p>
<p>So the next time your legal (or more specifically, pirated) copy of PowerDVD or whatever tries to playback a movie, all of a sudden you&#8217;ll see an error message instead saying that your player&#8217;s authentication key has been revoked &#8211; thus the movie is now unplayable. What&#8217;s worse is that you won&#8217;t be able to watch any of your older discs that worked previously either! It&#8217;s this exact reason that many people have called for the Blu-ray (and HD-DVD) formats to be <a title="Why you should boycoot Blu-ray and HD-DVD." href="http://bluraysucks.com/" target="_blank">boycotted</a>.</p>
<p>But not all is lost. Remember, this is an encryption technology created by Man, and therefore can be broken by Man with a bit of help from the Open Source Community at large. <img src='http://www.serenux.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  With a little help from a few external resources including the <a title="Ubuntu Community Documentation" href="https://help.ubuntu.com/community/RestrictedFormats/BluRayAndHDDVD" target="_blank">Ubuntu Community Documentation</a> and the <a title="Doom9 Forums" href="http://forum.doom9.org" target="_blank">Doom9 forums</a>, I discovered a plethora of projects by various people, from dumping discs to breaking the encryption and authentication.</p>
<p>On the surface are general applications to dump the movie, decrypted, to a file. One of the best projects is <a title="DumpHD on the Doom9 Forums" href="http://forum.doom9.org/showthread.php?t=123111" target="_blank">DumpHD</a> which is a Java app that provides a nice easy to use GUI that can rip a movie with a minimum of fuss (see detail about how to use it later in this article), however it requires that you already know what the decryption key for a given movie is which you can only obtain if you have authenticated with the drive. If you have the decryption key already, however, then authentication is not necessary and you can rip the movie right away without a problem, so this project is heavily supported by people posting up various decryption keys for all sorts of movie releases. The problem with this approach, however, is that different countries usually get different releases of the same movie, so for example a release of &#8220;Batman Begins&#8221; in Australia might have a completely different decryption key to the release of &#8220;Batman Begins&#8221; in America or Europe. This is not always the case of course, a good example being the Ewan McGregor movie &#8220;The Island&#8221; &#8211; the Australian release is actually the UK release, right down to the age-rating and film-office classification markings on the disc itself &#8211; only the box bears any Australian ratings markings!</p>
<p style="text-align: center;"><a title="Click for full size" href="http://www.serenux.com/~hyrax/snaps/BlurayMovieInserting.jpg" target="_blank"><img title="Inserting a Blu-ray movie into the LG GGC-H20L" src="http://www.serenux.com/~hyrax/snaps/BlurayMovieInserting_thumb.jpg" alt="Click for full size" /></a><br />
Click for full size (228K)</p>
<p>So, how do you find out the decryption key of your locally purchased movie then? You don&#8217;t want to keep buying a commercial player, especially one that doesn&#8217;t run under Ubuntu, just to get a valid authentication key. There&#8217;s got to be a better way! Well, there is! How about we just bypass the authentication procedure altogether? How? Again, through another great contribution on the Doom9 forums.</p>
<p>The LG GGC-H20L drive is but one of many Blu-ray/HD-DVD drives which have had their firmware reverse-engineered. Firmware is largely just a computer program that operates the drive. Since the firmware is upgradable to fix bugs and add new features to the drive, it means the program can be altered by a third party. A Doom9 contributor has provided <a title="Modified Blu-ray drive firmware" href="http://forum.doom9.org/showthread.php?t=139522" target="_blank">modified firmware</a> for various popular drives, including the GGC-H20L that effectively allow the drive to ignore the authentication procedure no matter what player authentication key is provided, blacklisted or not, thus making the drive give up the decryption key for the Blu-ray movie currently inserted every time!</p>
<p>In the case of the LG GGC-H20L that I use, the firmware is provided as a Windows Executable file. There are three ways to run this, either via a native Windows installation on your PC, a virtualised Windows installation on your PC, or via the Wine compatibility layer. I successfully upgraded my drive using the Wine option as follows:</p>
<p><em><span style="color: #ff0000;"><strong>WARNING: The following information can damage or even brick your LG Blu-ray drive if not followed correctly, or if you have a power failure during firmware update. You proceed at your own risk and I will not be held responsible for any damage incurred by your drive, or for loss of hair being torn out, by following these instructions.</strong></span></em></p>
<ol>
<li>You need a normal Wine installation. If you&#8217;ve never installed it before, then type in:
<pre><span style="color: #000080;">$ sudo apt-get install wine</span></pre>
<p>&#8230;and this will install the Ubuntu-repository version of Wine.</li>
<li>Since we&#8217;ll be modifying a physical device, only root can do that, so we will need to use sudo to execute the firmware upgrade, however Wine will not work as root until we change permissions of your Wine configuration in your Home directory, so type in the following to make root the owner of your Wine configuration:
<pre><span style="color: #000080;">$ sudo chown -R root:root ~/.wine</span></pre>
</li>
<li>Now execute the downloaded firmware file:
<pre><span style="color: #000080;">$ sudo wine GGC-H20L_1.03_VolumeID_Patch.exe</span></pre>
</li>
<li>The Upgrade GUI will appear. Click on the button to commence update and let it do its thing. After a minute or two, it will tell you that the drive firmware has been successfully updated. At this point, you will need to reboot your PC, but before you do, remember to change the owner of your Wine installation back to yourself. If your login was &#8220;jbloggs&#8221;, then you&#8217;d type in:
<pre><span style="color: #000080;">$ sudo chown -R jbloggs:jbloggs ~/.wine</span></pre>
</li>
</ol>
<p>Upon returning from restart, every time you query the drive for the inserted disc&#8217;s decryption key, the drive will now happily give it to you without question. Nice.</p>
<p>So how do we query the drive for that decryption key anyway? A simple tool to do this is <a title="AACSKeys - gets a movie's decryption key" href="http://forum.doom9.org/showthread.php?p=1320065#post1320065" target="_blank">aacskeys</a> (version 0.4.0c at this time of writing, but check further along the thread for newer releases) written by another Doom9 member, which queries the drive and tells you its Volume Unique Key and its Disc ID, which you can then copy and paste into DumpHD&#8217;s keys config file and happily begin dumping your movie.</p>
<pre><span style="color: #000080;">$ ./aacskeys /media/cdrom
aacskeys 0.3.6 by arnezami, KenD00

Volume Unique Key:              5D9BCD44522B6940F8705400DA612ED9
Unit Key File Hash (Disc ID):   837487B4D6F614D5B4D5F566387B41C2D284F393
$ </span></pre>
<p>If your drive&#8217;s firmware was not patched, instead of seeing the Volume Unique Key and Disc ID, you would get this error message instead: &#8220;The given Host Certficate / Private Key has been revoked by your drive.&#8221;.</p>
<p>We now need to take the output data and copy it to DumpHD&#8217;s &#8220;keydb.cfg&#8221; file. Each key is placed on its own line in the following format:</p>
<pre><span style="color: #000080;">DISC ID = Movie Title | D | YYYY-MM-DD | V | VOLUME UNIQUE KEY</span></pre>
<p>Thus in the example above, we would enter:</p>
<pre><span style="color: #000080;">837487B4D6F614D5B4D5F566387B41C2D284F393 = The Island | D | 2007-03-22 | V | </span><span style="color: #000080;">5D9BCD44522B6940F8705400DA612ED9
</span></pre>
<p>Now technically it appears that the date is largly irelevant, and most people just use 0000-00-00 instead of a real date (which is supposed to be the file date of the &#8220;Unit_Key_RO.inf&#8221; file in the &#8220;AACS&#8221; folder of the disc). I have tested this and I can&#8217;t see any difference in how DumpHD handles the disc.</p>
<p>Once you have finished editing the keydb.cfg file, save it.</p>
<p><em>NOTE: DumpHD (below) can now use AACSKeys directly, saving you having to edit to the keydb.cfg file manually, because DumpHD now does all the work for you. See <a title="A better way of using AACSKeys with DumpHD." href="http://www.serenux.com/2009/09/howto-deal-with-bd-copy-protection-when-ripping-blu-ray-titles-using-ubuntu/" target="_blank">this article</a> for more information.</em></p>
<p>Since DumpHD is a Java application, you will need Java installed to run it. If you haven&#8217;t already got it installed, you can install it with the following command:</p>
<pre><span style="color: #000080;">sudo apt-get install java-common</span></pre>
<p>&#8230;or more realistically you should install it as part of the ubuntu-restricted-extras package which also installs a number of other useful packages:</p>
<pre><span style="color: #000080;">sudo apt-get install ubuntu-restricted-extras</span></pre>
<p>Once that is done, launch DumpHD by simply running the &#8220;dumphd.sh&#8221; script by either double-clicking on it and select &#8220;Run&#8221; when prompted, or in a terminal, change to where you extracted the DumpHD program and type in:</p>
<pre><span style="color: #000080;">$ sh ./dumphd.sh</span></pre>
<p>When loaded, you will be presented with the following interface:</p>
<p style="text-align: center;"><a title="Click for full size" href="http://www.serenux.com/~hyrax/snaps/DumpHDFrontend.jpg" target="_blank"><img title="DumpHD Frontend" src="http://www.serenux.com/~hyrax/snaps/DumpHDFrontend_thumb.jpg" alt="Click for full size" /></a><br />
Click for full size (63K)</p>
<p>At the top-right of the window, there is the Source Browse button. Click on it and a new window will appear. In that window, type in or select &#8220;/media/cdrom&#8221; and then click OK. After a few seconds, the disc should be identified and you will see the window change as follows:</p>
<p style="text-align: center;"><a title="Click for full size" href="http://www.serenux.com/~hyrax/snaps/LoadedMovieReadyToRip.jpg" target="_blank"><img title="DumpHD Frontend" src="http://www.serenux.com/~hyrax/snaps/LoadedMovieReadyToRip_thumb.jpg" alt="Click for full size" /></a><br />
Click for full size (85K)</p>
<p>Now all you need to do is click on the Destination Browse button, specify a place to store the decrypted movie and then click the Dump button to start the whole process! Once finished, you will have every video title found on the disc dumped in its originally encoded (video-wise) format, but without DRM. You can then use MPlayer to play these files directly. Generally the movie itself is the largest file, so in the case of my example, it&#8217;s the &#8220;00000.m2ts&#8221; file. I can play it simply with:</p>
<pre><span style="color: #000080;">$ mplayer -fs 00000.m2ts</span></pre>
<p>The -fs parameter plays the movie full-screen. I can toggle audio tracks using the hash (#) key (as for some reason, English is generally not the first audio track on the disc).</p>
<p>Remember that Blu-ray movies are very large. In my example, &#8220;The Island&#8221; is a good 21GB! It&#8217;s now up to you to decide whether or not you want to provide storage for your rips of this size, or whether or not you want to compress them down to save space. In my case, I was able to compress the movie down to about 4GB with negligible quality loss at a bitrate of 1200 using the x264 codec. I&#8217;ll probably increase this bitrate and allow the filesize to go to 8GB so I can maintain as near-perfect image quality to the original Blu-ray as possible. I personally choose to preserve the audio tracks as-is without down-converting them &#8211; they really don&#8217;t eat up that much space &#8211; a few hundred megabytes only.</p>
<p>Happy ripping!</p>
<p><span style="color: #0000ff;"><em><span style="text-decoration: underline;"><strong>Woah! After I&#8217;ve ripped the movie, it plays but it&#8217;s all corrupted! What&#8217;s going on?</strong></span></em></span></p>
<p>The movie you have ripped is likely protected using BD+ protection. This is where some or much of the movie is deliberately corrupted to annoy you. I have written a guide on how to deal with this and correct the corruption <a title="Dealing with BD+ copy protection on Blu-ray discs." href="http://www.serenux.com/2009/09/howto-deal-with-bd-copy-protection-when-ripping-blu-ray-titles-using-ubuntu/" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.serenux.com/2009/01/howto-rip-a-blu-ray-movie-using-an-lg-ggc-h20l-blu-ray-drive-with-ubuntu/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>HowTo: Image your hard-drive for transfer or backup using dd</title>
		<link>http://www.serenux.com/2008/11/howto-image-your-hard-drive-for-transfer-or-backup-using-dd/</link>
		<comments>http://www.serenux.com/2008/11/howto-image-your-hard-drive-for-transfer-or-backup-using-dd/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 10:47:38 +0000</pubDate>
		<dc:creator>HyRax</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Imaging]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Recovery]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.serenux.com/?p=111</guid>
		<description><![CDATA[Imaging, also known as Ghosting in the Windows world, is the act of creating a sector-by-sector copy of a hard-drive and saving it to a file, or transferring it to another hard-drive. Such uses for imaging include: Backup to an image file Clone to another hard-drive (eg: building multiple identical workstations) either directly or via [...]]]></description>
			<content:encoded><![CDATA[<p>Imaging, also known as Ghosting in the Windows world, is the act of creating a sector-by-sector copy of a hard-drive and saving it to a file, or transferring it to another hard-drive. Such uses for imaging include:</p>
<ul>
<li>Backup to an image file</li>
<li>Clone to another hard-drive (eg: building multiple identical workstations) either directly or via an image file</li>
<li>Data recovery (it&#8217;s safer and easier to examine an image file than risk further damage to the hard-drive itself)</li>
</ul>
<p>Linux has a neat little command that can do this for us called simply &#8220;dd&#8221;. It is completely filesystem independent, so you can backup any hard-drive regardless of whether it was Linux formatted, Mac formatted or Windows formatted. It copies the drive bit by bit, sector by sector, not file by file.</p>
<p><span id="more-111"></span></p>
<p><span style="color: #ff0000;"><em><strong>WARNING:</strong> The following article describes commands that can destroy the information on your hard-drive with next-to-no-chance of being able to rescue what&#8217;s left. Make sure that you have full backups of your data prior to using these commands. You use these commands at your own risk!</em></span></p>
<p>First up, your drive/partition being backed up or written to should be unmounted before you begin. If you were trying to backup the partition containing your system&#8217;s root filesystem, you should boot up your system on a LiveCD so you can access your root partition unmounted.</p>
<p>You then need to determine which drive or partition you want to backup. Easiest way to do this is to fire up a terminal session and type in:</p>
<pre><span style="color: #000080;">$ sudo fdisk -l</span></pre>
<p>&#8230;which will list all your drives, their partitions and sizes. Note down the device name of the drive or partition you wish to backup, eg: /dev/sda for the whole of your first drive or /dev/sda1 for just the first partition of that drive, and you&#8217;re ready to begin backup.</p>
<p>At its simplest, backing up a drive takes two basic parameters &#8211; input device and output device or file as follows:</p>
<pre><span style="color: #000080;">$ sudo dd if=/dev/sda1 of=/dev/sdb1</span></pre>
<p>&#8230;will copy the content of the first partition on drive sda to the first partition of drive sdb (destroying whatever was in /dev/sdb1 previously).</p>
<pre><span style="color: #000080;">$ sudo dd if=/dev/sda1 of=~/mybackup.img</span></pre>
<p>&#8230;will copy the content of the first partition on drive sda to a file called mybackup.img in your Home directory.</p>
<p>If you wish to backup an entire drive rather than just a partition, drop the number on the drive name, ie: /dev/sda1 becomes /dev/sda instead.</p>
<p>To restore the image to a drive, simply reverse the parameters:</p>
<pre><span style="color: #000080;">$ sudo dd if=~/mybackup.img of=/dev/sda1</span></pre>
<p>How simple is that? The only issue with this method of backup, though, is that if you were to backup a 10GB partition containing only 5GB of actual data, the resulting image file will still be 10GB as dd does not simply copy active data from the drive, it copies <em>everything</em>.</p>
<p>So with that in mind, let&#8217;s compress the image, so any empty space on the drive doesn&#8217;t take up unnecessary space in the image file. We can do this by piping the data from dd into gzip before writing it to a file:</p>
<pre><span style="color: #000080;">$ sudo dd if=/dev/sda1 | gzip -9 &gt; ~/mybackup.img.gz</span></pre>
<p>&#8230;and to restore, we simply pipe the decompressed data into dd again for writing to the drive:</p>
<pre><span style="color: #000080;">$ gunzip -c ~/mybackup.img.gz | sudo dd of=/dev/sda1</span></pre>
<h3>But wait! There&#8217;s more!</h3>
<p>This just scratches the surface of what you can do with dd. For example, you can also use dd to destroy a drive&#8217;s content before you dispose of, or sell the drive by using the following:</p>
<pre><span style="color: #000080;">$ sudo dd if=/dev/random of=/dev/sda1</span></pre>
<p>&#8230;which will write random data to the partition sda1 using the virtual random device, completely obliterating it.</p>
<p>Or, if you want a more uniform destruction, try:</p>
<pre><span style="color: #000080;">$ sudo dd if=/dev/zero of=/dev/sda1</span></pre>
<p>&#8230;which will &#8211; no surprises here &#8211; write zeros across the entire partition.</p>
<p>Or perhaps you have a drive that isn&#8217;t playing nice, for example Microsoft Windows can get stroppy when working with, or removing partitions created by a foreign OS. The easiest way to fix this is to simply destroy the Master Boor Record (MBR). You can achieve this by specifying a blocksize parameter. The MBR is inside the first 512 bytes of the drive, so all we have to do is blank those 512 bytes out using:</p>
<pre><span style="color: #000080;">$ sudo dd if=/dev/zero of=/dev/sda bs=512 count=1</span></pre>
<p>The bs parameter specifies the block size in bytes (in this case 512) and the count parameter specifies how many blocks of 512 bytes we&#8217;re doing (only one in this case, the first 512 bytes of the drive where the MBR resides).</p>
<p>Any PC will now view this hard-drive as a brand new, never partitioned drive.</p>
<h3>Rescuing a dying hard-drive</h3>
<p>The dd command is particularly useful for recovering data on a drive that&#8217;s about to become a paperweight. As long as it can power up and identify itself to the system, you can attempt data recovery by taking an image of the drive and then try to recover the files from that image.</p>
<p>Since dying hard-drives are typically sown with errors, we need to tell dd to ignore them and keep pulling as much data off as possible. Taking our first imaging example, we add a couple of parameters to the command as follows:</p>
<pre><span style="color: #000080;">$ sudo dd if=/dev/sda of=~/mybackup.img conv=noerror,sync</span></pre>
<p>This will make a full backup of all partitions on drive /dev/sda to a file called mybackup.img in your Home directory, and the conv parameter tells dd to ignore any errors found during the read by skipping over them. The sync parameter tells dd to replace the errors with null values &#8211; blanks &#8211; so that the resulting image file is the same data length as the drive.</p>
<p>Once the backup is complete, you can then mount the image to view its content. As long as the MBR (the first 512 bytes of the hard-drive) were not damaged, you will be able to now recover most, if not all your files, without worrying about further failure to the drive or odd behaviour due to the physical errors on the drive itself.</p>
<p>To mount the image file, you do the following. First we need a mountpoint &#8211; a place to reference the mounted image volume:</p>
<pre><span style="color: #000080;">$ mkdir /dev/shm/myrecoveryimage</span></pre>
<p>This creates a directory called &#8220;myrecoverytimage&#8221; in your system&#8217;s RAM drive. Before you point out that you have less physical RAM than the capacity of your hard-drive, don&#8217;t worry &#8211; this is just a mount-point. The image will still be physically read from wherever you put it on another drive.</p>
<p>Now we mount the image. Let&#8217;s say we backed up a standard Linux ext3-formatted drive:</p>
<pre><span style="color: #000080;">$ sudo mount -t ext3 -o loop ~/.mybackup.img /dev/shm/myrecoveryimage</span></pre>
<p>&#8230;or for a Windows NTFS formatted backup image:</p>
<pre><span style="color: #000080;">$ sudo mount -t ntfs -o loop ~/.mybackup.img /dev/shm/myrecoveryimage</span></pre>
<p>We have told the system to mount an image file of filesystem type Ext3 (or NTFS). We have to specify the loopback device because an image file is not a block device like a hard-drive is. We then specify the filename of the image we are wanting to mount, and finally where we are mounting it to.</p>
<p>You can now simply switch over to the mountpoint directory and see the content of the image file as though it were any normally mounted hard-drive.</p>
<pre><span style="color: #000080;">$ cd /dev/shm/myrecoveryimage
$ ls -l</span></pre>
<p>There are a plethora of filesystems that the mount command can manage including FAT, NTFS network filesystems etc. Refer to the man page for the mount command for more details.</p>
<p>When you have finished with the image, you can unmount it with:</p>
<pre><span style="color: #000080;">$ sudo umount /dev/shm/myrecoveryimage</span></pre>
<p>&#8230;and that will make the /dev/shm/myrecoverimage directory revert back to an ordinary empty directory again (which, being in the RAM disk, will be lost when you reboot).</p>
<p>Happy dd&#8217;ing! <img src='http://www.serenux.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class='wp_likes' id='wp_likes_post-111'><a class='like' href="javascript:wp_likes.like(111);" title='' ><img src="http://www.serenux.com/wp-content/plugins/wp-likes/images/like.gif" alt='' border='0'/>Like</a><span class='text'></span>
<div class='unlike'><a href="javascript:wp_likes.unlike(111);">Unlike</a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.serenux.com/2008/11/howto-image-your-hard-drive-for-transfer-or-backup-using-dd/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
