LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 10-24-2014, 12:50 PM   #1
sulobaidsuevin
Member
 
Registered: Jan 2014
Distribution: Debian Kali Linux 1.0 -Custom Brew ;)
Posts: 35

Rep: Reputation: Disabled
SD cards File system bricking up - 6th time now!


This has been an ongoing issue of mine for over a year, i can not seem to find ANY reasonable help on anyware so i am trying here. If more info is needed, (depending on the info requested,) let me know and i may provide it.

At first, i suspected a crypto virus but its not. Many scanners which claim to specialize in the removal of such viruses report a clean bill of disk health. I mean over a dozen. So there is that. After some time and use, encrypted or not aparently as of today, my SD card i leave in my PC, which disk health is good,) refuses file permissions, refuses to allow changes and even won't open some of my folders. I can't change it by normal means and now just want my disks and content back safely. I have 2 machines, one Linux and the other windows but the problem originated on Linux. Windows is thus far of no help. I have no idea how to use dd and its a bit above my outright ability to safely do. I am gonna need a bit of a walk-threw. All 6 mini SD cards were harmed by something going on in this Linux system, dunno what but running TigersSecurityTool it shuts down half way threw its scan, not cool. Many things suspect ho0wever i don't wanna hear the usual cop out "Reinstall". Thats b.s.! I'll be greatfull for REAL help and not the usual, this is not a normal system or issue so heads up on that however normal repair ideas may aply still, so what am i missing?

Thanks.

P.S.:
I have several cards ranging from 64GB to 32GB one of them has my daughters pictures and medical info on, she died a few months ago and it would be good to rescue the contents as it was not backed up before it was too late and this all happened before i knew anything. It was the first. I really want those pictures back.
 
Old 10-24-2014, 01:01 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
I can't help with identifying the cause, but your best hope of recovering the data is a combination of dd and testdisk/photorec.

Use dd to back up the SD card to a local file, so you don't risk further damage to the card. Then you can use testdisk/photorec to scan though it to pull out files.

dd is easy to use for simple things like this, just do the following (assuming sdb is your SD card):
Code:
dd if=/dev/sdb of=$HOME/sdbackup.bin
Just make SURE you do NOT swap the if and of flags.

This will create a byte-for-byte copy of the SD card to $HOME/sdbackup.bin, regardless of its partitioning information, filesystem, etc. Once you have this backup, then use photorec:
Code:
photorec $HOME/sdbackup.bin
See here for more info on photorec:
http://www.cgsecurity.org/wiki/PhotoRec_Step_By_Step

If the SD card has some physical problem though, dd may error out trying to read it.

I have only used photorec once, but it was 100% successful. I was in Antarctica and had just moved about 100 priceless pictures from my camera's SD card to the computer and deleted them off of the SD card. A script I had written to rename the files and convert to jpg malfunctioned (user error) and ended up deleting all of the pictures from the computer. I used dd to back up the SD card (as described above), and then used photorec to recover the images off of the dd image (also as described above). I lost the filenames, but everything else worked perfectly.

Last edited by suicidaleggroll; 10-24-2014 at 01:09 PM.
 
Old 10-24-2014, 01:40 PM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
hmmm. are you using these sd cards in an android phone, perchance?
because i've heard weird things happening with that usage scenario.
 
Old 10-24-2014, 02:11 PM   #4
sulobaidsuevin
Member
 
Registered: Jan 2014
Distribution: Debian Kali Linux 1.0 -Custom Brew ;)
Posts: 35

Original Poster
Rep: Reputation: Disabled
suicidaleggroll - Your EXACTLY what i needed thank you so very much. Yes, it is sdb but after this is done how would i go about re-alighning the 0 sector to were it should be as it is displaced with dd since it aparently the only thing i can use for this. Honestly, i downloaded a copy of the dd manual's and it gave me many headaches trying to descipher a seeingly simple proscess as you described and i had hoped some one like you could translate it from the greek it is to english as you have done. I been struggling with that. Your awsome - thank you x infinity.

ondoho - It is a Panasonic Toughbook CF-30, custom made/reverse engeneered running Ubuntu with a "Sandboxed" user account containing Debian Wheezy/Sid but the Sid half is off in the software sources list intentionaly. The SD card is currently a encrypted mini 32GB which usualy remains unmounted and can only be mounted manyaly which i keep my real data in for security sake.

Of note:
I am awaiting a new keyboard and a part for the PCMI card slot, the 32GB card in that slot won't read. It had 7+ Virtual Machines on it used for testing, development and learning.
I only ever get one error and it is intentional for stabalization: "ErrorMain: Second argument to lang.bind() must be a function not an object." -This was intentional.
 
Old 10-24-2014, 02:37 PM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by sulobaidsuevin View Post
but after this is done how would i go about re-alighning the 0 sector to were it should be as it is displaced with dd since it aparently the only thing i can use for this.
I'm not sure I understand the question. The command I posted will not write/replace/displace anything on the SD card, it's read-only. dd will only write to the device/file given by the of flag, in this case it would just create a binary file in your home directory.
 
