You are not logged in.

#1 2017-04-24 12:11:23

CaptainKirk
Member
Registered: 2009-06-07
Posts: 391

My PC "Breaks" Camera Cards :(

My PC (64 bit, all up to date and rebooted since the last updates Friday and no updates run since) has a problem that, sometimes, if I try to write to a camera card, the card formatting somehow gets broken and no longer works in the camera. To format it fresh, it also usually only works if you do that in the camera itself -- when I try from my PC (using the correct format) it fails.

So generally before I write to a card, I copy the whole thing to my PC, in case I will break it.

Last night, a friend stopped over and asked me to copy just a few images from his card and email them urgently. I put the card in my USB hub via a little reader I have, and it was mounted automatically, and we looked at one folder of 100 images, copied 20 to my PC and then I umounted it manually.

When he got home, he said the card won't work in his camera nor in his Windows PC -- both say it must be reformatted. sad

It may be worth noting that when I use Thunar to umount via right click on the device and then "eject" or "unmount" it takes like 5 or 10 seconds so I generally do it manually instead. This is what I did last night:

[kirk@arch nextcloud]$ sudo lsblk
[sudo] password for kirk: 
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465.8G  0 disk 
├─sda1   8:1    0 282.4M  0 part /boot
├─sda2   8:2    0  18.6G  0 part /
├─sda3   8:3    0  93.1G  0 part /srv
└─sda4   8:4    0 353.7G  0 part /home
sdb      8:16   0 931.5G  0 disk 
├─sdb1   8:17   0 282.4M  0 part 
├─sdb2   8:18   0  18.6G  0 part 
├─sdb3   8:19   0 205.2G  0 part /home/kirk/Disk2/sdb3
├─sdb4   8:20   0     1K  0 part 
└─sdb5   8:21   0 210.9G  0 part /home/kirk/Disk2/sdb5
sdg      8:96   1  14.9G  0 disk 
└─sdg1   8:97   1  14.9G  0 part /run/media/kirk/3963-3231
[kirk@arch nextcloud]$ sudo umount /dev/sdg1

Here is dmesg -T, that part that appears to be relevant: https://pastebin.com/8ZUxEMv9

I realize that information may be missing here, and he is bringing me back the card today, but I have a few questions:

1. Can anyone suggest why when I write to such cards, they usually break?
2. Do you know why this one got broken just via my reading from it? I'm guessing if I had just removed it without unmounting, it would not have gotten broken...
3. Is there an easy way to fix his card? I can recover the files, but last time I did that, it was a bit of a pain as it created 2 or 3 copies of each image. sad

Thank you for any ideas!

Offline

#2 2017-04-24 12:58:02

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: My PC "Breaks" Camera Cards :(

1. If the large amount of "reset high-speed USB device number 6 using ehci-pci" didn't give away immediately I'd say it's probably a bad/broken card reader or bad cable. Have you tried with a different card reader?
2. It most probably got mounted rw, even if you "just" read from the card there is still some information that will be written.
3. Maybe, but I'd recover all the images and format it again just to be sure there will not be any bad surprises later.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#3 2017-04-24 13:07:48

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: My PC "Breaks" Camera Cards :(

CaptainKirk wrote:

It may be worth noting that when I use Thunar to umount via right click on the device and then "eject" or "unmount" it takes like 5 or 10 seconds so I generally do it manually instead.

So you intentionally circumvent a program that should do things correctly as it is inconvenient to wait 5 seconds for Thunar to safely unmount/eject the card?  Instead you bypass the safe unmounting process and wonder why there's a problem?

I'm generally not a fan of gui tools for things like this as the cli commands give you more power.  But with great power ...

The proper way to unmount external media is to include the `sync` command.

This *shouldn't* really matter if you've only read from the device and not written to it, but it would seem in this case it does (see point 2 in the above post - maybe last access times or something similar are updated).


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2017-04-24 14:16:58

CaptainKirk
Member
Registered: 2009-06-07
Posts: 391

Re: My PC "Breaks" Camera Cards :(

R00KIE wrote:

1. If the large amount of "reset high-speed USB device number 6 using ehci-pci" didn't give away immediately I'd say it's probably a bad/broken card reader or bad cable. Have you tried with a different card reader?

Right, I thought maybe that was it also. sad

My other one broke so I will go and buy a new one now. Thank you.

Trilby wrote:

So you intentionally circumvent a program that should do things correctly as it is inconvenient to wait 5 seconds for Thunar to safely unmount/eject the card?  Instead you bypass the safe unmounting process and wonder why there's a problem?

I am not trying to circumvent anything nor do anything "incorrectly." I thought umount was the correct way to unmount a device actually. I don't think that I am wrong either.

Trilby wrote:

The proper way to unmount external media is to include the `sync` command.

This I have never read anywhere, nor do I see any suggestion of such here:

https://wiki.archlinux.org/index.php/US … ge_devices

With USB drives I never once had a problem and I have never run the sync command because I have never even heard of it until today. I am not a Linux expert but I certainly know the basics.

I actually see here:

https://unix.stackexchange.com/question … ing-writes

that umount automatically runs sync first and there is thus no need to run it manually.

Can you clarify what you mean and perhaps show me the docs so I can understand better why umount is not correct and not sufficient?

Thank you.

Offline

#5 2017-04-24 14:21:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: My PC "Breaks" Camera Cards :(

If that post is correct and umount does flush the filesystem (the equivalent of sync) then I'd be wrong - sorry for the noise.

However, Thunar is not likely just keeping you waiting for the fun of it.  It is doing something that likely ensures the cards is properly ejected/unmounted.  This is simple to test: unmount from Thunar and wait for it to finish before removing the device.  If this works, we'll have narrowed down the problem.

It's also quite possible that Thunar does something else when mounting: you mount with Thunar but umount manually - pick one or the other.  If thunar mount and eject (and waiting for the eject) works the next test would be to manually mount and umount and see if that works.

I could be wrong about 'sync', but my larger point remains that you use one tool to mount (and possibly move files) but yet you circumvent that tools safety checks for unmounting - this is not a good idea.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2017-04-24 15:41:33

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: My PC "Breaks" Camera Cards :(

I believe umount will flush/sync everything that is pending to disk before returning the prompt and I suppose that is why thunar will keep you waiting. If you want to be double sure that everything is written to disk/card before you remove it then issue a sync before and after umount.

You might also want to either eject or 'udisksctl power-off -b /dev/sdX' before you remove the card.

But like I've said before, the high number of resets would make me suspect more of a hardware problem than a problem with umount. There is also the possibility that card reader might need a quick to work properly, if it worked well before try with an older kernel/with other distros/other OS and see if there are still problems.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#7 2017-04-25 12:29:29

CaptainKirk
Member
Registered: 2009-06-07
Posts: 391

Re: My PC "Breaks" Camera Cards :(

Trilby wrote:

It's also quite possible that Thunar does something else when mounting: you mount with Thunar but umount manually - pick one or the other.

No, Thunar does not mount a USB device. See here https://wiki.archlinux.org/index.php/US … ge_devices for how auto-mounting works.

Thunar is simply launched to show me the newly mounted device, that's all. Using auto-mount and then manually using umount to unmount works fine for USB devices. The only issue has been camera cards.

R00KIE wrote:

But like I've said before, the high number of resets would make me suspect more of a hardware problem than a problem with umount.

Yes, that was definitely it. For $2 I got a new one and the first test worked fine.

Thank you!

Offline

#8 2017-04-25 12:44:51

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: My PC "Breaks" Camera Cards :(

I'm glad Rookie's suggestions were helpful.  And I have no problem conceding that my suspicions were incorrect now that Rookie's approach solved the problem.  However, until now there was no compelling evidence against my suspicion.  Yet rather than do some simple tests as I suggested to confirm or reject my hypothesis, you instead argued and patronized.  This is not a good strategy here.  I will certainly not bother to offer my input to your threads in the future.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB