LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-20-2005, 04:46 PM   #1
JMCraig
Member
 
Registered: Feb 2003
Location: Utah, USA
Distribution: Red Hat EL/CentOS, Ubuntu/Debian
Posts: 113

Rep: Reputation: 15
Angry Forgot to notrunc with dd--any recovery possible?


I was all set to test my bit twiddling of the allocation information in a big DB file--I'd dd'd out the portion of the file of interest and modified it. But I put it back--without using the conv=notrunc. Dang.

So, now this DB file, that should be 16GB long, is, uh, rather shorter. Is there any way to extend the length of the file again so that it will subsume the original contents? I know what the prior size was precisely and nothing's been written on the disk since the messed up dd truncated it, so I was hoping I could just tell the OS that it really is the original length and it might actually work. (I don't know how the space allocation works in Linux, so this might be a silly notion. But I figured I'd ask....) It should have truncated on a nice 2K boundary so I'm hoping there's nothing to indicate EOF in the data itself....

Any suggestions are most welcome!

Thanks,

John

(This was a test setup so it's not critical that I recover this in place, but I'd like to know if it's possible.)

Last edited by JMCraig; 10-20-2005 at 05:29 PM.
 
Old 10-20-2005, 05:49 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,578

Rep: Reputation: 191Reputation: 191
It should be possible in the manul mode (read: using hexedit or similar tool with filesystem reference). Ordinary tools... Much depends on the filesystem you have. Which one is it?
 
Old 10-20-2005, 06:03 PM   #3
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 31
That might work if the entire file was on consecutive blocks. It might be, it might not be. If it was, you could try

dd if=/dev/zero bs=1 count=0 of=<file> seek=<filesize>

which would write 0 bytes to the file (!), but as a side effect it would seek to the end of the file first, thus setting the filesize. WARNING: This is just off the top of my head, I have no idea whether this could even theoretically work. So don't even think about it unless you backup the entire partition first.

For a more sensible approach, it depends on your fs. If it's ext2/ext3, you could try debugfs (I used this once to recover some files without knowing wtf I was doing, but I winged it! rtfm! ). There is a debugreiserfs command but I don't know if it has the capability to recover files. Again, backup the partition first, if you have the space.
 
Old 10-20-2005, 06:11 PM   #4
JMCraig
Member
 
Registered: Feb 2003
Location: Utah, USA
Distribution: Red Hat EL/CentOS, Ubuntu/Debian
Posts: 113

Original Poster
Rep: Reputation: 15
File system type

The fs is ext2 and I'm guessing that the file is on consecutive blocks because of the way it was created (two big DB files put on one after the other--first things on there other than the fs goo). I'll check out the suggested tools! Thanks. (BTW, I love the dd option--very clever.)

I won't be backing it up since what I have is a backup of the DB and I can eliminate the file and rebuild it and then reload the DB.

John
 
Old 10-22-2005, 07:58 PM   #5
JMCraig
Member
 
Registered: Feb 2003
Location: Utah, USA
Distribution: Red Hat EL/CentOS, Ubuntu/Debian
Posts: 113

Original Poster
Rep: Reputation: 15
Didn't manage to extend file

Well, just BTW, I didn't manage to extend the file. I tried the dd trick of writing nothing but giving the original file length. For whatever reason, it didn't work. I didn't spend much time fussing with trying to figure out why since the recovery was straightforward.

Thanks!

John
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Something easy that I forgot how to do don_dimo Linux - Software 2 10-09-2005 03:26 AM
-=-I forgot-=- Tsukasa7 Linux - Newbie 1 04-13-2005 01:32 PM
I Forgot!! :@ brazilgurl69 Linux - General 4 09-19-2004 08:39 PM
what to do when forgot your password? isamitch Linux - General 11 07-23-2004 02:57 PM
Forgot what I did machiner Linux - Newbie 2 07-22-2004 07:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration