Sd card read only linux

Флешка монтируется только read-only. Помогите.

Здравствуйте уважаемые гуру. Помогите пожалуйста по сабжу.

lsusb
Bus 001 Device 005: ID 0951:1621 Kingston Technology

делаю
mount /dev/sdb1 /media/kin/
mount: block device /dev/sdb1 is write-protected, mounting read-only
и даже так
mount -o rw,noexec /dev/sdb1 /media/kin/
mount: block device /dev/sdb1 is write-protected, mounting read-only

dmesg | tail
[ 4715.584568] sd 9:0:0:0: Attached scsi generic sg2 type 0
[ 4716.873369] sd 9:0:0:0: [sdb] 63037440 512-byte logical blocks: (32.2 GB/30.0 GiB)
[ 4716.873857] sd 9:0:0:0: [sdb] Write Protect is on
[ 4716.873861] sd 9:0:0:0: [sdb] Mode Sense: 23 00 80 00
[ 4716.873864] sd 9:0:0:0: [sdb] Assuming drive cache: write through
[ 4716.877347] sd 9:0:0:0: [sdb] Assuming drive cache: write through
[ 4716.877353] sdb: sdb1
[ 4716.926237] sd 9:0:0:0: [sdb] Assuming drive cache: write through
[ 4716.926244] sd 9:0:0:0: [sdb] Attached SCSI removable disk
[ 4728.401660] FAT: utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive!

fdisk -l
Disk /dev/sdb: 32.3 GB, 32275169280 bytes
5 heads, 32 sectors/track, 393984 cylinders
Units = cylinders of 160 * 512 = 81920 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdb1 * 51 393984 31514688 c W95
FAT32 (LBA)

Источник

Micro SD card automatically mounted as read-only on Linux

It was a just normal night after school until I checked my Arch Linux Chromebook used as desktop/home server and found that no writes can be performed to the /home partition. Kernel dmesg reports a flood of errors as well.

The home directories are stored on a 32GB SanDisk Class 10 Micro SD card due to the low 16GB eMMC internal storage on this Samsung Chromebook 3. The Micro SD card has a single ext4 partition that has been set to mount on /home read+write during system boot. It also contains a 2GB swapfile that gets used occasionally complement to the 4GB RAM.

Somehow, this partition is now mounted as read-only automatically by the OS. Re-mounting the partition as read+write fails too.

This tiny machine usually sits there doing nothing besides contributing ADS-B data with a RTL-SDR dongle to a crowd-sourced flight tracking platform. Let’s get to the result first: seems like the Micro SD card is blocking all write requests on the hardware level without any explicit signal — it probably has reached the end of its lifespan. To anyone who happened to get to this post: if you’re sure no system/package update is performed, you have not interacted with the machine for a while and suddenly get this problem, the hardware failure may well likely be the cause.

Exploring along

Fix the Filesystem

First things first, I resorted to the “technology panacea” — rebooting the system, only to find the kernel floods similar errors during boot and the system boots into an “emergency mode” in maintenance runlevel that prompts for root password. Naturally, one would think the file system meta-data may have been corrupted. So we took out the SD card, plugged it into another Ubuntu workstation and tried a fairly standard filesystem check with fsck . As its name suggests, the check is performed on a file system so a virtual/partition device should be given to the tool (something like /dev/sda1 ) but not a raw device (something like /dev/sda ). Otherwise, fsck would always fail with not being able to find a superblock, which reasonably does not exist. The error is similar to those thrown by other tools that expect a filesystem — for example, if we try to mount the raw device.

The Linux Kernel documentations give a detailed disk layout specification of the ext4 filesystem. Just as a memory refresh, the Superblock lies in the partition’s beginning and contains metadata of the filesystem’s metadata (Ex. total & free inode count/block count, block size, error handling strategy, etc.) It contains a magic signature 0xEF53 at byte offset 0x38 so the OS can identify it. It’s so crucial for the partition to be mounted that multiple Alternate Superblocks exist as backups at various offsets in the partition besides this Primary Superblock.

Group 0 Padding ext4 Super Block Group Descriptors Reserved GDT Blocks Data Block Bitmap inode Bitmap inode Table Data Blocks
1024 bytes 1 block many blocks many blocks 1 block 1 block many blocks many more blocks

To know where these alternate superblocks might be stored, we can dry-run “create” a ext4 filesystem on the target partition and look at its parameters (the -n flag specifies not to actually create one but to output the details if it would).

In case the primary superblock is corrupted, fsck can be directed to use an alternative superblock found above with e2fsck -b or fsck -b .

Is there any chance that someone gets really unlucky and all alternate superblocks have been corrupted as well? Very unlikely, but it may have happened to this person who also documented his/her data recovery process carefully. Kyle Jone’s comment offers an interesting heads-up in case you believe to have a similar case:

I can’t make myself believe that you were unlucky enough to have all copies of the superblock wiped. So there must be something wrong with the partition table, which in turn is throwing off the logical block offsets in the filesystem causing fsck to not be able to find the alternate superblocks.

fdisk can be used to re-create a partition table — people having reinstalled *nix OSs may be familiar. Loading the partition into the tool first, deleting the partition and creating it again with the same starting sector should do the job. We haven’t tried it because the GPT partition table is reported to be normal, but here is a discussion thread about this process.

In case all superblocks are truly broken and you’re absolutely sure about the partition’s block size, we can force to re-create the superblock by mke2fs -S without touching block and inode bitmaps. This is only the last resort and further damage can be done to the disk if the block size is gotten wrong.

Data Recovery

The Data Recovery guide by Ubuntu offers a good starting point. We never want to write to the failed device which may further corrupt the data, so it’s best to image the entire device onto another drive first and perform operations there. The GNU ddrescue suits the purpose: functionally it works like an extended version of dd just for device recovery. It supports re-trying failed reads multiple times, pause-and-resume with a mapfile/logfile, or even recover the entire data using multiple damaged devices containing the same data (because it’s very unlikely that these devices are all physically damaged at the same data block).

Then, mmls from sleuthkit helps discover the partition table on the device image, and then we can mount the target partition by giving the device image and the partition’s byte offset. Fortunately, imaging our Micro SD card only took one single pass with 100% successful reads, and mounting the partition is successful with all data still intact.

Discovering the Problem

The good news gave us confidence and we proceeded to test mounting the physical Micro SD card directly as read+write, which succeeded as well. Then we unmounted the ext4 partition, and a fsck on it found inconsistencies from a non-empty journal but failed to fix the problem:

It looks like we can write new files or add changes to existing files in the drive without error when we mounted the drive earlier. But now all file changes were gone when the partition was mounted again. This interesting find inspired us of a potential quick dive by a raw disk read & write:

We haven’t tried this as we still want to preserve the partition’s metadata on the SD card, but this test is highly likely to fail potentientially accompanied with errors in the kernel ring. There’s no physical write-protect switch on the Micro SD card itself, so it appears that the card has entered a fail-safe read-only mode on the physical level as discussed above. Plenty of people are having the same problem online so we’ll stop here with this explanation for now, while preserving this SD card for future scrutiny when in the mood again.

Lessons Learned

It’s surprising to know that the lifespan of Micro SD cards may not be as long as we think before. The total system up time of this Chromebook is about a full year or so with the Micro SD card in it. Also, using a flash device as swap may contribute its quick worn out. Well, it’s not too surprising as the high quality flashes are usually left for the SSDs.

Backup regularly, as people always talk about. My friend and I were just talking about a tech review article days ago, claiming it’s practically impossible to wear out a particular well-known brand’s flash storage device. But you never know when it fails in what unexpected way.

References

Instances of fsck setting superblock flag failure: 1, 2, 3

Источник

Thread: Micro SD Cards are loading as read only, Ubuntu 14

Thread Tools
Display

Micro SD Cards are loading as read only, Ubuntu 14

I’m currently trying to format the SD so that I could install Deb Wheezy onto it, though I might use the NOOBs installer as it’s meant to be really simple and I haven’t tried it yet. It currently has RetroPie on it.

I was trying to format and setup the partitions using fdisk, and ran into the problems that follow.

I’ve experienced similar[ish] problems earlier in the week from my phones SD card; I couldn’t copy files onto it as it had been mounted as read only. This is what lead me to believe there was a fault on the computers side rather than the SD cards.

