LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 09-30-2004, 03:34 AM   #1
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
Exclamation Need help from a FileSystem Expert (for SDcard FAT)


Hello,
First, let me say I'm not a newbie.

I have a SDcard-based CoolPix 3700 digital camera with a 256MB card. On this card, I put 2 jpg and 1 mov (using CP=CoolPix). Then suddenly, the CP told me: "this card cannot be used", and it appeared empty! I thought, 3 files' not a lot, I let it go.

I went on holiday and took tens of jpg and some mov using the same "now-empty" SDcard. I browsed the new files each evening, and all was OK. Back home, the CP suddenly did it again: "this card cannot be used" (it is clear it is a bug from the CP...). And all was gone again! This time it was not only 3 files, so I plugged it on the PC, and here strange things began:

First I must explain the layout for the CP's fat16 filesystem. There's a "dcim" directory containing the data, and another containing meta-data (let me call this one xxxx as I don't remember the name).

I had already used this card, as well as another, and put the pictures on the PC through the USB cable (/dev/sda1 hotplugged), without any problem. Each time I had:
Code:
/mnt/removable# ls
dcim/  xxxx/
But this time:
Code:
/mnt/removable# ls
dcim/  dcim/  dcim/  xxxx/
And find . , as well as ls -R are consistent! Except the content of dcim appears to be the same for each dcim. However, ls[tab] only displays: dcim xxxx.
And guess what are the files inside dcim? Those are the 3 files of the start! Those I thought were lost forever and I did not care much about. And all along while storing new photos on the CP, those 3 files were not there, I'm positive about it!

I know nothing about filesystems, and I had always thought this was impossible, but IMHO:
the CP created dcim and xxxx. 3 files were created. The bug striked for the first time and dcim was somehow created again:
- masking the old dcim, from the CP's point of view, but
- being masked by the old dcim from the PC's point of view.
I took new photos and videos. Then the bug striked for the second time, and dcim was created again:
- masking again (so empty), from the CP's point of view, but
- still masked by the first dcim from the PC's point of view.

That's the only reasonable explanation I have. I tried manually creating a new device (same major, minor+1) for a supposed /dev/sda2. But I got nothing. So I dd if=/dev/sda of=cp.img the whole card, and looked at it with fdisk. And inside, there's only one partition. This makes me think there's indeed only one partition with a "strange" filesystem on it. BTW, I still preciously keep the cp.img file.

Note, however, that when I bought the SDcard, it was preformated, and I had no problems with it. When I needed space, I deleted files one by one. Problems began after I deleted everything by reformating the card using the Coolpix.

Well... you guess why I need a filesystem guru: I'd like to somehow get access to the (IMO) hidden files... Thanks for any hint, any suggestion. I'll try and do my best from even the slightest idea of a possibility...

Yves.
 
Old 09-30-2004, 10:33 AM   #2
maroonbaboon
Senior Member
 
Registered: Aug 2003
Location: Sydney
Distribution: debian
Posts: 1,495

Rep: Reputation: 48
Good luck on finding your filesystem expert! In case there are no takers here's some suggestions from a non-expert...

1. You can probably use the loopback device to mount your image file with 'mount -o loop cp.img /mnt' or similar, so you play with it as if it was the original card. Best make a another copy first of course.

2. Then you could try deleting or renaming the apparently duplicated directory, to see if the other shows up in its place.

3. If no luck you could try one of the Windows file recovery tools. I have tried a few of these and found the free 'Zero Assumption Recovery' (check Google) to be very effective. I think maybe it only recovers JPEGs, so you might not get your movies back.

4. Failing all that, the FAT16 filesystem must be well-documented somewhere, and with a hex editor and the loopback device it might be easy to check it out and do some experiments.
 
Old 10-01-2004, 02:12 AM   #3
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Original Poster
Rep: Reputation: 66
Yes! 1+2 is an excellent idea. I'll try this one. Keep the ideas coming!

Yves.

[Edit]Eh, wait! How do I do that? My file is not a filesystem image. It is a disk image that contains one partition (that why I looked at it with fdisk).

How do I use the loop device to open the first (and only) partition that is contained in this file? Is there some kind of offset to give? Or should I somehow dump the partition to another file, and then open this one?

Last edited by theYinYeti; 10-01-2004 at 02:24 AM.
 
Old 10-01-2004, 10:12 AM   #4
maroonbaboon
Senior Member
 
Registered: Aug 2003
Location: Sydney
Distribution: debian
Posts: 1,495

Rep: Reputation: 48
Good point. Yes I think you can do 'dd' with 'if=/dev/sda1' instead. Also I think it is probably a good idea to specify block size and count for dd. I guess fdisk will give some clue what to use. I seem to recall using dd to rescue a CF card and getting a short read at first.

Bon chance!
 
Old 10-04-2004, 04:09 AM   #5
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Original Poster
Rep: Reputation: 66
Well, I had this same idea before reading your last post, except I did not look for any special parameter... it worked! Here's what I did:
Code:
# dd if=/dev/sda1 of=sda1.img
# mkdir tmp
# mount -o loop sda1.img tmp
# cd tmp
# mv dcim dcim02
# mv dcim dcim01
# ls -Ra
And guess what? dcim contains the initial 2 jpg and 1 mov, dcim01 contains all my holliday jpg and mov, and dcim02 contains nothing (I had not taken any photo after the second bug).

That's the definitive proof, that I was right, and that your idea saved my files! THANK YOU VERY MUCH maroonbaboon !!!!

Yves.
 
  


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
SDCard Partition Problems ch4se Linux - Hardware 1 08-14-2005 07:44 PM
Use of FAT filesystem pwardy Linux - Software 5 01-31-2005 01:57 PM
How to debug Linux FAT filesystem code? ashishkumbhare Programming 2 04-14-2004 02:16 PM
i want to compile fat file system module and get fat.o working ramya272 Linux - Newbie 9 02-26-2004 11:41 AM
Access attributes & ownership on FAT filesystem correro Linux - General 2 03-18-2003 08:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 08:49 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