- Флешка монтируется только read-only. Помогите.
- programmatically detect SD card write protect
- 1 Answer 1
- Micro SD Card automatically getting write protected
- 3 Answers 3
- Not the answer you’re looking for? Browse other questions tagged sd-card or ask your own question.
- Related
- Hot Network Questions
- Subscribe to RSS
- Cannot remove Micro SD card’s read-only attribute after Ubuntu image
- Attempted fixes with Windows
- Attempted fixes with Linux
- USB turn write protection off
- 8 Answers 8
Флешка монтируется только 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)
Источник
programmatically detect SD card write protect
Back in the good-old days of floppy, if you enable write protection of a floppy, DOS would kindly tell you that you cannot write to it. Now we have SD card that can hold the content of thousands of floppy and we still have the write protection — and it’s handy sometime. But nobody is able to tell me I can’t write to it, at least on Linux. I have a lovely script that partition and format a SD card in a way I like. It took me 1/2 hour of debugging just to find out that the SD card is write-protected.
So the question, is there a way that the software can detect such condition?
1 Answer 1
The driver knows when the card is write-protected, and it actually warns when you mount it via command line:
In case you would like to check it yourself at device level, you can use the hdparm command to query read-only status of disk device, including SD card and USB flash drive in general. This program should be available in most GNU/Linux distributions, commonly in a package named «hdparm».
If you are not root, be sure to specify full path to the hdparm command; and this assumes you have read permission on your card of course.
For example: my SD card is inserted, detected as /dev/sdc , and write protection tab is at Unlock:
When I slided the write protection tab to Lock, re-insert the card, and run the command again:
If you would like to do it in shell script, you can try something like:
Note: If you prefer to do it in C, you can try either:
- Opening the device file in write mode and see if it fails with errno value EROFS (Read-only file system), or.
- Opening the device file in read mode, then issue ioctl() named BLKROGET , and check if the result value is nonzero; this is the way hdparm work.
Источник
Micro SD Card automatically getting write protected
I’m using Transcend Micro SD Card. When I try to copy some files from my system(12.04), it’s getting write protected and also unmounting the device. I’m unable to copy files to it.
3 Answers 3
In case, if you are using Sandisk, please do the following (If the lock switch is not on lock):
- Slide the switch up and down. Repeat this 3 times.
- Let it stay on the Lock position for 30 seconds.
- Slide the switch up to unlock the card.
- Try to transfer files into the device.
Yes it is strange and yes it works, as per this source.
Rahul, First Check that whether You have locked MicroSD card using white lock which is located on side of Adapter.
This is a duplicate. Please refer to my answer on /questions/213889/
basically, just run in terminal sudo mount —options remount,rw
Not the answer you’re looking for? Browse other questions tagged sd-card or ask your own question.
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.10.8.40416
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Источник
Cannot remove Micro SD card’s read-only attribute after Ubuntu image
I can’t remove the read-only attribute from a Kingston 32 GB Micro SD Card. I want to wipe clean the whole card.
I was given a Raspberry Pi 3 and a 32 GB Micro SD Card and an Echo to play around with. The Micro SD Card was factory fresh when I got it. I downloaded a fresh Ubuntu 16.04 image and formatted the card using Etcher on Windows 10. After I was done, I plugged in everything for the Raspberry to work and noticed that nothing happened. I started to panic a little and thought to myself: «Good job Scrat, you utter moron. Why couldn’t you simply wait a little and google a freaking tutorial.»
I googled what could possibly have gone wrong and what I should’ve done, and had to discover that you can’t just put any random Ubuntu image on it. It has to be one of the images the creator provides (in my case Ubuntu Mate or Raspbian).
Attempted fixes with Windows
When trying to reformat by right-clicking and reformating via the Windows Explorer, the first thing I encountered that the card was in read-only mode. Trying to access it in the Windows Explorer only showed me the EFI directory, of which I wasn’t surprised by.
First thing I found on the internet is about a switch/lock on the card, but my card does not have any lock at all. Neither the card itself, nor the Robson Mini Card Reader I use for reading.
Afterwards I tried to remember how to edit disks.
Mind that I’m still using Windows 10 at that moment, because I would’ve had to copy my old VM-Ware and system image from my external drive, and I didn’t know where that was.
I opened a command line, run diskpart, and list all my disks via
Which output my 931 GB HDD, my 119 GB SSD (Where Windows is installed on) and the 29 GB Micro SD Card:
Following the information I’ve got, I knew that Datenträger 2 aka Disk 2 is the card I wanted to edit by doing:
So far so good. Then I wanted to remove the read-only attribute by doing:
Which was also successfully executed.
But when I tried to do:
I got a «Hardware Error Message» (In German, thats why I’m not copying it here, but it essentially only said Hardware Error). That error also followed when trying to create primary partition or do other things.
At this point the panic in me started to grow more and more. But I tried to keep calm because I still had a few tricks up my sleeves.
I tried using the programs: EaseUS Partition Master, Etcher (again) and SD Card Formatter which all failed due to the card being protected (read-only, write-protected).
I also tried using the registry edit to change the behaviour of Windows towards storage devices by creating the key (which was not there yet):
and creating a new keyword (DWORD WriteProtect) and setting it to 0, which means no read-only.
Attempted fixes with Linux
That didn’t work either and I began losing my nerves with Windows, so I got off my butt and searched for my external drive and installed VM-Ware and ran the Ubuntu 16.04 virtual machine I use for school.
Starting the VM I already noticed that Ubuntu was able to help me way more than Windows (or at least I thought so, because my Linux skills are limited in this aspect). The first thing I see is a linked icon on the Desktop to the card called «Ubuntu 16.04.2 LTS amd64» in it are contained the various stuff Ubuntu needs to work seen in the image here.
But that wouldn’t help me. So I went ahead and started a terminal and wrote:
Which confirmed that the card is visible (sdb):
But lsblk wasn’t very precise so I also used the command we learned in school:
Which was a bit more precise:
And I was euphoric because I thought I finally cracked the goddamn Davinci code or something, so I ran
Which Immediately opened with an error message:
The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes.
Which I ignored because I thought it was no biggie, but right after ignoring the previous one the next error message popped up:
Partition(s) 1 on /dev/sdb have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.
So I did what the message told me and rebooted. But that was of no use either, because the same two errors popped up again. I ignored them both this time and the good old trusty gparted window I knew from school opened.
Once I changed to /dev/sdb it became confusing really fast. As you can see here, things are pretty weird, because now sdb is somehow considered my SSD instead of the card, but the image from the card is still mounted. At this point I was too angsty to continue doing anything further in fear of accidentally screwing up my laptop as well.
By the way, I have also tried giving myself permissions to access the disk and try to use the dd command, but with the same error message (Access denied, read-only or something, I’m not exactly sure, but something in this direction).
I have already ordered another 32 GB Micro SD card from Amazon, in case there is no more hope for the old one. But I’m not giving up yet.
(Sorry that some things are in German but I think those things are for the most part self-explanatory.)
Источник
USB turn write protection off
I have a USB which is write protected:
How can I turn the write protection off?
What I’ve tried
- Checked if it has a hardware switch — no
- Tried to format it on windows and on Linux (via terminal too)
- Tried fdisk | chmod
- Tried to fix this with several tools from Ubuntu software center
- Used Google and have seen about 10,000 discussions about this problem but they were never solved
Additional information
mkfs -t vfat /dev/sdb1
8 Answers 8
To turn off disk device`s write protect, we use the low level system utility hdparm like this:
where we asume that /dev/sdb is the Physical disk device we’re working on. If the device has partitions that are mounted as read-only, you should re-mount ’em as read-write in order to write data to them.
Hope that helps.
After researching your question it appears that this is a not-too-uncommon problem with certain brands of USB flash drives (some older Samsung, a Kingston model) that would essentially just «crap out» for no known reason. People had tried opening them and jumping two leads (maybe from a flaky switch?) to no avail. If you still have this drive and it’s still in warranty I’d return it and get a replacement.
I hate to break the bad news to you =\ but it appears you’re out of luck in this situation as everything I’ve read points to hardware failure.
Edit 05/27/2016: I experienced an issue personally with a flash drive flaking out on me recently. In my case, this was a Corsair Flash Voyager 128GB that started slowing down pretty drastically on me. While it didn’t show the symptoms noted here, it occasionally would not mount and showed up as a «Silicon Power» device. This was a result of the drive having accrued a large amount of bad sectors and dropping into diagnostic/programming mode. Since this is one of my more popular answers and this also falls into the category of «failing flash drives,» I figured I’d include it here for reference.
Update 2: Regarding that Corsair Flash Voyager, I sent mine in for an RMA, only to have my second one fail on me in the same fashion. The problem actually turned out to be mechanical. The sliding mechanism seems to put a small amount of pressure on the PCB. Ordinarily, this wouldn’t have caused an issue in the normal life span of the device. But for this particular model, it seems to have had weak solder joints that the pressure from the sliding action exacerbated — leading to oxidation in the cracked joint and eventual failure. Rather than doing yet another RMA, I took matters into my own hands. I opened the case, shaved some of the plastic casing away to give the PCB some wiggle room and then reflowed the NAND chip to repair the broken solder joints. It’s working great to this day!
Источник