10

I just got my Raspberry Pi and a brand new 16 GB Class 10 SD card. I am using Linux Mint and am trying to image the Raspbian Debian 7 (Wheezy) OS to the card, but whenever I try

dd bs=4M if=2013-05-25-wheezy-raspbian.img of=/dev/sdc

I get the error

dd: opening `/dev/sdc': Read-only file system

I have tried every way possible to change the permission using

chmod a=rwx /dev/sdc

and I added this line to /etc/fstab:

UUID=9016-4EF8  /media/matt/SDcard vfat user,uid=1000,gid=100,dmask=027,fmask=137  0  0

Here are some printouts from the command line:

matt-Aspire-5552 SDcard # blkid
/dev/sda1: LABEL="PQSERVICE" UUID="8806A1F106A1E104" TYPE="ntfs"
/dev/sda2: LABEL="SYSTEM RESERVED" UUID="EABAA321BAA2E971" TYPE="ntfs"
/dev/sda3: LABEL="Acer" UUID="6A5AE8025AE7C8C1" TYPE="ntfs"
/dev/sda5: UUID="a27e3081-abad-432d-8ffa-a24245684cd8" TYPE="ext4"
/dev/sdc1: UUID="9016-4EF8" TYPE="vfat"

And fdisk -l:

matt-Aspire-5552 SDcard # fdisk -l

Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x2bd2c32a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    41945087    20971520   27  Hidden NTFS WinRE
/dev/sda2        41945088    42149887      102400    7  HPFS/NTFS/exFAT
/dev/sda3        42149888   371296943   164573528    7  HPFS/NTFS/exFAT
/dev/sda4       371298302   625141759   126921729    5  Extended
Partition 4 does not start on physical sector boundary.
/dev/sda5       371298304   625141759   126921728   83  Linux

Disk /dev/sdc: 15.8 GB, 15811477504 bytes
255 heads, 63 sectors/track, 1922 cylinders, total 30881792 sectors
Units = sectors of 1 * 512 = 512 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/sdc1            8192    30881791    15436800    c  W95 FAT32 (LBA)

And I have even tried changing the permissions tab in the Properties of the SD card mount folder to be read-write, but that didn't change anything.

All of this has been done in sudo su root.

6

Putting Linux ISO on SD Card

  1. Gain superuser priveleges:
    • sudo su -
  2. Remove entry from /etc/fstab
  3. Unmount /dev/sdX
    • umount /dev/sdX
  4. Physically remove SD card
  5. Inspect SD card and make sure it's not LOCKED
  6. Physically insert SD card
  7. Find which device Linux assigns the card
    • dmesg | tail
  8. Write contents of ISO to SD card
    • dd if=/path/to/file.iso of=/dev/sdX bs=4096
  • 2
    I also suspect the physical lock slider. (Item 5.) – hans_meine Aug 12 '15 at 17:57
  • Along similar lines, my microSD adapter card was faulty. Read only, regardless of the position of the lock slider. – Peter Becich Jan 24 '18 at 2:52
3

I had an issue with a card reader as well. The switch on the card I found does nothing, it is essentially a price of plastic you're sliding. That in turn activates another switch inside the card reader. In my case the switch in the card reader was bent a little too far so that it never made contact, and forcing it to mount read only no matter what. I bent it back very carefully with the tiniest pair of needlenose pliers ever and it worked fine. That's what worked for me. Hope it helps.

2

Physical write protection

Here's the image for those who had never used SD cards before.

Attribution.

It is analogous for a micro SD adapter with a MicroSD inside: the dongle is on the adapter:

1

You are getting that error because, when you are inserting the SD card into the Raspberry Pi, the SD card is mounted to the root file system in a read-only mode (default).

This prevents you from performing any write operation on the SD carry. Therefore failing of dd is likely.

You actually need to remount the SD card manually, by enabling the rw option, so that this time the SD card is mounted in read-write mode.

Assuming /dev/sdc is the logical name of your SD card:

  1. $ sudo mount -o remount,rw /dev/sdc

The above command, mounts the SD card for rw access, and I guess you no longer have a problem re-flashing the Raspbian OS image onto it.

Alternative:

  1. Editing the /etc/fstab file using your preferred editor like this

    $sudo leafpad /etc/fstab

  2. Search for a line similar to this:

    /dev/sdc /mnt/sdcard sdc ro,nosuid,nodev,noatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0 0

  3. Replace ro with rw in the above line.

  4. Save the file.

  5. I hope it works..

  • 1
    This answer does not address the question; the question is about dd, which writes to the block device, and not to a mounted filesystem, and is best done while the device is not mounted at all. – hans_meine Aug 12 '15 at 17:56
  • However, it solved my problem. I was able to write to the sd card from my Linux laptop using Etcher, but then could not modify any files on it (while still on the laptop.) – mhwombat May 28 '18 at 22:16
1

I had this problem too.

Atlas RPI # dd bs=1024k if=2013-12-20-wheezy-raspbian.img of=/dev/sdb
dd: opening '/dev/sdb': Read-only file system

How I fixed it was as follows:

Atlas RPI # dd bs=1024k if=2013-12-20-wheezy-raspbian.img of=/dev/sdb1
^C49+0 records in
48+0 records out
50331648 bytes (50 MB) copied, 6.54082 s, 7.7 MB/s

That is to say, I started deliberate writing to the first partition (which is deliberately wrong). After one second of writing I aborted this with Ctrl + C. Then I did:

Atlas RPI # dd bs=1024k if=2013-12-20-wheezy-raspbian.img of=/dev/sdb
2825+0 records in
2825+0 records out
2962227200 bytes (3.0 GB) copied, 412.419 s, 7.2 MB/s
Atlas RPI #

And it works perfectly - Tada!!! Maybe it's just an odd filesystem that the SD cards are factory formatted with? Who knows.

  • Not sure if this is the cleanest way to fix it, but the hack worked for me, too. – rodrunner Sep 18 '15 at 16:12
1

Having been a Linux user for about 12 years, I was fairly confused as to how an unmounted block device could be a read-only file system. I'm still confused; Ubuntu didn't give me any useful information as to why things were going wrong or how to fix them.

In the end, I reformatted the SD card using my camera. After that, the dd command worked fine.

UPDATE

You won't believe this, but spraying compressed air into the card slot near where the read-only switch is sensed fixed it for me. I hardly believe it.

  • You don't even need compressed air ... blowing by mouth a few times into the slot of the card reader fixed the "broken" cardreader. :) – user33267 Jul 29 '15 at 15:25
  • The 80s video gaming solution – deltaray Jan 9 at 16:10
0

On your PC that you are using to write the image to the SD card, make sure that the SD card is un-mounted, ad that you run the dd command as root.

Something like this:

sudo umount /dev/sdc
sudo dd bs=4M if=2013-05-25-wheezy-raspbian.img of=/dev/sdc

You should now be able to take the SD card out of your PC and plug it into your Pi.

0

I had a faulty card reader that had that same issue.

The SD card would come up read-only no matter where the switch was. I used a different SD card reader in the end.

0

I just ran into this as well when tring to load an image to the SD from another computer (at this very moment). Don't use sudo to unmount the SD card in the first step (or even su). Every time I had unmounted the SD card using sudo, it set it as Read-Only.

Then use sudo with dd.

Hope that helps ya.

  • then get error, "dd error writing operation not permitted" – Lin Song Yang Jul 14 '17 at 23:42

protected by goldilocks Nov 15 '15 at 14:28

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.