Have you ever tried to resize a ext4 partition using fdisk but end up accidentally wiping your partition table instead?
It can be a panic inducing moment but all is not lost (including your data) .
Turns out that there is a FOSS tool called TestDisk that is designed to be used to recover from such human errors.
From their web page:
TestDisk is powerful free data recovery software! It was primarily designed to help recover lost partitions and/or make non-booting disks bootable again when these symptoms are caused by faulty software: certain types of viruses or human error (such as accidentally deleting a Partition Table). Partition table recovery using TestDisk is really easy.
I can attest to the easy part, I have in the past quite easily recovered a ext4 partition that I accidentally deleted using fdisk.
TestDisk is distributed as static binaries for various operating systems so it is handy to keep a copy of it on any sort of recovery/rescue media that you use.
A protip about fdisk
Do not use fdisk unless you are absolutely certain you know what you are doing with it. While TestDisk can save you if you fuck up, it is better to not take that risk.
Booting into a live CD is usually a slower process but it is better to be safe rather than sorry when it comes to things like partitions.
Let us envision a scenario:
- You send an important message to someone, a message that requires a response.
- Your chat application indicates that the recipient has ‘read’ the message.
- The recipient does not respond after having ‘read’ the message.
Why did they not respond?
Were they perhaps distracted by something else before they could respond? Were they still thinking up a response? Did their phone lose connectivity? Was it something you said? Do they hate you now and never want to talk to you again?
On the fateful afternoon of April 8, 2017, yours truly was bored and decided he wanted to set up this hot new social networking software called Mastodon. Little did he know how this bit of idle curiosity would affect his life months later.
This is the story from then to now in pieces, as much as I can recall. I don’t remember every detail but what remains is enough.