0

So I bought a brand new 128GB USB stick and plugged it into my raspberry pi.

I then use the command line to make a new partition and extra filesystem using fdisk and mkfs.ext4

Seemed to go ok. I then used rsync to copy a 65GB of data to the usb stick and left it over night.

The next morning the rsync had a order prematurely with an error that the device was full. Sure enough, df confirmed 100% full. A bit confused I tried to unmount, but I couldn't so I rebooted. On rebooting the device would not mount saying that there is an error so I ran e2fsck and it corrected a load of stuff about inodes and superblocks and the journal. Afterwards, all the data is gone and the drive is at 0% but will mount.

Exactly the same happened again when I tried to copy the files again. So I tried reformatting and this time the drive reports errors straight away. e2fsck find and fixes them, but running it again find errors again and again so it seems to be ineffectual.

I then decided to plug it into a Windows pc and do a full format as exFAT. Took a long time, but I could copy data onto it and read it fine. Back on Linux, I can copy data to it and read the data. Reformat as ext4; errors again.

So I have formatted as exFAT and now running badblocks. It has nearly finished and found nothing wrong. Why am I having so much difficulty with this drive?

3 Answers 3

1

There are various counterfeit USB sticks and memory cards on the market. These frequently appear to have a much larger capacity than they actually do have. The more clever fakes are designed to pass simple tests and be actually usable... until you attempt to store more data than their actual capacity is. At that point, you will get data corruption and errors. The behaviour you're seeing might fit this situation.

You might try checking your USB stick with a program that is dedicated to detecting fake storage devices. Here are a few examples, in no particular order:

https://www.raymond.cc/blog/test-and-detect-fake-or-counterfeit-usb-flash-drives-bought-from-ebay-with-h2testw/

https://www.geckoandfly.com/22803/detect-fake-usb-flash-drives-sd-cards-ssd-disk/

3
  • Possibly, though it is from a reputable seller, not an online market place. I will give those checks a look, but I would have thought it would fail the badblocks test?
    – James
    Commented Apr 27, 2018 at 4:24
  • @James They won't fail such a simple test. Every block the device claims to have can be written and read back successfully. But different addresses may address the same physical block. I have come across one such fake media myself when a friend asked for help with data recovery. It claimed to be a 32GB device but was in reality only 128 MB. The first 96MB of the device were completely genuine. The rest of the device was the same 32MB of blocks being accessed more than 1000 times through different addresses.
    – kasperd
    Commented Apr 29, 2018 at 22:40
  • @James If you want to detect such forgeries what you have to do is to write pseudo-random data to the media and read back random locations to verify that they have correct content. Once the amount of pseudo-random data you have written exceeds the real capacity of the media you will soon start seeing incorrect data coming back when you read from random previously written locations.
    – kasperd
    Commented Apr 29, 2018 at 22:42
0

Try to detect bad blocks on the device.

You can use e2fsck -c -c -k …
mkfs.ext4 also supports -c option.

Double -c conducts slow read&write tests.
Single -c conducts faster read tests.
-k options preserves list of bad blocks detected earlier (e.g. if you use single -c tests before double -c tests).

1
  • Thanks, I will give this a go and see what happens
    – James
    Commented Apr 27, 2018 at 4:23
0

Same situation on Ubuntu for a flash drive with 128 GB. The usb flash starts at exFAT. On ext4 there will be problems:

  1. from Disks only 64 GB format is possible.
  2. first files on gui will give errors.

But it can be fixed:

sudo apt install f3
sudo f3probe -t -n /dev/sdX #replace X with the drive letter

If it is a problem it will mention about f3fix. For me, the argument --last-sec=134217727 was required and now the disk has 69 GB.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .