0

Context:
Today I was trying to figure out how to install NixOS live usb with a writeable filesystem (dd-ing the iso results in read-only iso9660 fs).

I split my usb into two partitions, one empty and one formatted to ext4. I ran something like dd if=(nixos image).iso of=/dev/sdb1. Then I realized that it probably won't work so I opened gparted to delete everything and try something else.

This is where I noticed that something strange is happening: gparted said that my 32GB pendrive has only about 1,4GB (size of first partition). It seems that /dev/sdb is the same thing as /dev/sdb1 now.enter image description here

The disk utility sees the second partition but is unable to remove it or to format the entire drive.enter image description here enter image description here

My windows machine doesn't see the pendrive at all.

I also have tried wipefs /dev/sdb

How can I bring my pendrive back to usable state?

Update:

The problem is gone after restarting (now i'm embarrassed that I didn't try this earlier). I can't find a way to reproduce it. One thing I forgot to mention is that I've also mounted the iso as a loop device but I later unmounted it. As you can see on the gnome-disks screenshot a loop device was still there, but I'm not sure if it was pointing to the iso or to the first partition on pendrive. So perhaps the loop mount somehow interfered with accessing /dev/sdb?

Just to clarify, I have tried zeroing the entire drive as well as just the first megabyte. This didn't work because /dev/sdb was not pointing to what it should(at least that's my interpretation).

  • 1
    Remove the stick. Count to ten. Put it back in. Then wipe the first MB from the device itself. It's possible the kernel is confused with what partitions are still on it. – roaima Jun 9 '18 at 21:12
  • Using Gparted from the menu select Device then Create a partition table and select msdos. Create an NTFS partition to be reorganized by windows. – GAD3R Jun 9 '18 at 21:34
0

The problem you are describing was caused by a low-level device tool (like dd) writing blocks at the wrong size directly onto the device.

To fix this, you need to re-write the device blocks to the appropriate size. This can be done with dd. Double check your output device before running the command

sudo dd if=/dev/zero of=/dev/sdb bs=2048 count=32

Once the dd command is done, you should be able to access your device through gparted.

or else try below command

wipefs -a /dev/your-device

it will erase all partition in your disk

  • Thank you for the answer. I've tried both methods but the problem is still there. Gparted now reports /dev/sdb to have exactly 512MiB. – AAaaaaaa Jun 9 '18 at 21:32
0

If the USB pendrive is still healthy physically/electronically, it will help to wipe the first mibibyte, to overwrite it with zeros. This way confusing data will be removed and most partitioning tools will be able to manage it.

You can use mkusb for this purpose. See the following links,

help.ubuntu.com/community/mkusb

help.ubuntu.com/community/mkusb/wipe

If there are still problems, I suggest that you analyze the problem and try to solve them according to the following link,

Can't format my usb drive. I have already tried with mkdosfs and gparted

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.