Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 12-23-2006, 02:54 PM   #1
LQ Newbie
Registered: Sep 2003
Location: San Diego, CA
Distribution: Mandrake
Posts: 4

Rep: Reputation: 0
Files disappeared after permission change

I'm in panic mode right now. A week or so ago, I tried to access my USB drive by way of Mandrive 2007. I'm pretty new to this, so bear with me. I had trouble with the permissions. I tried to write to the drive with some new pictures and it wouldn't let me. I tried to change the permissions of all the folders on the drive and it just wouldn't work. I gave up and came back to the problem just now. The folders are all there, but the files are gone! This is multiple GB of all my stuff and it was in transition between locations, in other words, this was my only copy. My fiance's stuff was there too. Windows doesn't see the files either.
One more thing: Windows says that the drive is half full (about what I would expect if the files were there). I feel like I just need to reestablish access to them or something.

Last edited by Nyphur; 12-23-2006 at 02:58 PM.
Old 12-23-2006, 03:56 PM   #2
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,837

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
Sorry to hear about your problems. I hope we can help you. I'm not an expert in data recovery though, so I can only give you some general pointers.

First of all, I don't know exactly what happened to you, but part of the problem is that the FAT format (which nearly all flashdrives are) does not natively support the *nix permissions system. The permissions you see are simulated through a mount option (umask) and aren't changeable with the usual chmod command. Somehow you must have corrupted your filesystem in the attempt, something that's not difficult to do with FAT. A search of the forums or google can give you info on how to handle permissions on fat drives.

Anyway, before you do anything else, do NOT mount the drive with read-write permissions (If you don't know how to manually mount drives, learn that first). In fact, you should instead use the dd command to copy an image of it onto your hard disk and work from that to recover your data. Something like: "dd if=/dev/sda1 of=/backuplocation/usbdiskimage.iso bs=512" should do (not sure if the byte count is good though. Can anyone else help me there?). This image can be generally be treated as if it were a drive device, or mounted via a loopback device.

Your first recovery option should probably be dosfsck. This tool can sometimes recover corrupted partition tables, which is likely your problem. I've managed to salvage a bad usb stick myself using it.

If that fails, you can try to recover the files individually. There are several data recovery tools out there, but the one that worked best for me is photorec, which despite the name can rescue a large number of other file types as well. It comes in a package called testdisk. There's another promising one I've found called magicrescue, but I don't have experience with that yet. Perhaps someone else can point out other good tools you could try.

I'm not going to go into details on how to use these tools; you can read the man pages yourself. Just be sure to run the recovery tool on the disk image instead of the drive itself. The worst thing is you'll probably loose all the file names and have to rename all the files manually. But at least you'll have them.

Good luck.
Old 12-23-2006, 04:02 PM   #3
LQ Newbie
Registered: Sep 2003
Location: San Diego, CA
Distribution: Mandrake
Posts: 4

Original Poster
Rep: Reputation: 0
A mistake:

I should have been more specific: This is an external hard drive formatted to FAT32.
Does this change my options any?
Also, I have written to the drive. I put some more files on there successfully.
Old 12-23-2006, 08:53 PM   #4
Senior Member
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 115Reputation: 115
Your partition table isn't hosed, your file allocation table (FAT - get it?) is hosed. Writing to the drive has probably caused you to experience some data loss.

Stop writing to the drive, period. The instructions you were given for recovery were good ones; the 512 block size should be fine. Image the drive to someplace on a Linux HD, then mount the image and work on that.

In the worst case, after you have an image that you know is faithful, mount the drive on a windows machine and run scandisk or chkdsk (as appropriate, depending on the version of windows).
Old 12-23-2006, 09:01 PM   #5
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Ditto the advice already given: If you are going to have any hope of recovery, do not use the drive anymore--particularly for writing.

If you are going to attempt recovery yourself, then making a clone first would be highly recommended.

An--don't attempt recovery unless you are willing to learn a whole bunch of minutiae about partitions and filesystems and are willing to invest the time. Ohterwsie, get it to a professional.
Old 12-23-2006, 10:09 PM   #6
LQ Guru
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 235Reputation: 235Reputation: 235
My advice, always make a backup copy of data you never want to lose. Don't ever think that the hard drive or whatever won't fail on you on that given day, because it could happen at any given day or time..
Old 12-24-2006, 12:29 AM   #7
LQ Newbie
Registered: Sep 2003
Location: San Diego, CA
Distribution: Mandrake
Posts: 4

Original Poster
Rep: Reputation: 0
Thank you all. I am going on vacation tomorrow, so I will not be able to start on your suggestions right away (nor will I be able to sleep well at night with this all messed up), however, it will be high priority for me when I get back. I will repost with more questions and results when I have them.
Again, thanks.
Old 12-24-2006, 10:07 AM   #8
Senior Member
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 115Reputation: 115
FAT is usually easy to recover. You'll get the files back, most likely. You won't get a lot of the file names back and if they are images you'll have to browse all these images with funky names like chk0001 and see what they are, then name them.


filesystem, mandriva2007, permissions

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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need ACCESS to change files! Every time I try to change a setting,"Permission Denied" Balarabay1 SUSE / openSUSE 2 03-06-2006 10:54 AM
rox + recursive permission change for FILES only? NonSumPisces Linux - Newbie 9 08-11-2004 08:21 PM
how to change exisitng files/directory permission from 755 to 770 mweil Linux - Newbie 3 07-01-2004 11:18 AM
Files disappeared after update mikelds Linux - Newbie 4 05-11-2004 05:19 AM
My song files just disappeared from my hard drive? timberwolf Linux - General 6 12-21-2003 08:58 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:22 AM.

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