I’ve tried to format the SD card using [this guide]( http://qdosmsq.dunbar-it.co.uk/blog/. -raspberry-pi/ ) but mine seemed to bugger it at the last stage as I got the message :

Command (m for help): w
fdisk: unable to write /dev/mmcblk0: Bad file descriptor

I think that this means the filesystem is read only, which is weird that it only popped up at the last stage, but then thats the write stage, so perhaps it makes perfect sense.

If I grep in /dev I can see that the SD Card is there :

vco@geoHP:/dev$ a | grep mmc
brw-rw—- 1 root disk 179, 0 Feb 6 12:33 mmcblk0
brw-rw—- 1 root disk 179, 1 Feb 6 12:52 mmcblk0p1
brw-rw—- 1 root disk 179, 2 Feb 6 12:33 mmcblk0p2
vco@geoHP:/dev$

And I can see that In GParted : [SD Location](https://lh4.googleusercontent.com/gN. =w1188-h366-no) as well as the error message GParted displays [about the file system being read only]( https://lh4.googleusercontent.com/-v. -h450-no/a.png ) that’s the same [for both partitions](https://lh3.googleusercontent.com/-y. -h452-no/b.png )

I had a similar problem with another SD Card, so I’m inclined to think that this is an issue with Linux rather than the card, that some setting has somehow been set to use SD Cards as read only. not sure how or why. (Note — the SD Card definitely isn’t physically ‘locked’ on the Micro SD Card adaptor)

Any advice much appreciated

edit 1 : turns out that the fat16 partition was mounted, I guess the ext4 was the only was that showed up as mounted in the finder window. not sure what difference that makes

edit 2 — I repeated the fdisk steps after unmounting the other partition and got the same error message as previously. I might try just wiping in GParted.

******
edit 3 — GParted didn’t do anything differently, [similar error message](https://lh6.googleusercontent.com/cL. =w1158-h798-no). No reason why it would I guess.

edit 5 — I’ve fount the following command [from this post]( http://askubuntu.com/a/47547 ) :

sudo mount -o remount,rw ‘/media/SGTL MSCN’

I don’t really get what it’s doing though, I thought that I’d be mounting something from `/dev` **to** `/media`.

edit 6 — I’ve just tried the following without any progress :

$ sudo mount -w /dev/mmcblk0 /media/sdcard/
[sudo] password for vco:
mount: block device /dev/mmcblk0 is write-protected but explicit `-w’ flag given
vco@geoHP:

edit 8 — I tried to use `dd` on this after unmounting the SD card with the following (and similar) error :

vco@geoHP:/$ sudo umount /dev/mmcblk0p2 /dev/mmcblk0p1
vco@geoHP:/$ sudo mount | grep mmc
vco@geoHP:/$ sudo dd if=/dev/zero of=/dev/mmcblk0
dd: failed to open ‘/dev/mmcblk0’: Read-only file system
vco@geoHP:/$

edit 9 — I’ve tried to mount the SD card from `/dev/mmcblk0` using `mount -w` but I get the following :

sudo mount -w /dev/mmcblk0 /media/sdcard/
mount: block device /dev/mmcblk0 is write-protected but explicit `-w’ flag given
vco@geoHP:/$

edit 10 — [from this post here](http://unix.stackexchange.com/questi. nt116810_79309) I’m going to try and reboot the machine.

edit 11 — after rebooting the SD card is still mounted as read only

edit 12 — it does this for other SD cards as well, [here’s GParted with a different card](https://lh3.googleusercontent.com/-a. -h461-no/a.png)

Re: Micro SD Cards are loading as read only — not sure how to fix — Ubuntu 14

You have really tried a lot of methods to mount the SD cards.

See the last post (post #8) of this link Howto help USB boot drives

It looks like the cards are failing with the gridlock symptom, but there could be some bad hand-shaking between the UEFI/BIOS system or operating system and the card reader or some firmware, so that good cards cannot be read.

I suggest that you try to format the SD cards in another computer (with Windows or MacOS) and in a camera or mobile phone. That way you might separate a problem with the cards from a problem with the systems in the computer and/or the card reader.

Re: Micro SD Cards are loading as read only — not sure how to fix — Ubuntu 14

Thanks. Although I can’t be 100 percent I think that lifetime is incredibly unlikely as I’ve tried this on 3 SD cards. One from the phone (which was kind of old) one from the Pi that had Retro Pie on it (not too old, not that used) and another one that had never been used.

Never heard of this before.

I can try and format the card in Windows. I’ll just go FAT32 unless there’s anything else. I’m expecting this (formatting in another OS) to work, I’m not sure what the steps after that would be though.

I’ll post back when I’ve formatted as that’s the acid test I guess.

One scenario I hadn’t considered (and don’t know how to check as I’m out of SD’s) is that putting the cards into the Ubuntu machine is actually breaking them. If this was the case using them in another OS would give the impression that the fault lay with the cards. Maybe this is a bit paranoid I’m not sure whats really going on with all this

Last edited by apple6; February 6th, 2015 at 07:04 PM .

Re: Micro SD Cards are loading as read only — not sure how to fix — Ubuntu 14

I have not had any problem with my Ubuntu 12.04 LTS and 14.04 LTS destroying SD cards. But before we know, it it one of the possibilities.

Good luck formatting to FAT32 in Windows

Re: Micro SD Cards are loading as read only — not sure how to fix — Ubuntu 14

If you have one of the normal Raspbian images, you use dd to write the image directly to the SD or microSD device (after making sure that everything on the card is unmounted). But I have not tried that with an mmcblk device. You might try a USB card reader or computer that has internally USB connected memory card slots. That puts everything on the card including an mbr, FAT32 partition for config files, and Linux partition for everything else. Then you should either be able to expand the Linux partition with gparted, or the first time you boot it on a Pi, it will ask if you want to expand the partition to fill the SD/microSD (I have an older Pi with SD slot). The NOOBS thing is something that can be run from Windows to create the SD/microSD.

One thing that might be tripping you up is if the write protect tab moves when you insert the card or microSD to SD adapter. I know that I had that trouble with a microSD to SD adapter when the write protect tab was quite loose and the slot was tight.

Re: Micro SD Cards are loading as read only — not sure how to fix — Ubuntu 14

Hey — I used Windows and was able to format an SD Card.

Weirdly it didn’t work with the Micro to regular SD adaptor that I was using, so I thought that it was that.

But now I’ve booted into Ubuntu and I’m having the same problems again. I’m really not sure what to do here, thanks

Re: Micro SD Cards are loading as read only — not sure how to fix — Ubuntu 14

I think there is some bad hand-shaking between the UEFI/BIOS system or operating system and the card reader or some firmware, so that good cards cannot be read (in Ubuntu).

Can the UEFI/BIOS system be updated to a newer version?

Does the card reader work with Ubuntu in another computer, another USB port, or via a USB hub?

Maybe another card reader works with Ubuntu.

Re: Micro SD Cards are loading as read only — not sure how to fix — Ubuntu 14

Thanks for your response Sudodus :

I’m not sure how to go about troubleshooting this to be honest. My current setup (on this laptop) is Windows 8 and Ubuntu 14 dual boot. I only use Ubuntu, windows is there because I paid for it and it’s handy sometimes (this eve?!)

Possibly — though I’m sure that I’ve read that isn’t something that should really be done if one can help it? I would be concerned about pulling the rug from beneath the feet of both operating systems doing this.

I’ve never done this before (I’m sure there are plenty of guides out there though, I’m not asking you of that).

I’m not really understanding how this could be the problem either — as I’ve used SD cards with this Ubuntu version before and they have worked, the ones that I’m failing to use now are the very ones that I have used before.

Does the card reader work with Ubuntu in another computer, another USB port, or via a USB hub?

Maybe another card reader works with Ubuntu.

By card reader are you referring to the Micro Regular converter? One of these :

I think that (if this is what you mean) I’ve already answered this as I have used SD cards with this computer, using Ubuntu and the SD Card readers that I have.

I didn’t try the SD to USB adapter that I had previously though, I’ve just tried that and it doesn’t work either. Exactly the same errors in GParted regarding read only file system.

I can’t convince myself that this is an Issue with anything other than Ubuntu, I’m sure it’s an isolated case (as I have been using it before without issue) but still. I have no idea how to test this though, I don’t know where the settings would be for such a thing and whether there’s a file somewhere that has somehow had it’s value to change to read only or something.

Also regarding the catalyst for this, the only thing that I can think of is that earlier this week I took the SD from my phone without turning the phone off and put it into Ubuntu. It wouldn’t let me do anything to the SD and said ‘read only; etc etc. I was in a rush so didn’t have time to try anything or test anything out. But that was the first time that this has happened, I’m not sure if something went wrong with me pulling the SD out of the phone which made Ubuntu lockdown SD card transfers or something mental ? I’ve not had any messages that imply this.

Out of ideas, let me know what you thinks best, thank you!

Источник

Читайте также:  Абракадабра вместо русских букв windows 10
Оцените статью