LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 12-08-2017, 04:57 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
How to use the inode to get back a file.


Hi: I have just deleted some lines from a text file in vim, saved and quit, but accidentally. To get those lines back, given the backup is identical with the original file, I could use dd if I knew where the file is located on disk. But this information is kept in the inode so, so there is a way to get back lost data. How can I do it? Please do not suggest the use of some monster program. I only need to know the physical sector number of an existent file starting point.

Last edited by stf92; 12-08-2017 at 05:09 PM.
 
Old 12-08-2017, 06:06 PM   #2
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Well, the data is irretrievably lost. I ran hadparm --fibmap which gave the start of the file and dd to extract it. If fills 8 sectors, of which vim only used 5. The rest is filled with zeros. My data was overwritten with the zeroes. Bad luck.

EDIT: who zeroed the rest of the block? Vim or the OS?
EDIT EDIT: On second thought it would be unlikely that Vim would to that. The zeroing of the rest of the block had to be managed by the OS itself. I wonder why? I do not see the need for clearing the rest of the block.

Last edited by stf92; 12-10-2017 at 06:12 PM.
 
Old 12-19-2017, 02:43 AM   #3
ogeninfo
LQ Newbie
 
Registered: Dec 2017
Posts: 2

Rep: Reputation: 0
Thank you sir, share with me this information.
 
Old 12-19-2017, 09:08 AM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,778

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by stf92 View Post
EDIT: who zeroed the rest of the block? Vim or the OS?
EDIT EDIT: On second thought it would be unlikely that Vim would to that. The zeroing of the rest of the block had to be managed by the OS itself. I wonder why? I do not see the need for clearing the rest of the block.
When vim saves a file, it does not overwrite the original. It creates a new file and then, once that file has been written successfully, renames it over the original. The saved file uses a new inode and disk blocks, so the fibmap report on the saved file tells you nothing about where the original file was stored on the disk.

If done promptly, the debugfs utility might have allowed you to locate that original, now deleted, inode and recover the file content. By now, that data has likely been overwritten since some file allocators select from the free block list on a "last in, first out" basis.
 
1 members found this post helpful.
Old 12-25-2017, 07:22 PM   #5
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
I see.

Last edited by stf92; 12-25-2017 at 07:36 PM.
 
  


Reply



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
add more inodes to ext4 file system bradvan Linux - Server 3 04-06-2012 04:30 AM
Inodes across the File Systems bhanu001 Linux - Newbie 5 02-22-2008 08:30 AM
fsck move file when removing inodes? allasso Linux - General 2 09-26-2006 05:22 PM
How to delete a file that begins with a '-' ? Flesym Linux - Newbie 3 01-23-2006 07:01 AM
Inodes an File System Management okter Programming 1 05-13-2005 06:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 10:56 AM.

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
Open Source Consulting | Domain Registration