<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Seagate on rooiratel</title><link>https://rooiratel.red/tags/seagate/</link><description>Stephan Snyman's personal website</description><language>en-gb</language><generator>Hugo</generator><atom:link href="https://rooiratel.red/tags/seagate/index.xml" rel="self" type="application/rss+xml"/><item><title>Easy disk recovery</title><link>https://rooiratel.red/posts/ez-disk-recovery/</link><pubDate>Sun, 12 Mar 2023 20:03:37 +0200</pubDate><guid isPermaLink="true">https://rooiratel.red/posts/ez-disk-recovery/</guid><description>I have some really old hard drives in my PC. There was a power failure, and when I booted up my PC again, I instantly heard the click of death. Not a good sign. Also, I couldn’t access the drive at all. I checked dmesg, and yeah, my shitty Seagate HDD was really dead.
Luckily, I had two new and unused 6TB Toshiba hard drives in storage.
Prepare new hard drive I plugged in the new drive and create a new ext4 file system on it.</description><content:encoded><![CDATA[<p>I have some really old hard drives in my PC. There was a power failure, and when I booted up my PC again, I instantly heard the click of death. Not a good sign. Also, I couldn&rsquo;t access the drive at all. I checked <code>dmesg</code>, and yeah, my shitty Seagate HDD was really dead.</p>
<p>Luckily, I had two new and unused 6TB Toshiba hard drives in storage.</p>
<h2 id="prepare-new-hard-drive">Prepare new hard drive</h2>
<p>I plugged in the new drive and create a new ext4 file system on it.</p>
<pre tabindex="0"><code># mkfs.ext4 /dev/sdY
</code></pre><p>Next, I created a directory to mount it.</p>
<pre tabindex="0"><code># mkdir /mnt/cool-name
</code></pre><p>and then mounted it.</p>
<pre tabindex="0"><code># mount /dev/sdY /mnt/cool-name
</code></pre><p>That worked - I could see it, but I couldn&rsquo;t create any files on this file system. The root user was being mean&hellip; Here&rsquo;s how I fixed it:</p>
<pre tabindex="0"><code># chmod o+w /mnt/cool-name
</code></pre><p>Much better.</p>
<h2 id="ddrescue-to-the-rescue">ddrescue to the rescue</h2>
<p>I followed the instructions on the <a href="https://wiki.archlinux.org/title/Disk_cloning">ArchWiki Disk Cloning</a> page.</p>
<p>Well, with one small alteration, it was not clear to me where the rescue.map file was stored, so I explicitly stored it in the /root/ directory.</p>
<p>I first cloned every block that did not have read errors.</p>
<pre tabindex="0"><code># ddrescue --force -n /dev/sdX /dev/sdY /root/rescue.map
</code></pre><p>This took about 5 hours on my 2TB drive. You can pause this with <code>Ctrl+C</code> and then resume later by running the same command again. Using the rescue.map file, it will continue where it left off. I tested this multiple times.</p>
<p>Once that was done, I needed to copy all the faulty blocks.</p>
<pre tabindex="0"><code># ddrescue --force -d -r3 -n /dev/sdX /dev/sdY /root/rescue.map
</code></pre><p>This didn&rsquo;t take long at all for me, since it was comprised of only 0.01% of the remaining blocks.</p>
<p>Finally I ran <code>fsck</code> on the new partition to fix any corruption issues.</p>
<pre tabindex="0"><code># fsck -f /dev/sdY
</code></pre><p>This also didn&rsquo;t take long.</p>
<h2 id="final-touches">Final touches</h2>
<p>Because the old partition was cloned onto the new one, the partition label and various metadata all get applied to the partition on the new hard drive.</p>
<p>To change the label of the new partition without formatting it, I needed to do the following:</p>
<pre tabindex="0"><code>sudo e2label /dev/sdY cool-name
</code></pre><p>where &ldquo;cool-name&rdquo; was the new label for your partition.</p>
<p>Then I resized the file system to fit to the size of the new disk.</p>
<pre tabindex="0"><code>sudo resize2fs /dev/sdY
</code></pre><p>Finally, I added this new partition as an entry on my <code>/etc/fstab</code> config to mount it to <code>/mnt/cool-name</code> on startup. And with that, I was done.</p>
<p><code>ddrescue</code> did a great job, and I got all my files back from a completely useless hard drive that will soon have its platters become intimately familiar with an industrial-strength drill.</p>
]]></content:encoded></item></channel></rss>