Ok so my problem is that I had a Jetflash 32 GB USB flashdrive which used to have 32,000,000,000 bytes, or in other words its capacity was 29.8 GiB. I used to be able to right click on windows and see 29.8 as a number.

Now I did make a bootable USB via Linux to install Manjaro on somebody's computer. I can't remember what exactly I did back then to the flash drive. Long story short, when I formatted the USB in my computer (which happened a few weeks after the aforementioned incident) my flash drive now has 28 GiB of storage.

So I lost almost 2 GiB! I don't see any partitions nor unallocated space using any Windows tool or gparted in Linux.

Is there any low level tool that can delete any mbr/lba or whatever flag data and check my sectors one by one to determine my original capacity?

I did not find anything on the Internet. All the "my USB pen shows less GB" related topics are for solving issues where there was a smaller partition showing up and the rest of the space was just unallocated but "visible" to diskmanager or partitionmanager or gparted etc which is not my case.

  • You can use MKUSB > Restore to a standard storage device (Debian/Ubuntu and derivatives only). If it still shows the same then it's possible some sectors were deemed as bad and marked "not for use" in one of the formats. – user772515 Sep 22 '17 at 8:11
  • What does gparted show now? Maybe Windows is just ignoring any extra partitions, but gparted shoudln't... There are proprietary programs to "re-flash" flash memory devices (USB drives, SD cards, etc), they're often used by scammers to sell a small (8-32GB) card that looks & kind of behaves like a much bigger card (128-256GB) but trying to write to the whole card will spot the fake. Last I read the programs were in Chinese... – Xen2050 Sep 22 '17 at 9:06
  • @MichaelBay I'll try that mk USB and get back to you but I dont think that it would do anything different than rightclick>format on windows but I have nothing to lose tying it either. – papajo Sep 22 '17 at 9:12

I used a dd-inspired tool like mkusb on a flash drive before, like the mkusb Ubuntu help page says they:

'use the whole device', actually only the head end (size of the iso file), but the rest of the device is not available. mkusb simply clones the ISO 9660 file system with its content from the iso file. This ISO 9660 file system works from CD/DVD disks, and also from USB drives. After using a USB pendrive like this, you make a new partition table and file system, if you want to use it for another purpose.

Down the the link chain leads to Help to Format a USB pendrive. Creating a new partition table, then partition(s) should do the trick, unless you run into the "special cases" of a problem flash device. The one I had just wouldn't really listen and would occasionally pick up remnants of the old ISO filesystem months after formatting & reusing it.

Overwriting the first gigabyte (where the ISO originally was) solved my problem, but if you wanted to overwrite the entire USB that should work too (at the expense of one less lifetime writes to the flash memory), or just the first megabyte is supposed to work too...

Using plan dd from linux should do it. First make 100% certain you have the correct device (like /dev/sdx, using lsblk or gparted or gnome-disk-utility or watching dmesg/the syslog when plugging in the device should tell you)

  • To overwrite just the first megabyte (1M, where M =1024*1024) you'd do

    dd if=/dev/zero of=/dev/sdx bs=1M count=1

    To overwrite more M's use a larger count.

  • To overwrite the first gigabyte (1G, where G =1024*1024*1024) do

    dd if=/dev/zero of=/dev/sdx bs=1G count=1
  • To overwrite the entire device, don't use any bs or count, just do

    dd if=/dev/zero of=/dev/sdx

    When it's finished dd will tell you how much it was able to write before reaching the end of the device, giving you an idea of how much is really writeable, similar to this:

    1+0 records in
    1+0 records out
    1048576 bytes (1.0 MB) copied, 0.000838339 s, 1.3 GB/s

If dd is taking a long time you can "Send a USR1 signal to a running 'dd' process mak[ing] it print I/O statistics to standard error and then resume copying." Use kill and pgrep or ps pkill or htop or maybe even killall if you're careful, or see man dd for an example like:

$ dd if=/dev/zero of=/dev/null& pid=$!
$ kill -USR1 $pid; sleep 1; kill $pid

18335302+0 records in 18335302+0 records out 9387674624 bytes  (9.4  GB)  copied,
34.6279 seconds, 271 MB/s

Once dd is finished, write a new partition table and make a new partition and format it. I'd use gparted, it's got a create partition table option in a menu, and usually works well.

  • bs=1M will just create blocks of 1MB size not write from the first sector and if I use bs=1G it will write blocks of 1GB which will make my USB drive very slow for copying files less than 1GB (which would the usual thing) are you sure about that? – papajo Sep 22 '17 at 10:42
  • Those "blocks" are just what dd uses, it doesn't change the device, just writes to it in chunks that size. Unless you use other flags like seek= or skip= then dd should start reading & writing at the "start" of each device. You might be thinking of the device's/drive's sector size, I'm pretty sure you can't change that - dd definitely can't – Xen2050 Sep 22 '17 at 11:11
  • Seriously, use wipefs unless you are determined to do a full zero out. An arbitrary partial zero out makes little sense. Also it doesn't wipe the backup GPT. – Tom Yan Sep 22 '17 at 13:50
  • @TomYan Like the multiple linked help pages suggest, even gparted alone should be fine with a normal drive, but this is a special case / problem drive. And where's the backup GPT kept, somewhere that overwriting every sector of the drive can't touch it? If it's on the drive & writable, then dd will overwrite it. – Xen2050 Sep 22 '17 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.