Files

61 lines
6.7 KiB
Plaintext
Raw Permalink Normal View History

Episode: 2072
Title: HPR2072: That Awesome Time I Deleted My Home Directory
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr2072/hpr2072.mp3
Transcribed: 2025-10-18 13:58:15
---
This is HPR episode 2007 to 2 entitled, At Awesome Time I deleted my own directory.
It is posted by SIGFLOB and is about 8 minutes long.
The summary is, SIGFLOB delete SIGFLOB directory only to recover one important file.
This episode of HPR is brought to you by an honesthost.com.
Get 15% discount on all shared hosting with the offer code HPR15, that's HPR15.
Better web hosting that's honest and fair, at An Honesthost.com.
Hello everybody, my name is SIGFLOB, I'm SIGFLOB, you'll listen to Hacker Public Radio and in this edition we're going to talk about that awesome time that I deleted my home directory.
Hey, so forgive my voice, it's a bit hoarse, I'm currently losing my voice.
But before I lost it completely, I thought I'd make another episode.
So deleting everything in my home directory, this is something I've done a couple of days ago.
I didn't try to, and let me tell you about it.
So what happened, while I deleted it by typing RM asterisk, I'm sorry, RM slash F asterisk, and then a path to the thing I want to delete it, which is the opposite way HapThings.
I don't know, maybe it's my dyslexia or something like that.
And so it executed, RM executed the slash asterisk before I had anything to do with the driven path.
Gah, when it finally executed, I saw a bunch of print about, I can't delete this directory, I can't delete that directory, which is good because it preserved the directories in my home directory, I just did RM asterisk, not RM, RF asterisk.
So I saw this being printed by, and it took a second for me to realize what I've done, and why am I getting a print out, and like, oh my god, I deleted everything on my home directory.
I was working on this particular program at the time, and I was like, oh, I just lost all the work I've done for the last couple of nights.
Let me tell you about the program. It's one file, fortunately, I decided to have it just in one file because I was writing this quickly.
It was a quick hack, and I'll put the other program.
So what I wanted to do was get this file back. I could care less about all the other things in my home directory. I just wanted this one file.
And so what I did, after I realized that I deleted everything, I was the power in my computer as soon as possible without syncing to disk, which is something you should do if this happens to you, just turn off your computer quickly as possible.
That way the remnants of the file is still in the file system, and it isn't written over.
What you want to do from there is boot into a computer that has your slash file system accessible, not mounted, so you can read it.
You're going to read it with crap is what you're going to do.
Fortunately for OpenBSD, you have the BSD install RAM disk, which contains Grap and DD, that's something else you'll need.
All you do is boot from it. It has a root file system in memory that it works with, and so yeah, when you boot up the RAM disk, the install RAM disk, you have an option to go to Shell.
So you want to do that, go to Shell.
Another component you need is in your head, I had it in my head, a memory of a little bit of the source code of the file I'm looking for.
You want to have some part of the file that you know is going to the file, and what you do after that is grab your slash file system for a string that's string that you're remembered.
So type grab dash B, dash A, what string remember slash, I'm sorry, space slash DB slash the root file system, and that'll take a while.
B means point, and you dump out the byte offset that where you found whatever, and A tells Grap to treat whatever's input as ASCII text, which is important because if you don't specify A, it'll just say while these files are similar or there's a match found rather.
What you want to do is actually print out where the match is found, so sit back, bake a potato, depending on how large your file system is, you should be getting it back real real soon.
It took like a couple of minutes for me, and I'm running on an 80 gig file system.
Next, you want to run DD over your file system with the DD, you specify the IEP parameter as your slash file system.
That's the input file from that you have the BS parameter as one DD works with block size, block size chunks, and that sets the block size, the default block size is 512.
Just set that to 1, so you can use the byte offset that you got from a Grap, and then have your out file equal somewhere to store what you just you're extracting.
Now the most important argument is skip, skip equals, then type the byte offset that you got from Grap, but subtract it by say 500, okay, depending on how big the file is, just subtract it by that.
And then after that you have count, especially by count being the beginning of the file where you think it is, and the end of the file where you think it is.
So it's the byte offset, minus how big you think the had of the file is, plus how big you think the tail is, and I just had two megs because it's probably under that.
And so I ran that, it went through, and I'll put it that to a file in my slash temp directory is where I put it.
So I open that file in the temp directory, and lo and behold there's a bunch of cropped at the beginning and a bunch of cropped at the end, but my source file is there unharmed.
You're lucky because you turned off your computer right away to have a contiguous area of storage that has your file that happened to me, the case of me.
So yeah, I got, I opened up an enter, I got rid of the card of the beginning and rid of the card at the end, and wow, I had my file back, which is great.
Now you mount that file system as read and write, and copy that file over to your home directory, and reboot, and there you'll see it, and all as well, the two days of work writing that file are not lost.
So thank you for listening everyone, take care, and keep your file system to safe.
You've been listening to Hacker Public Radio at HackerPublicRadio.org.
We are a community podcast network that releases shows every weekday, Monday through Friday.
Today's show, like all our shows, was contributed by an HBR listener like yourself.
If you ever thought of recording a podcast, then click on our contribute link to find out how easy it really is.
Hacker Public Radio was founded by the digital dog pound and the Infonomicon Computer Club, and is part of the binary revolution at binrev.com.
If you have comments on today's show, please email the host directly, leave a comment on the website, or record a follow-up episode yourself.
On this otherwise stated, today's show is released on the creative comments,
attribution, share a like, 3.0 license.