USB Drive Unable to Erase

Hello, I have an issue that I’ve not come across before and hope someone might have some sage words to assist.
I used the following command to place the manjaro mate iso onto a usb stick to use as a install medium:
sudo dd bs=4M if=manjaro-mate-20.2-201212-linux59.iso of=/dev/sdb status=progress oflag=sync

And that works wonderfully to install manjaro mate. The issue is that now I can not format the drive at all.

I have a feeling that the geometry of the device is not being correctly reported to the kernel. sfdisk doesn’t support cylinder / head/ sector options since 2.26.

  # lsblk
    sdb                                             8:16   1 225.3G  0 disk  
├─sdb1                                          8:17   1   2.2G  0 part  
└─sdb2                                          8:18   1     4M  0 part  

❯ sudo fdisk /dev/sdb
Welcome to fdisk (util-linux 2.36.2).

Command (m for help): p
Disk /dev/sdb: 7.65 GiB, 8213966848 bytes, 16042904 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: 0x50452f44

❯ ls -l /dev/disk/by-id/usb*
lrwxrwxrwx 1 root root 9 Apr 5 11:09 /dev/disk/by-id/usb-JetFlash_Transcend_256GB_03X87O8S9PCAOPL9-0:0 → …/…/sdb
lrwxrwxrwx 1 root root 10 Apr 5 11:09 /dev/disk/by-id/usb-JetFlash_Transcend_256GB_03X87O8S9PCAOPL9-0:0-part1 → …/…/sdb1
lrwxrwxrwx 1 root root 10 Apr 5 11:09 /dev/disk/by-id/usb-JetFlash_Transcend_256GB_03X87O8S9PCAOPL9-0:0-part2 → …/…/sdb2

❯ sudo gdisk -l /dev/sdb
GPT fdisk (gdisk) version 1.0.7

Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: not present


Found invalid GPT and valid MBR; converting MBR to GPT format
in memory.


Disk /dev/sdb: 16042904 sectors, 7.6 GiB
Model: Transcend 256GB
Sector size (logical): 512 bytes
Disk identifier (GUID): F1C8556C-1791-4DB4-B500-29CF59AB1DAE
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 16042870
Partitions will be aligned on 2048-sector boundaries
Total free space is 16042837 sectors (7.6 GiB)

Hello @Aeolus :wink:

Just run:

sudo wipefs -a -f /dev/sdb

and it should be done. But it just deletes only all signatures.

Hey megavolt, after running wipefs the drive still only shows 7.65 GiB.

Then just create new partition table on it with gparted or similar :wink:

I’m sorry I should have posted the output, it’s still showing the total size of the disk as 7.65GB vice 256GB:

❯ sudo fdisk -l /dev/sdb
[sudo] password for wildman:
Disk /dev/sdb: 7.65 GiB, 8213966848 bytes, 16042904 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

I can create a partition but it will carve it out of the total size being reported to the kernel, which in this case is wrong.

ok… let me think:

  1. fdisk and gdisk reports this:

gdisk reports also this model:

You just dd and image to it:

and lsblk reports this after:

I guess at this point you have never formatted the drive, right? So it was pre-formated?

From this data, I would assume that this flash drive is a fake one and reported first the wrong size, but linux has detect the correct size after reformatting.

Here is a tutorial how to check if it is a fake usb: How to Check Real USB Capacity in Linux Terminal - LinuxBabe

I ran F3:

❯ sudo f3probe /dev/sdb
F3 probe 8.0
Copyright © 2010 Digirati Internet LTDA.
This is free software; see the source for copying conditions.

WARNING: Probing normally takes from a few seconds to 15 minutes, but
it can take longer. Please be patient.

Probe finished, recovering blocks… Done

Good news: The device `/dev/sdb’ is the real thing

Device geometry:
Usable size: 225.28 GB (472444928 blocks)
Announced size: 225.28 GB (472444928 blocks)
Module: 256.00 GB (2^38 Bytes)
Approximate cache size: 0.00 Byte (0 blocks), need-reset=no
Physical block size: 512.00 Byte (2^9 Bytes)

So now I’m running: sudo dd of=/dev/sdb if=/dev/zero
To see if I can actually write something to it.
Here’s the output of lsblk now:

❯ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 238.5G 0 disk
└─sda1 8:1 0 238.5G 0 part
└─luks-3f8f3cbb-5736-47a8-afb8-2ee4676b2350
254:0 0 238.5G 0 crypt /
sdb 8:16 1 225.3G 0 disk

Edit: We were thinking the same thing about the fake drive…lol

That is really strange. Maybe there is problem with flash drive, maybe it is the kernel driver. idk. To check this i would recommend to replace the flash drive with the same model and try again. If it is still the same, then there must be something wrong with driver.

To follow-up:

❯ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 238.5G 0 disk
└─sda1 8:1 0 238.5G 0 part
└─luks-3f8f3cbb-5736-47a8-afb8-2ee4676b2350
254:0 0 238.5G 0 crypt /
sdb 8:16 1 225.3G 0 disk
└─sdb1 8:17 1 225.3G 0 part
❯ sudo mkfs.ext4 /dev/sdb1
mke2fs 1.46.2 (28-Feb-2021)
Creating filesystem with 59055360 4k blocks and 14770176 inodes
Filesystem UUID: 4e75e922-ae88-4c33-99d7-23381e9ee5e1
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done

Hello,

the same Yesterday here.
Back from Kernel 5.11.6-1 to LTS 5.4.101-1 and allready is fine.

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