Issues formatting (corrupted?) usb device

Hello.

I was playing around with a 128GB dual usb drive (usb 3.0 + usb-c) that I use for media consumption between my computers and phone.

My phone (OnePlus 6: Android) does this weird thing where it sometimes can't read the usb and only comes up with an option to format it to an appropriate filesystem (exfat). I've used this option in the past with the usb in question as well as other usb drives without any issue.

I formatted the usb to an exfat filesystem (not really sure if I used the phone or the laptop to do that, it's been a while) and after loading it up with some movies it's now kind of unusable:

  • I can mount it on my laptop and read data from it, but I can't write anything to it (e.g. delete existing movies or load up new ones)
  • My phone can read it but only briefly; it auto-ejects after ~30 seconds
  • I can't seem to be able to reformat it using mkfs, fdisk, or my phone. The former two options end up hanging forever (I've tried letting both run for more than 8 ours to no avail). The hanging also occurs when I try to write anything to the drive as well.

Some terminal output that might help:

  • fsck
> sudo fsck -CM /dev/sdb
[sudo] password for george:
fsck from util-linux 2.37.3
e2fsck 1.46.5 (30-Dec-2021)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/sdb

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
 or
    e2fsck -b 32768 <device>

/dev/sdb contains `DOS/MBR boot sector; partition 1 : ID=0xb, start-CHS (0x0,4,5), end-CHS (0x3c1,217,24), startsector 256, 245759744 sectors, extended partition table (last)' data
  • blkid
/dev/sdb1: UUID="F1DF-B900" BLOCK_SIZE="512" TYPE="exfat" PTTYPE="dos" PARTUUID="57529403-01"
  • fdisk
Disk /dev/sdb: 117.19 GiB, 125829120000 bytes, 245760000 sectors
Disk model: FDU050
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: 0x57529403

A possible cause of the issue might have been physically ejecting the usb drive while it was still in use, but as I said earlier this was a while ago so I don't really remember.

This is likely not the right forum to be posting these kinds of issues so apologies in advance. On that note, besides possible solutions to my problem, I'd very much appreciate suggestions on which forums / subreddits to move this conversation to. Cheers!

EDIT: New information

  • findmnt
findmnt -fn usb
/mnt/usb /dev/sdb1 exfat  rw,relatime,fmask=0022,dmask=0022,iocharset=utf8,errors=remount-ro

I also tried using dd to fill the usb with zeros as per @BluishHumility 's suggestion but that led to the hanging again after running without issues for ~30 seconds.

Try navigate to /run/media/your_user_name and ls to see if root owns the drive. use sudo chown -R your_user_name drive_name . Ive done this several times to usb sticks I got locked out of.
Worth a try :smiley:

1 Like

If you want to start over, you can give the drive a complete wipe by writing it with all zeros.

dd if=/dev/zero of=/dev/sdb bs=1M

Use lsblk first and double- or triple-check that the drive you want to erase is still sdb and hasn't changed to sdc or something else.

Just to be clear, this is a very destructive command and you need to be careful to make sure you point it at the correct device.

Afterward you can set up GPT with parted or gparted. I see now the device has MBR but unless you have a compelling reason to use MBR I would just use GPT.

After that, you should be able to sudo mkfs.exfat /dev/sdb, or whatever filesystem you want to go with.

3 Likes

Thanks for the suggestion, but no luck unfortunately. It runs fine for the first 30 seconds, erasing about 2.4GB in the process, but then it stops and hangs as described previously.

I should also mention that once I mount this usb, unmounting causes the same hanging issue so I need to physically eject it each time.

No luck with this one. I get an operation not permitted error even with super user priviledges.
Tried looking at / changing the file attributes with lsattr/chattr and I get an "Operation not supported while reading flags" error.

I hate to say so, but it sounds like you might have a counterfeit flash drive on your hands. Is it new? Where did you get it from?

Sometimes dishonest companies will essentially hack a flash media device and force the device to represent the capacity as higher than the actual storage capacity. Some of the drive space will be usable (whatever the actual physical capacity is), but once you get to the "fake" part of the drive you start running into problems.

I used to have a piece of software on another Linux install called f3probe, which can detect when you have one of these counterfeit devices and can help "fix" the device (the fix would be to identify the usable portion of the device, and format a partition so only the good chunk would be used).

It's a great piece of software, I haven't used it since last year but it looks like it's in the AUR: AUR (en) - f3

2 Likes

You can use dd to overwrite the beginning and end sectors. Backup partition data is also stored at the end sectors depending on the file system. Wiping the end sectors could possibly help, as your prior dd command should have wiped the beginning sectors already.

Remove all other external devices when using dd, as a mistake executing that command will give you a memorable life lesson.

1 Like

If you havent pull out all your hair by now. try gparted as was recommended. 1. ensure you select correct drive. 2. create new partition table 3. create a partition making sure it is GPT , give it a label, set the mount and apply changes. 4. format the partition. this should work. I use this to set up my Tib storage drives as I can see what I am doing.

Sorry to contradict you, but generally if it's not working via the terminal rarely will a GUI method be more successful.

2 Likes

I'm currently running the f3probe command while typing this. It's been going for about half an hour now with no signs of finishing any time soon.
I'm not really sure about the counterfeit flash device, it's an SSK flash drive I bought from amazon. I have other storage related products from that company that I also bought from amazon and they're working well so far.

It might be that the flash drive is either faulty due to a manufacturing issue, or I somehow messed it up so bad that it's irrecoverable. A bit annoying, but nothing too major. As I said, I used it for media consumption (i.e. watching moves + listening to music) and it wasn't very expensive anyway.

Tried it with the same results as any other method so far unfortunately. I'm currently running the f3probe command on it, but not very hopeful about it tbh.

If I stumble across any solution, or if the command actually finishes, I'll update the post. Otherwise, RIP my usb. Thanks for the suggestion anyway.

1 Like

Forgot to mention in the original post, but I've tried messing around in a GParted Live instance, but when attempting to save the changes I get the same-old hanging without any error messages.

Perhaps sgdisk may prove more helpful than other terminal apps. Use the --zap option to completely wipe all partition information (then attempt a format).

Again, be very careful that you are selecting the the right destination.

Sgdisk has worked for me in the past when all else failed.

However, I'm not sure if it will help in your case because of your file system format.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.