grahamed
Posts: 277
Joined: Mon Jan 30, 2012 7:01 pm

Strange things after SDCARD backup

Wed Oct 26, 2016 10:12 pm

Hi

I am quite sure that i have got hold of the wrong end of the stick here; otherwise something rather odd is happening. Well I think it's odd, maybe it is well-known.

If I edit a file (such as /etc/rc.local as root), save it, reopen it, see it has changed, reboot, reopen it find it has changed back.

If I create a new file, copy a file from one dir to another, or delete a file, after a reboot everything is back to how it was.

The CLI history is not being saved. I am using the machine headless at the CLI over SSH.

It looks like the card has become write-protected in some odd-way, even though I can apparently see the changes prior to reboot. I assume I am seeing stuff in memory rather than on-disc.

The mini-SD card does not have a write-protect switch (that I can see anyway).

This all started after I tried the accessories/SDCARD copier - which failed "unable to create FAT". I have a recent backup but I would really like to know what is going on before I restore it.

User avatar
rpdom
Posts: 17550
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Strange things after SDCARD backup

Thu Oct 27, 2016 5:33 am

Sometimes when an SD card fails, it goes into a permanent read-only mode (presumably to preserve your existing data). I guess your card has failed at some point.

Possibly the Pi doesn't realise that and is buffering changes prior to writing them to the card. Either that, or the card is dropping writes and returning that they have been successful, and the Pi is returning the write-cache version of the changes when read, which will get lost during reboot.

grahamed
Posts: 277
Joined: Mon Jan 30, 2012 7:01 pm

Re: Strange things after SDCARD backup

Thu Oct 27, 2016 10:03 am

Hi

OK, thanks for the reply. I was hoping that Linux had somehow become read-only and could be reset.

Unless it's an amazing co-incidence it happened during SDCARD COPIER which is a bit worrying,

I will use Win32DiskImager to copy off this card, format it with SDformatter, write the earlier backup back, and see if it works again or at what point it fails.

grahamed
Posts: 277
Joined: Mon Jan 30, 2012 7:01 pm

Re: Strange things after SDCARD backup

Thu Oct 27, 2016 10:27 am

Hi again

SDformatter says the card is write-protected.

So I shall buy some more 16G cards.....and hope the new 16G is as big as the old 16G, or has that problem been sorted? - but please do not say use SDCARD copier.

User avatar
RaTTuS
Posts: 10574
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Strange things after SDCARD backup

Thu Oct 27, 2016 10:32 am

depends on your sdcard - [this is a problem with sdcards not raspbian ]
don't buy them from ebay
also check that they are good with https://www.heise.de/download/product/h2testw-50539
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

grahamed
Posts: 277
Joined: Mon Jan 30, 2012 7:01 pm

Re: Strange things after SDCARD backup

Thu Oct 27, 2016 11:02 am

Hi

Thanks

I never buy such things from eBay - I know people who do and are surprised when their incredibly well-priced card/stick turns out to fill up quicker than its alleged capicity would suggest.

Unless two cards are the same size one will be bigger than the other.....irrespective of other qualities. AFAIK Pi cards have no leeway or so little that it becomes a matter of luck.

Until manufacturers start to produce identically sized cards this problem will remain and will affect this type of use (other similar systems have similar problems I assume). I guess it will continue until Raspbian and such can be forced to use say 15G on a 16G nominal card.

In the meantime how do I "restore" my image to a slightly smaller 16G card?

hippy
Posts: 8233
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Strange things after SDCARD backup

Thu Oct 27, 2016 11:17 am

The SD on cards stands for "Secure Digital" and many cards can be commanded to put themselves into protected mode. Something like that may have happened here.

When I was writing SD card driver code for a microcontroller I found it was surprisingly easy to get something wrong which could provoke very adverse outcomes with some cards so have never entirely trusted their use.

grahamed
Posts: 277
Joined: Mon Jan 30, 2012 7:01 pm

Re: Strange things after SDCARD backup

Thu Oct 27, 2016 11:38 am

Hi hippy

I think you are correct.

I also think it was SDCARD copier what done it. I have no evidence for this excepting that I saw it immediately after a failed attempt to copy a card.

But how to undo it? Googling gets many hits re the w/p switch found on full size cards, and many references to Windows thinking the card is w/p when its not but i can't see any about low-level bit twiddling.

hippy
Posts: 8233
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Strange things after SDCARD backup

Thu Oct 27, 2016 12:36 pm

Best bet is to Google for "unlock microsd password" and similar. That may reveal some means to at least get it back to a usable form.

That may be a fruitless pursuit if something has however gone bad with the card. The worst cases I had were cards which were never even recognised in anything after I'd manage to do whatever I did wrong to them.

drgeoff
Posts: 11100
Joined: Wed Jan 25, 2012 6:39 pm

Re: Strange things after SDCARD backup

Thu Oct 27, 2016 12:37 pm

grahamed wrote: Until manufacturers start to produce identically sized cards ..
That isn't going to happen.

Even cards, from the same silicon wafer, that have the same nominal capacity can have a different actual capacity after any bad sectors are mapped out during the testing stage.
Quis custodiet ipsos custodes?