Old 10-24-2014, 02:40 PM   #6
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
You should use ddrescue when imaging a failing device.
 
Old 10-24-2014, 08:41 PM   #7
sulobaidsuevin
Member
 
Registered: Jan 2014
Distribution: Debian Kali Linux 1.0 -Custom Brew ;)
Posts: 35

Original Poster
Rep: Reputation: Disabled
suicidaleggroll The way i understand my issue thus far is a matter of complex partition alighnment, i imagine it as 2 plates as one read/write surface alike to the platters in a normal hard drive but solid state would be a mini sd card i think. If both plates are not in sync the drive becomes write only, the farther apart they are the worse it gets and data is almost like smeared, won't read. Files/folders won't open then. I have one brand new 64GB mini SD card that happened to and the others are as suspect. I may only get one shot at this so i got'ta make it count. If i can re-alighn that on Linux using dd as its said can be done after i get the data back then i can rescue the sd and let it be until i find the cause some how. I reaserched this for off and on maybe months, dd was the only cure i was told but never had got unstuk from stupid reading it, its like trying to learn Python. Lol. I also do not have enough space to clone the files as you indicated to my primary space were the Linux i use is. Not sure if i should use an external drive or not. If yes, do i need to empty it first?

metaschima What? I have a failing hard drive i had to remove, on my fallback system really. Its not dead yet but should i have hope? I did not think it could save a failing disk. Really?

Last edited by sulobaidsuevin; 10-24-2014 at 08:44 PM.
 
Old 10-25-2014, 10:33 AM   #8
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by sulobaidsuevin View Post
metaschima What? I have a failing hard drive i had to remove, on my fallback system really. Its not dead yet but should i have hope? I did not think it could save a failing disk. Really?
If it's not dead, there is hope of getting your data. It cannot "save" the failing disk, it is doomed.
 
Old 10-25-2014, 04:53 PM   #9
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by sulobaidsuevin View Post
suicidaleggroll The way i understand my issue thus far is a matter of complex partition alighnment, i imagine it as 2 plates as one read/write surface alike to the platters in a normal hard drive but solid state would be a mini sd card i think. If both plates are not in sync the drive becomes write only, the farther apart they are the worse it gets and data is almost like smeared, won't read. Files/folders won't open then. I have one brand new 64GB mini SD card that happened to and the others are as suspect. I may only get one shot at this so i got'ta make it count. If i can re-alighn that on Linux using dd as its said can be done after i get the data back then i can rescue the sd and let it be until i find the cause some how. I reaserched this for off and on maybe months, dd was the only cure i was told but never had got unstuk from stupid reading it, its like trying to learn Python. Lol.
I don't know where this platter re-alignment idea is coming from, but I highly doubt your issue has anything to do with the entire disk misaligning itself spontaneously. Chances are it's just losing bits, which is causing corruption issues.

Quote:
Originally Posted by sulobaidsuevin View Post
I also do not have enough space to clone the files as you indicated to my primary space were the Linux i use is. Not sure if i should use an external drive or not. If yes, do i need to empty it first?
You can use whatever drive you want as long as it has at least 32 GB of free space (for doing a dd dump of a 32 GB SD card, 64 GB for a 64 GB SD card). You don't need to empty the drive unless it doesn't have enough space available.
 
Old 10-25-2014, 08:08 PM   #10
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626
Can clone + compression to save space. Even bit by bit copy can compress.


Might be that testdisk or photorec can recover some parts.


Is linux system separate? If so then we'd have to look at other things like voltages maybe.
 
Old 10-28-2014, 07:50 AM   #11
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
The other part is once you get the cards recovered, you need to diagnose why this is occurring. Someone else had a thread about photo files which got changed, they were being accessed by Linux and Windows and stored on a Raid array. The visibility of files and priviledges of the files were confusing as they described them; however their main intent was to restore their files.

My point here is that these disks should not just randomly get messed up. Try to be determine the root cause of your problems. Do the disks persist in always working, zero problems, if all you ever do is use them via Linux? Or do the disks get messed up Linux or Windows and you never even change any files? What file system is being used? Are there discrepancies in the files between one system and another? For instance are the files all fine in Linux and under Windows they are all write-protected or something? Are you leaving this disk in the drive when you shutdown and restart the system?

Just some suggestions. Because if I had that situation, it would be obnoxious and my instincts would tell me that there's something causing this, as your instincts similarly told you.

