Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy file / directory by inode number

Status
Not open for further replies.

tcase

Technical User
Jan 28, 2002
4
IE
Can anyone tell me if it is possible to copy a file / directory by its inode number?

I have a corrupted file system which fsck has problems fixing. I have run ncheck on the filesystem and have a list of inode numbers for most of the files on the drive. I now need a way to get at those files, copying them to another working filesystem was what I had in mind.

If anyone can be of assistance I would be most gratefull.

 
Not sure what you are trying to achieve here ?
I presume this is not the boot filesystem, but a data only filesystem ?
Does it mount ? , if you cannot mount it until you fsck it, and thus you ahve the problem, you have no alternative but to let fsck attempt the repairs. as without it, it cannot be accessible.

In any case, if fsck cannot fix it, then consider that file lost anyway !!. Eg. if fsck says a filesize is 0, its more thank likely lost.

Any files it has not lost, but does not know what to do with, it should move them to the filesystems local "lost+found" directory. The filename will be changed to the Inode number.
Moving this file back to the original location may work.
But personally, i would consider any deleted/damaged files duff and resort to a backup.

Hope this helps.
Regards
UkWizard.
 
usual story - user did not backup all files!!

The data is not on the root file system instead a separate /u data filesystem.

Filesystem does mount, just the directory is totally empty (sing ls returns a reply of notfound). When fsck runs it clears a lot of files, but the directory (mount point) remains empty - not even lost+found appears using ls. again using ncheck I can see the files are there, but need some way to get at them by inode number.

thanks for the advice though. any further advice is always appreciated

tcase
 
I am more confused now, whats "sing ls" mean ?

You do know that the fsck must be run on a filesystem that is NOT mounted, dont you ?

Reboot into single user mode, and run a full fsck on the /dev/u filesystem. If it scans okay, mount it, then see if you can see any files.

If you cant see any, then you are probably screwed.

Let me know what happens ?, im curious now :)


Regards
UkWizard.
 
sorry, UkWizard, my typo .. "sing ls" should read "using ls" ie using the ls command.

I did know that the the filesystem should be unmounted before running fsck.

After fsck has completed, despite all the error messages about to many bad files there is still nothing to be seen in the /u directory (after re-mounting of course).

However out of curosity I ran ncheck once more on the filesystem. This time a lost+found directory could be seen listed within the /u structure. I was able to change directory to the lost+found only by typing the full path of the directory ie cd /u/lost+found (just typing cd lost+found would not work from the /u directory - the directory structure must still be very messed up).

From the lost+found directory I was able to salvage about 80% of the missing data - the majority undamaged but a number containing some data plus some additional damage.

I would still like to know how to get at a file by its inode number. A lot of data was listed by ncheck before fsck did its work and deleted what it thought was bad (ncheck after running fsck listed fewer files).

I still have a copy of the hard drive to play with before anything was done to try and fix it so if anyone has any more ideas about copying or moving a file by its inode number I would love to hear from them.

regards tcase
 
I'm not sure it will help in your situation, but find /somewhere -inum number will tell you which file occupies that inode number. It probably won't work on a damaged filesystem though... Annihilannic.
 
Annihilannic

ncheck also gives the same information - filename & inode number, even on the damaged file system. My question is how to move or copy the files once I have the inode number
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top