# [ext4] troubles formatting an SD card [Solved]

## Sade

I want to format this SD card with ext4, 

The card is connected through a SD slot in the front of my case,

When I insert the SD card it is auto mounted read only, and currently has a fat32 file system.

When i want to create the ext4 file system i get:

```
atom / # mkfs.ext4 /dev/sdc1 

mke2fs 1.41.9 (22-Aug-2009)

/dev/sdc1: Read-only file system while setting up superblock
```

When i repartition using fdisk i get:

```
Unable to write /dev/sdc
```

I noticed that the SD card has some kind of manual lock switch on the side, but it is in the unlocked state.

Maybe i don't have the right kernel driver to write to SD???

extra info:

```
atom / # lspci

00:00.0 Host bridge: Intel Corporation Mobile 945GME Express Memory Controller Hub (rev 03)

00:02.0 VGA compatible controller: Intel Corporation Mobile 945GME Express Integrated Graphics Controller (rev 03)

00:02.1 Display controller: Intel Corporation Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller (rev 03)

00:1b.0 Audio device: Intel Corporation 82801G (ICH7 Family) High Definition Audio Controller (rev 02)

00:1c.0 PCI bridge: Intel Corporation 82801G (ICH7 Family) PCI Express Port 1 (rev 02)

00:1d.0 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #1 (rev 02)

00:1d.1 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #2 (rev 02)

00:1d.2 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #3 (rev 02)

00:1d.3 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #4 (rev 02)

00:1d.7 USB Controller: Intel Corporation 82801G (ICH7 Family) USB2 EHCI Controller (rev 02)

00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev e2)

00:1f.0 ISA bridge: Intel Corporation 82801GBM (ICH7-M) LPC Interface Bridge (rev 02)

00:1f.2 IDE interface: Intel Corporation 82801GBM/GHM (ICH7 Family) SATA IDE Controller (rev 02)

00:1f.3 SMBus: Intel Corporation 82801G (ICH7 Family) SMBus Controller (rev 02)

01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 02)
```

```
atom / # lsusb

Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 001 Device 003: ID 046d:0992 Logitech, Inc. QuickCam Communicate Deluxe

Bus 001 Device 005: ID 0bda:0158 Realtek Semiconductor Corp. Mass Storage Device

Bus 001 Device 004: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 002 Device 003: ID 046d:c30e Logitech, Inc. UltraX Keyboard (Y-BL49)

Bus 002 Device 004: ID 050d:3201 Belkin Components F1DF102U/F1DG102U Flip KVM

Bus 002 Device 002: ID 050d:3101 Belkin Components F1DF102U/F1DG102U Flip Hub

Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 002 Device 005: ID 046d:c01d Logitech, Inc. MX510 Optical Mouse
```

```
atom / # dmesg | grep sdc

[62823.516733] sd 2:0:0:0: [sdc] 7954432 512-byte logical blocks: (4.07 GB/3.79 GiB)

[62823.517666] sd 2:0:0:0: [sdc] Write Protect is on

[62823.517682] sd 2:0:0:0: [sdc] Mode Sense: 03 00 80 00

[62823.517693] sd 2:0:0:0: [sdc] Assuming drive cache: write through

[62823.519719] sd 2:0:0:0: [sdc] Assuming drive cache: write through
```

```
atom / # uname -a

Linux atom 2.6.31-gentoo-r6 #4 SMP Fri Nov 27 22:04:28 CET 2009 i686 Intel(R) Atom(TM) CPU N270 @ 1.60GHz GenuineIntel GNU/Linux
```

EDIT ----------------------------------------

I even tried setting the write protect to off using:

```
atom / # hdparm -r0 /dev/sdc

/dev/sdc:

 setting readonly to 0 (off)

 readonly      =  0 (off)
```

But this didn't change anything

----------

## NeddySeagoon

Sade,

You must umount the partition before you can make a filesystem.

----------

## Sade

Thanks Neddy, 

But I did,

if you forget to unmount you will get a different error:

```
atom / # mkfs.ext4 /dev/sdc1 

mke2fs 1.41.9 (22-Aug-2009)

/dev/sdc1 is mounted; will not make a filesystem here!
```

in stead of the read-only superblock error

----------

## pilla

Sade,

Are you sure that the lock slider is not moving to locked once it is inserted in the media reader? 

You may want to try to slide it to the middle too.

----------

## Sade

Ok, I did some testing,

I have 2 card readers, 

one is in the case, i'll call this the internal one, this reader i want to use

one is a multi card reader usb connected, i'll call this the external one

I also have 2 SD cards,

SD1: a miniSD inside an SD adapter, this card i want to use

SD2: a normal size SD card

When i use SD1 in the external card reader everything works,

When i use SD2 in the external card reader everything works,

When i use SD2 in the internal card reader everything works,

But (@&%#*) when i use the combination i want to use (SD1 in the internal card reader) then the weird protection problems occur,

----------

## Sade

 *pilla wrote:*   

> Sade,
> 
> Are you sure that the lock slider is not moving to locked once it is inserted in the media reader? 
> 
> You may want to try to slide it to the middle too.

 

You where totally right,

I opened up the (internal) reader, and it turns out that there is an mechanical switch, which is supposed to ''feel'' where the slider on the SD card is, but appearantly it doesn't do a very good job, setting the slider closer to the middle fixed the problem. (Also I gently forced the switch with my screwdriver to the write UNprotected position to prevent this from happening in the future.)

----------

## pilla

Glad to be of any help.

----------

