LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   General (https://www.linuxquestions.org/questions/general-10/)
-   -   Can't write to micro SD card (https://www.linuxquestions.org/questions/general-10/cant-write-to-micro-sd-card-4175666425/)

jesusangel 12-23-2019 05:59 AM

Can't write to micro SD card
 
Hello,

I have a micro SD card which I was using in a Raspberry PI 3. I can read from and write to it, but after remounting the filesystems, the new files disappear.

The card has two partitions, one with a FAT32 filesystem and other one with an ext4 filesystem.

Code:

Disk /dev/sda: 14,9 GiB, 16021192704 bytes, 31291392 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
Disklabel type: dos
Disk identifier: 0x8f1eafaf

Device    Boot  Start      End  Sectors  Size Id Type
/dev/sda1        8192  131071  122880  60M  c W95 FAT32 (LBA)
/dev/sda2      131072 31291391 31160320 14,9G 83 Linux

The card is not write protected:

Code:

# hdparm -r /dev/sda

/dev/sda:
 readonly      =  0 (off)

I can mount the filesystems RW and a write operation in the card doesn't return any error:

Code:

/dev/sda1 on /mnt/slot1 type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
/dev/sda2 on /mnt/loop type ext4 (rw,relatime,data=ordered)

# file loop/rnd.bin
loop/rnd.bin: data

# umount /mnt/loop
# mount /dev/sda2 /mnt/loop
# ls -l /mnt/loop/rnd.bin
Can't access to /mnt/loop/rnd.bin. No such file or directory

I have checked both filesystems:

Code:

# dosfsck -w -r -l -a -v -t /dev/sda1
fsck.fat 4.1 (2017-01-24)
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "mkfs.fat"
Media byte 0xf8 (hard disk)
      512 bytes per logical sector
      8192 bytes per cluster
        1 reserved sector
First FAT starts at byte 512 (sector 1)
        2 FATs, 16 bit entries
    16384 bytes per FAT (= 32 sectors)
Root directory starts at byte 33280 (sector 65)
      512 root directory entries
Data area starts at byte 49664 (sector 97)
      7673 data clusters (62857216 bytes)
63 sectors/track, 255 heads
        0 hidden sectors
    122880 sectors total
Checking file /boot
../..
Checking file /overlays/imx219.dtbo (IMX219~1.DTB)
Checking for bad clusters.
Reclaiming unconnected clusters.
/dev/sda1: 215 files, 3020/7673 clusters

#  fsck.ext4 -fv /dev/sda2
e2fsck 1.43.4 (31-Jan-2017)
Paso 1: Verificando nodos-i, bloques y tamaños
Paso 2: Verificando la estructura de directorios
Paso 3: Revisando la conectividad de directorios
Paso 4: Revisando las cuentas de referencia
Paso 5: Revisando el resumen de información de grupos

      208423 nodos-i utilizados (21.68%, el 961520)
        654 ficheros no contiguos (0.3%)
        399 directorios no contiguos (0.2%)
            número de nodos-i con bloques ind/dind/tind: 0/0/0
            Histograma de las profundidades de «extents»: 188727/231
    2177729 bloques usados (55.91%, el 3895040)
          0 bloques dañados
          1 fichero grande

      165610 ficheros regulares
      23075 directorios
          55 dispositivos de caracteres
          25 dispositivos de bloque
          0 fifos
          64 vínculos
      19649 enlaces simbólicos (19377 vínculos simbólicos rápidos)
          0 zócalos
------------
      208478 ficheros

I tried also to delete the partitions but I couldn't. I couldn't either create new filesystem. The mkfs.ext4 ran without errors, but after mounting the new filesystem, the old files are still there.

What's happening?
Maybe the card is broken?

Kind regards,

fatmac 12-23-2019 07:10 AM

On your mSDHC card, the first partition is vfat & contains the boot files, your second partition is ext4, & should be mounted as / (the root file system). Any files that you save to that disk should be found in /home/pi, the standard user.

jesusangel 12-23-2019 08:02 AM

Hi,

I'm mounting the sd card filesystems in another computer, so I can write anywhere, not only in the pi's home directory.

I'm sorry. I've realized I made a mistake when I posted this tread. I wanted to post it in the Linux General forum, but I did in Non-*NIX > General.

I've made a new post in the right forum, so please forget about this one.

Kind regads,

Quote:

Originally Posted by fatmac (Post 6070643)
On your mSDHC card, the first partition is vfat & contains the boot files, your second partition is ext4, & should be mounted as / (the root file system). Any files that you save to that disk should be found in /home/pi, the standard user.


jsbjsb001 12-23-2019 08:15 AM

Quote:

Originally Posted by jesusangel (Post 6070668)
I've made a new post in the right forum, so please forget about this one.
...

You should have just clicked the Report button and asked for it to be moved instead if you posted in the wrong forum (which yes, you did).

I'm reporting this thread to be closed as a dupe.

jesusangel 12-23-2019 08:18 AM

Hello,

I was searching for a close thread buttom or something similar. I didn't know that the correct button was the report one. Thank you for the info.

Kind regards,

Quote:

Originally Posted by jsbjsb001 (Post 6070670)
You should have just clicked the Report button and asked for it to be moved instead if you posted in the wrong forum (which yes, you did).

I'm reporting this thread to be closed as a dupe.


jsbjsb001 12-23-2019 08:21 AM

There is no "close thread" option - only mods and Jeremy can do that (and the same for moving threads). The Report button is also there for asking for a thread to be moved, as much as reporting posts that break LQ rules.


All times are GMT -5. The time now is 06:36 AM.