grahamed
Posts: 277
Joined: Mon Jan 30, 2012 7:01 pm

Re: Strange things after SDCARD backup

Thu Oct 27, 2016 1:54 pm

Hi drgeoff

I know it's not, that's why I'd really like Raspian to allow expansion to nominal size less 10%. I don't think that will happen either. At this time I do not trust SCARD copier in accessories. I don't like what it does either, copy a live file system... never did that in my day.

grahamed
Posts: 277
Joined: Mon Jan 30, 2012 7:01 pm

Re: Strange things after SDCARD backup

Sun Oct 30, 2016 4:33 pm

Hi

Further findings

a USB stick attached during failed SDcard copy was also found to be read-only in the Pi and by Windows, however Windows disk manager recovered it.

W10 disk manager says the SDCARD is found, 2 healthy partitions. I can create a new file on the (still read-only) SDCARD boot partition, eject the card, insert it, find the file, read it, delete it, whatever. So as a W10 file explorer goes it's all normal, but it will still not format.

Ubuntu like-wise says there are 2 partitions present, allows (apparently) a new file to be created in /boot but then gives "Unexpected error: Error writing to file: Remote I/O error" when attempting to write changes and the file is not there after eject/insert.

So it seems to me that the card is functional but Linux regards it as read-only, as does W10 format and SDcardformatter.

tpylkko
Posts: 410
Joined: Tue Oct 14, 2014 5:21 pm

Re: Strange things after SDCARD backup

Sun Oct 30, 2016 8:57 pm

Is it not possible to write the larger img file to the too small partiton in Windows? Because unless your disk is entirely full, which it should never be, then the last bit of the image that you loose will contain nothing.

That is, if the new sd card is smaller tjan the image of the old one, then why not just write the image on it anyway? I don't have windows, but would presume that you can do this in any OS.

User avatar
davidcoton
Posts: 5319
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: Strange things after SDCARD backup

Sun Oct 30, 2016 9:51 pm

tpylkko wrote:Is it not possible to write the larger img file to the too small partiton in Windows? Because unless your disk is entirely full, which it should never be, then the last bit of the image that you loose will contain nothing.

That is, if the new sd card is smaller tjan the image of the old one, then why not just write the image on it anyway? I don't have windows, but would presume that you can do this in any OS.
Unfortunately you end up with a partition table that allows writing "off the end" of the card. So it is not that simple. The partition sizes must fit before copying. Then if they are too small for the card, they can be expanded.
One possibility is to manually adjust the last partition of any newly installed card to leave some margin for copying to a smaller card. OK as long as no-one uses size adjust (and Jessie has been run once, so the auto-adjust isn't triggered after the manual change). DISCLAIMER: I haven't tested this!

EDIT: Grammatical correction
Last edited by davidcoton on Sun Oct 30, 2016 11:30 pm, edited 1 time in total.
Location: 345th cell on the right of the 210th row of L2 cache

grahamed
Posts: 277
Joined: Mon Jan 30, 2012 7:01 pm

Re: Strange things after SDCARD backup

Sun Oct 30, 2016 10:30 pm

Hi

Adjusting the size of the partition is part of the solution. You then have to copy from old card to new card. Windiskimager copies card not partitions so you end up using dd or such and that means having a spare Linux machine to hand. Actually early versions of Windiskimager did not check sizes rigorously so would start the copy and then die somewhere near the end by which time partition had finished copying (I have used 0.7 but usual disclaimers apply).

tpylkko
Posts: 410
Joined: Tue Oct 14, 2014 5:21 pm

Re: Strange things after SDCARD backup

Mon Oct 31, 2016 3:27 pm

Ah, ok. So in Windows you cannot copy a partition. Like make a new disk and then dd the partition on the smaller partition? Can you not do that with any program on Windows? If that is the case, then it might make sense to always boot into a live disk of gparted (for example) every time that you want to mess around with partitions.

grahamed
Posts: 277
Joined: Mon Jan 30, 2012 7:01 pm

Re: Strange things after SDCARD backup

Tue Nov 01, 2016 11:07 am

Hi

I guess there might be a Windows program that can copy *x partitions but I am not aware of it. For Windows to copy the partition sparsely, i.e. not copy unused space, etc, it would have to understand the structure.

I have used an old Partition Magic live CD but it cannot change the write-protected card so no shrink in place.

It may be that it is going to be too much trouble (in this particular case) to copy the partitions on to disk, edit, write to new card, etc., just to retrieve the few significant changes to MySQL database. I guess I can just prepare a new card and copy the MySQL data directory onto it. I can't do anything until ebuyer sends me the new cards - it is surprisingly slow they are being.

I also find that my cameras regard the disk as faulty - they just say "card?" - I guess that is the nearest error message they have. Maybe they would always say that for a RPi formatted card.

User avatar
RaTTuS
Posts: 10574
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Strange things after SDCARD backup

Wed Nov 02, 2016 7:40 am

ext2fsd http://www.ext2fsd.com/?page_id=16 can read and understand ext[2-4] filesystem under windows - you can use this to read the stuff off the sdcards
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

Return to “Troubleshooting”