There are a variety of tools one can use to diagnose that disk too. Such as fsck, however there are different fsck programs for different file systems. There are also repair methods for the file system. Another thing to do is to use fdisk to look at how your disk is partitioned. It may be that your SD cards are similar to some newer USB thumb sticks which contain "helpful" software mostly intended for Windows where it provides you with utilities to encrypt, backup, or other helpful functions by establishing a proprietary file management scheme. Their intentions are both that you have guided file management where they can provide you with coherent support; however it also means that you're using their software, which they're happy to have happen as well. Therefore if the disk was in Windows and you chose to accept the manufacturer's proprietary file management scheme, it may be a case where Linux can see files so it allows you to work with them, but may fail eventually; especially if you swap the cards from Windows to Linux.

My basic thinking is the following:
  1. A SD card fresh from the package likely has a VFAT file system on it
  2. Doing absolutely nothing to that card, which is to say in Windows, not accepting or using any auto-started manufacturer's utilities; and in Linux, not altering the disk by reformating or repartitioning: the disk should work fine in both systems
  3. SD cards are not IMHO supposed to be permanently in the system; you plug them in when you wish to get or remove data and then you unplug them with the only minor caveat that in either system it's best to eject or un-mount the disk before you remove it. That's all, no complications, no fuss.
  4. These are after all "differently shaped" thumbsticks. In fact, I've seen a thumbstick when it was torn apart where all it was, was a microSD card! That's not normal, but I thought it was amusing how they chose to do that.
 
Old 11-06-2014, 12:29 PM   #12
sulobaidsuevin
Member
 
Registered: Jan 2014
Distribution: Debian Kali Linux 1.0 -Custom Brew ;)
Posts: 35

Original Poster
Rep: Reputation: Disabled
rtmistler:

I hate to say it but i am up to 9 now. Below is a tool i may be needing to use to fix the offset sectors. Its hard to explain but later on i'll attempt to do so. Yes, i use a single 64GB Mini SD card in a SD adapter and leave it in the laptop slot in order to store my actual files inside of and i usually encrypt the whole SD card. I am not one to store anything on a PC. I am saving the info here for offline use as a .pdf for now. I won't be keeping it but having an offline means of resolving this is necessary. Thank you all. When i get this fixed i'll be posting the solution.

http://www.pendriveapps.com/partitio...editor-ptedit/
 
Old 11-06-2014, 02:19 PM   #13
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by sulobaidsuevin View Post
rtmistler:

I hate to say it but i am up to 9 now. Below is a tool i may be needing to use to fix the offset sectors. Its hard to explain but later on i'll attempt to do so. Yes, i use a single 64GB Mini SD card in a SD adapter and leave it in the laptop slot in order to store my actual files inside of and i usually encrypt the whole SD card. I am not one to store anything on a PC. I am saving the info here for offline use as a .pdf for now. I won't be keeping it but having an offline means of resolving this is necessary. Thank you all. When i get this fixed i'll be posting the solution.

http://www.pendriveapps.com/partitio...editor-ptedit/
I'm betting that your problem is that an SD card is NOT the same as a magnetic disk. It is REWRITABLE-FLASH which has a FINITE amount of write cycles. The fact that you're encrypting the data probably makes it worse. The cards are probably going bad because you're exceeding the reasonable lifetime limits for write evolutions on those disks. Do not use flash media disks for recurring everyday data. And the more full those disks are, the less life they will have because even though there are file system management algorithms; those algorithms cannot spread out the writes to different physical areas on the disk because there's little free space for that to happen.

My point made from before:
Quote:
SD cards are not IMHO supposed to be permanently in the system; you plug them in when you wish to get or remove data and then you unplug them
 
Old 11-06-2014, 02:56 PM   #14
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
I have noticed that with flash cards that they leak charge, which invariably leads to corruption over time. In general I have to reformat all the partitions once a year to keep the charge fresh. Like I've recommended in the past, flash media should never be used as the sole means of backing up data.
 
Old 11-07-2014, 08:27 AM   #15
sulobaidsuevin
Member
 
Registered: Jan 2014
Distribution: Debian Kali Linux 1.0 -Custom Brew ;)
Posts: 35

Original Poster
Rep: Reputation: Disabled
metaschima - I wasn't trying to use it as the sole place to store things, they were hardly a few months old for a few and the rest maybe a month. All at once for this to happen is highly suspect. I have a few backed up. I intended them for temporary storage. So why is it i can have a mini SD card in my cell phone, the same 16GB one for 3 years and it works fine? I don't understand this "leak charge" because i don't see anything storing power in them, perhaps did you mean leak data?

Your all very kind, knowledgeable and best i ever encountered in sch a place yet. Thank you.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Need to match if the system time is available in file or not santosh0782 Linux - Newbie 2 11-30-2013 04:27 AM
check file system every time.... keimasi Linux - Desktop 7 03-17-2011 11:29 AM
File System Creation Time meshcurrent Linux - General 5 02-08-2009 11:46 AM
system file changes to read only by it self after some time.... ghost333 Slackware 3 12-02-2008 10:05 AM
send system time to a file ust Linux - Newbie 3 08-15-2008 09:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:05 PM.

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