maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   N900 vs. copier/scanner (https://talk.maemo.org/showthread.php?t=96897)

chill 2016-06-24 09:09

N900 vs. copier/scanner
 
I plugged the N900 into a copier/scanner machine, wanting to use it as the medium to save a scan. After unplugging (the copier did not prompt me to eject the medium), it looks like everything in MyDocs was destroyed: all the photos in DCIM, Images, my documents, nothing is there anymore.

iHaveNoNames 2016-06-24 11:13

Re: N900 vs. copier/scanner
 
Maybe just unmount during the eject process. MyDoc must be mount like a FAT32 partition.

pichlo 2016-06-24 11:45

Re: N900 vs. copier/scanner
 
It sounds like a corrupt partition. The scanner may not have prompted you but there must be an option to safely remove the medium. If all else fails, at least wait a few seconds between the end of the last operation and removing the medium. By "a few" I mean at least 30.

Do you need the data or are you happy to reformat the partition and start over? I have always been able to restore lost data but exactly how to do that differs from one case to another so I cannot give you a generic recipe. You must not be afraid to get your hands dirty and dip deep into the command line and sometimes even a binary editor.

The first thing to do would be to backup your MyDocs partition to avoid any more data loss. You will need at least 27GB of free space on your backup medium to do that. Put an empty, large (32GB+) SD card in your phone and run this from the terminal:

Code:

root
umount /dev/mmcblk0p1
dd if=/dev/mmcblk0p1 of=/media/mmc1/mydocs.backup bs=1M

Then remove the card. If the data recovery works, you can delete the backup.

Next, you can try fixing the corruption by the easiest method of them all - plug it into a Windows PC and run a disk check on it. If that does not work, look up one of the many threads dealing with data corruption and start from there. Michaaa62 usually gives excellent advice, like for example here.

robthebold 2016-06-24 13:49

Re: N900 vs. copier/scanner
 
Quote:

Originally Posted by chill (Post 1508265)
I plugged the N900 into a copier/scanner machine, wanting to use it as the medium to save a scan. After unplugging (the copier did not prompt me to eject the medium), it looks like everything in MyDocs was destroyed: all the photos in DCIM, Images, my documents, nothing is there anymore.

Don't panic, don't do anything rash. MyDocs might not have gotten remounted by the phone if the scanner wasn't playing nice. If that happened, you'll just see what's in an Actual MyDocs directory -- which could have stuff that got saved there when MyDocs was mounted by another host some other time -- rather than the partition that's usually mounted over it. It'll look like everything's gone when it isn't. Try remounting MyDocs or just restart the N900.

If the worst happens as pichlo hypothesizes, you can use photorec and testdisk on the dd copy of the partition. You can probably even use "ddrescue" instead of "dd" if you've got a Linux desktop handy, it's more robust and can skip over (and even retry) bad blocks.

But first, don't panic.

chill 2016-06-24 13:54

Re: N900 vs. copier/scanner
 
The scanner didn't have a prompt for safe removal. It only said not to remove while it was saving the file; I don't know if I waited 30 seconds after it was done saving.

I've done a windows PC disk check and am now stuck with a bunch of .chk files. I am sensing a reformat or a reflash in the near future.

P.S. There is nothing to backup from MyDocs, everything is gone.

nodevel 2016-06-24 14:07

Re: N900 vs. copier/scanner
 
This happened to me more than once on the N900 (I was just as scared first time it happened) and regular fsck always fixed it.

I think I had done it using my Linux desktop I connected it to via USB, but trying fsck on the N900 as I type, it looks like it's available there as well (at least with KP 53).

pichlo 2016-06-24 14:11

Re: N900 vs. copier/scanner
 
Quote:

Originally Posted by chill (Post 1508280)
The scanner didn't have a prompt for safe removal. It only said not to remove while it was saving the file; I don't know if I waited 30 seconds after it was done saving.

Sounds like a warning to avoid that scanner model. Can you share which one it was?

Quote:

I've done a windows PC disk check and am now stuck with a bunch of .chk files. I am sensing a reformat or a reflash in the near future.
How many? Windows' disk check creates those from FAT chains it cannot identify as belonging to any particular file. It's usually just one or two, rarely more than a single digit number. More than that usually indicates a serious corruption.

Quote:

P.S. There is nothing to backup from MyDocs, everything is gone.
The command I posted above would backup the whole partition at a low level, byte by byte rather than file by file. Perhaps I should have that clearer. You may now be stuck with the CHK files, trying to figure out what each one is and renaming them accordingly.

Quote:

Originally Posted by nodevel (Post 1508283)
This happened to me more than once on the N900 (I was just as scared first time it happened) and regular fsck always fixed it.

I think I had done it using my Linux desktop I connected it to via USB, but trying fsck on the N900 as I type, it looks like it's available there as well (at least with KP 53).

Yes, the michaaa62's post I linked above uses fsck on the device.

IIRC there was some problem with the fsck's reliability on the N900 but I think it was fixed at some point. Though I do not remember when exactly.

robthebold 2016-06-24 14:38

Re: N900 vs. copier/scanner
 
Quote:

Originally Posted by chill (Post 1508280)
P.S. There is nothing to backup from MyDocs, everything is gone.



Do the "dd" pichlo suggested and work with the image file that creates, not the MyDocs partition. I was too specific (and Linux-chauvinistic, I guess) above, there's a version of photorec for Windows (and Mac, Solaris, etc., etc) too. It's available from the cgsecurity webiste. You'll get most of your stuff back, although you may lose the filenames. The name "photorec" not withstanding, it can recognize lots more than just photos.

michaaa62 2016-06-24 18:40

Re: N900 vs. copier/scanner
 
Try to check the file system either from a linux machine (you need backupmenu installed, to work outside the maemo system) or the n900 itself with these commands:
Code:

sudo gainroot
umount /dev/mmcblk0p1
fsck -af /dev/mmcblk0p1
mount /dev/mmcblk0p1 /home/user/MyDocs

If errors remain during the fsck command, you might try thr -r option for fsck. After no more errors mount the MyDocs partition or reboot the n900.

chill 2016-07-12 17:53

Re: N900 vs. copier/scanner
 
I used Windows to find and repair the errors. I did this before getting the advice above. Otherwise I would have followed.

I have now ended up with a bunch of .chk files that windows cannot see when the device is connected to the PC.

I subsequently used fsck but I just got the unable to create a unique name error.

I'll get the name of the scanner when I get back to work.
EDIT: Canon iR2525.

endsormeans 2016-07-12 18:14

Re: N900 vs. copier/scanner
 
N900 vs copier / scanner ....
hmmm....

ready...
Fight!....

https://s26.postimg.org/v8kbn55ll/TWL.png

:D

chill 2016-10-11 18:26

Re: N900 vs. copier/scanner
 
I'm still stuck with a bunch of .chk files that the PC can't see, and nothing else. Please help.

michaaa62 2016-10-11 19:00

Re: N900 vs. copier/scanner
 
These are residual files of the file system corruption, that Windows could not handle easily. There are a couple of windows tools around, that try to find the right file type for this collected 'garbage'. Just try to search the web for '.chk files'

chill 2016-10-13 06:00

Re: N900 vs. copier/scanner
 
Thanks, I did, but they cannot even be seen by the PC.

sulu 2016-10-13 07:20

Re: N900 vs. copier/scanner
 
It seems you won't be able to copy the files via USB. (I never really figured out what kind of logic/magic is going on there).

Instead I'd try to get the files off the device another way - either by copying them to a µSD card or via some sort of network connection (e.g. an sshfs mount).
Then you can run the file command on each of the files to determine their magic blocks, which will give you an output like this:
Code:

$ file somefile 
somefile: JPEG image data, JFIF standard 1.01

Now I know "somefile" is a jpeg picture, so in the best case I can just rename it to "somefile.jpg" and open it with any picture viewer.

pichlo 2016-10-13 07:49

Re: N900 vs. copier/scanner
 
I had a similar case once. A different set of files seen by the phone than seen by the PC in mass storage mode.

The reason is simple although it may sounds a bit complicated to a layman.

Historically, there have been essentially two types of storage: floppies and hard disks. A floppy has a small capacity and is treated as a single storage unit. It has some metadata describing the physical layout (most commonly the File Access Table, or FAT), followed by the data themselves. It may look something like this (PT = Partition Table):

Code:

+---------+--------------------------------------------+
|  FAT  |                    Data                    |
+---------+--------------------------------------------+

(Please note that this is a simplification. "FAT" is just one of a number of possible types of metadata and "Data" includes all data, i.e. files as well as directories.)

The other type of storage is the hard disk. Hard disks are several orders of magnitude larger than floppies. It was considered a good idea to have a mechanism to split the capacity into a number of smaller units, each with its own file system. These units are called "partitions". As the time progressed, the importance of partitions has grown. Nowadays, every computer is shipped from the factory with a number of partitions, each with a different purpose (boot, data, recovery, swap...).

Now, you need some global metadata (called the partition table) describing where the partitions are plus each of these partitions needs its own metadata describing its physical layout. So the picture may look something like this:

Code:

+--+--------------------+--------------------+---------+
|  |    Partition 1    |    Partition 2    |  etc  |
|  |+---+--------------+|+---+--------------+|        |
|PT||FAT|    Data    |||FAT|    Data    || ....... |
|  |+---+--------------+|+---+--------------+|        |
+--+--------------------+--------------------+---------+

Memory cards, USB memory sticks etc.use both layouts. They are usually shipped with the "big floppy" layout but they can easily be converted to the "hard disk" layout by the end user with the proper tools.

In the N900, you have three partitions. The first one is the largest one at 27GB and contains all your pictures, videos, music etc. This partition is exposed to the PC in mass storage mode.

But the PC does not know that it is a partition. All it can see is the red bit. Does that look familiar? If not, then it should. It is the exact replica of the first picture, i.e. what the floppy looks like. To the PC, the N900's storage looks like a large floppy.

Now image a serious data corruption, to the extent that the PC cannot figure out what the hell is going on. You run some recovery tool and that tool decides that the situation is beyond repair. In some cases, the corruption may even fool the PC into thinking that it is dealing with the "hard disk" layout and not the "big floppy" one. So the recovery tool proceeds to "fix" the partition table and you end up with the situation like this:

Code:

+--+--------------------+--------------------+---------+
|  |    Partition 1    |    Partition 2    |  etc  |
|  |+--+---------------+|+---+--------------+|        |
|  ||  |+---+---------+|||  |              ||        |
|PT||PT||FAT|  Data  ||||FAT|    Data    || ....... |
|  ||  |+---+---------+|||  |              ||        |
|  |+--+---------------+|+---+--------------+|        |
+--+--------------------+--------------------+---------+

See the problem? You have a partition table inside a partition. This is illegal and the phone, which sees the whole layout, will get rightfully confused. The PC, which can see only the red part of the layout, can see nothing wrong. As far as the PC is concerned, it has a perfectly valid USB mass storage attached, with a partition table and a single partition.

For several reasons that are too technical to go into (even more than the above tirade :)), you may easily get into a situation when the phone not only does not know that you have a nested partition; to the phone, Partition 1 actually looks like a perfectly normal partition, with a valid FAT and data. So the phone can see a full set of files. The PC, however, can see a different FAT describing the same area and it can see a different set of files. Funnily, both can happily coexist for a while but since none of them knows about the other one, the areas that one thinks are empty can be already claimed by the other one and if you use either of them to write onto the medium, you inevitably create more corruption.

The solution is not very easy. I ended up writing my own CLI program to locate both FATs (one seen by the phone and one seen by the PC) and update one using data from the other. The result was that the PC could see exactly the same files as the phone. The layout was still wrong so I had to copy the files off, reformat the storage and copy the files back. I lost some of the data but managed to save most. The CLI tool was very crude as it was meant for a single job, definitely not for public consumption. It required some manual assistance and understanding of what you are doing. It was a lot of work and I would not want to go through it again, so now I am a bit more cautious and backup more frequently. If a similar corruption happens again, I just reformat the damn thing and restore from the last backup.

chill 2016-10-22 18:36

Re: N900 vs. copier/scanner
 
Quote:

Originally Posted by sulu (Post 1516663)
It seems you won't be able to copy the files via USB. (I never really figured out what kind of logic/magic is going on there).

Instead I'd try to get the files off the device another way - either by copying them to a µSD card or via some sort of network connection (e.g. an sshfs mount).
Then you can run the file command on each of the files to determine their magic blocks, which will give you an output like this:
Code:

$ file somefile 
somefile: JPEG image data, JFIF standard 1.01

Now I know "somefile" is a jpeg picture, so in the best case I can just rename it to "somefile.jpg" and open it with any picture viewer.

I tried. cp said it was skipping the two folders containing the .chk files. Then I tried mv instead, at which the phone froze and then shut down. I guess it was a reboot that didn't do the boot up part.


All times are GMT. The time now is 18:13.

vBulletin® Version 3.8.8