7

I am trying to format an sdcard following this guide. I am able to successfully create the partition table, but attempting to format the Linux partition with mkfs yields the following output:

mke2fs 1.42.9 (4-Feb-2014)
Discarding device blocks:    4096/1900544

where it appears to hang indefinitely. I have left the process running for a while but nothing changes. If I eject the sdcard then mkfs writes the expected output to the terminal:

mke2fs 1.42.9 (4-Feb-2014)
Discarding device blocks: failed - Input/output error
Warning: could not erase sector 2: Attempt to write block to filesystem resulted in short write
warning: 512 blocks unused.

Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
476064 inodes, 1900544 blocks
95026 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1946157056
58 block groups
32768 blocks per group, 32768 fragments per group
8208 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done                            
Warning: could not read block 0: Attempt to read block from filesystem resulted in short read
Warning: could not erase sector 0: Attempt to write block to filesystem resulted in short write
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:  0/58
Warning, had trouble writing out superblocks.

Why is mkfs reporting that we are "discarding" blocks and what might be causing the hangup?


EDIT

I am able to successfully create two partitions -- one at 100MB and the other 7.3GB. I then can format, and mount, the 100MB partition as FAT32 -- it's the ext4 7.3GB partition that is having this trouble.

dmesg is flooded with:

[ 9350.097112] mmc0: Got data interrupt 0x02000000 even though no data operation was in progress.
[ 9360.122946] mmc0: Timeout waiting for hardware interrupt.
[ 9360.125083] mmc_erase: erase error -110, status 0x0
[ 9360.125086] end_request: I/O error, dev mmcblk0, sector 3096576

EDIT 2

It appears the problem manifests when I am attempting to format as ext4. If I format the 7.3GB partition as FAT32, as an example, the operation succeeds.

EDIT 2

To interestingly conclude the above, I inserted the sdcard into a BeagleBone and formatted it in the exact same way I was on Mint and everything worked flawlessly. I removed the sdcard, reinserted it into my main machine and finished copying over the data to the newly created and formatted partitions.

sherrellbc
  • 2,461
  • 7
  • 28
  • 41
  • 1
    It looks like a failing SD card. – David King Jan 11 '16 at 18:01
  • Is there any output in kernel log, related to this process? You can use `dmesg` to see. – TNW Jan 11 '16 at 18:05
  • @DavidKing, I would suggest the same thing, however, another partition formatted as fat32 (100MB) will successfully mount. I edited the OP with more information. – sherrellbc Jan 11 '16 at 18:26
  • @sherrellbc Are you saying you have a second partition on that same card that is working? If so that doesn't mean your card is fine. It's entirely possible that there are bad blocks on the card that aren't affecting the FAT32 partition but *are* affecting your new partition. – David King Jan 11 '16 at 18:28
  • @DavidKing, I see. I further updated the OP with information from dmesg. – sherrellbc Jan 11 '16 at 18:29
  • @DavidKing, I am able to successfully format the 7.3GB partition as FAT32 without issue. It appears that the problem occurs only when formatting to ext4. – sherrellbc Jan 11 '16 at 18:43
  • The problem does not occurs as FAT32 because contrary to ext4, FAT32 only initialises a couple of sectors at the beginning of the partition.It is probably a bad card. They go bad after a while of being (ab)used. – Rui F Ribeiro Jan 11 '16 at 18:53
  • @RuiFRibeiro, I am unsure of the brand, but it's the same card that shipped with the Rpi. Do you have any suggestions on verifying if I do, indeed, have a bad sdcard? – sherrellbc Jan 11 '16 at 18:55
  • 1
    I myself have gone already through a two damaged sdcards. You can always do a dd to your sd, `dd if=/dev/mmc0 of=/tmp/file_on_disk bs=1024`. If it fails, you know for sure it is bad, if it does not fail, well, it is *probably* bad. I would not waste more time over it. – Rui F Ribeiro Jan 11 '16 at 18:57
  • @DavidKing, as an interesting conclusion, I placed the sdcard into a BeagleBone device and formatted it there without problem. All is well and no errors are being observed. – sherrellbc Jan 11 '16 at 19:59
  • I have already tried to format an SD card in ext4 unsuccessfully, I got I/O errors too. Maybe a SD card can't be formatted to ext4? – Sw0ut Jan 11 '16 at 22:04
  • @Sw0ut, I was able to successfully do this by mounting the sdcard on a BeagleBone running Angstrom. I am not sure why it did not work on Mint. – sherrellbc Jan 11 '16 at 22:08
  • The best course of action is buying a new one and testing it. I paid 3 euros for an 8 GB card – Rui F Ribeiro Jan 12 '16 at 03:36
  • @RuiFRibeiro, it is not that I am concerned about the cost, I was just wondering why it was not working. Everything was pointing to an apparent hardware failure -- yet all works perfectly after using a different platform (the beagle bone device) to mount and format the device. There is apparently something wrong with how Linux Mint was interfacing with the sdcard. – sherrellbc Jan 12 '16 at 03:38
  • tell us your kernel version and distro – Rui F Ribeiro Jan 12 '16 at 03:52
  • and how old is that card – Rui F Ribeiro Jan 12 '16 at 03:54
  • @RuiFRibeiro, I was using Linux Mint with kernel 3.13.0-37 on x86_64. – sherrellbc Jan 12 '16 at 03:58
  • damn. let me pickup my notebook. – Rui F Ribeiro Jan 12 '16 at 04:03
  • Posted an answer. – Rui F Ribeiro Jan 12 '16 at 04:12

1 Answers1

3

I actually suspect you are being bitten by a much talked ext4 corruption bug in kernel 3 and 4. Have a look at this thread,

http://bugzilla.kernel.org/show_bug.cgi?id=89621

There have been constant reports of corruption bugs with ext4 file systems, with varying setups. Lots of people complaining in forums. The bug seems to affect more people with RAID configurations.

However, they are supposedly fixed in 4.0.3.

"4.0.3 includes a fix for a critical ext4 bug that can result in major data loss."

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=785672

There are other ext4 bugs, including bugs fixed as of the 30th of November [of 2015].

https://lists.ubuntu.com/archives/foundations-bugs/2015-November/259035.html

There is also here a very interesting article talking about configuration options in ext4, and possible corruption with it with power failures.

http://www.pointsoftware.ch/en/4-ext4-vs-ext3-filesystem-and-why-delayed-allocation-is-bad/

I would test the card with other filesystem other than ext4, maybe ext3.

Those systematic bugs with ext4 are one of the reasons I am using linux-image-4.3.0-0.bpo.1-amd64 from the debian backports repository in Jessie in my server farm at work.

Your version in particular, kernel 3.13 seems to be more affected by the bug.

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1298972 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1389787

I would not put it aside maybe some combination of configuration and hardware at your side is triggering the bug more than usual.

SD cards also go bad with wear and tear, and due to the journaling filesystem, an ext4fs system is not the ideal for an SD card. As a curiosity, I am using a Lamobo R1 and using the SD card just for booting the kernel, with an SSD disk.

http://linux-sunxi.org/Lamobo_R1

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227