How do I restore a USB flash drive back to its original state?

dear community,

How do I restore a USB flash drive back to its original state? Note: i have some sticks here - that have flash-versions of linux on it - i want to use those sticks for other purposes now. so the question is:

How do I restore a USB flash drive back to its original state?

i tried to figure it out - and here is what i have gotten out of asking some friends and looking around here and there. i have written down all that i have found - plz set me straight if i am wrong…

here we go: the steps:
Or how can I reset a USB drive to factory settings? After having tooled around with a USB Linux version.

note: i do not want to use GUI-tools

should i do this with the usage of the dd raw command - and using the dd raw image overwritten or multi partitioned flash drive
i think it is pretty necessary to revert back to a single Fat, Fat32, exFAT or NTFS partition.

well which is the best way and method to reset or restore the USB flash drive back to its original state.
this means - how to allow the Resetted USB drive to be detected, readable, and useable again by all computers.

note: i have been working with tools such as Etcher to burn an ISO or Win32 Disk Imager to write an image.
that was great - but now - i want to restore it back to normal - on linux-terminal

well that said i think that it is pretty important to check first what is the USB flash drive name
i normally do this every time i am about to do anything with its file system.

so the very first step is to find the name of the device in the Terminal - on command line.

we can check the name in the command line too. it is found out be running this command:

sudo fdisk -l

this command helps us finding the name of the device using the terminal

so we are able to see all the partitions of our system as output of this command.
that is so great: we need to find our flash drive based on its size.

in the next step i am going to format a bootable USB to a let us say normal stick

we need to do several steps - that is to delete the entire file system from the USB device and then formatting it with a pretty new filesystem.

the first step is to wipe the filesystem from our flash drive

i for one i suggest to completely wipe the whole (that is all) filesystem from our flash drive:
With that we are to restore it to its original state - the genuinte state.

i sugest to run this command to wipe the filesystem from our demo flash drive:

sudo wipefs --all /dev/sdb

and afterward we can do a test:

well after we have wiped it - after we have wiped the filesystem - our usb-stick is pretty new - and completely clean.

we can check that with:

sudo fdisk -l
well how do you think about this plan.

A few things:

  • If you are going to use the USB to install an OS, there is no reason to erase it first. That is just wasted write cycles. You can just write the new image in place of the old one.
  • If all you want it the USB to be ready to go again and empty to write files to. You can write a new partition table and format it. That is all you need.
  • The only reason to wipe the device is if you are worried about someone using forensics or recovery software to access the data. If the prior data wasn’t personal information, don’t waste the write cycles. Most USB sticks have seriously limited write cycles before they start to fail.
3 Likes

warum solch Aufwand ?
:slightly_smiling_face:
Formatieren und gut ist…

why such expense ?
only formatting — that’s all

2 Likes

hello dear Dalto, hello dear colin

danke - danke für den tipp zu “formatieren” an colin…:wink:

many thanks for the quick reply also to you dalto- great to hear from you

thanks for the hints

  • If you are going to use the USB to install an OS, there is no reason to erase it first. That is just wasted write cycles. You can just write the new image in place of the old one.

thanks but in earlier times -when used a USB-stick to install an OS - then the whole (that means the entire ) stick was used.

  • If all you want it the USB to be ready to go again and empty to write files to. You can write a new partition table and format it. That is all you need.

again - for creating a stick with a installation-version of for example - eos then i used the whole (the entire) stick

  • The only reason to wipe the device is if you are worried about someone using forensics or recovery software to access the data. If the prior data wasn’t personal information, don’t waste the write cycles. Most USB sticks have seriously limited write cycles before they start to fail.

okay - you suggest not to wime the whole stick

many thanks for the hints.

great - i am loving this forum

That is fine. When you write an image to a stick, it overwrites the content. Deleting the data first has no purpose. It does the same thing if the disk is full or empty.

1 Like

yes fully agreed but what if i want to use afterwards the stick for any other purpose…?

do i now have to do some special treatments - use special methods and procedures - such as wiping??

probably not

In that case, write a clean partition table to it and format it. You still don’t need to erase it.

1 Like

hello dear Dalto

many thanks - guess you mean like so:

question

have a 16gb flash drive, which I want a live ISO to boot from (via unetbootin or something similar). It’ll be some 32bit distro that I can plug-in and boot on whatever computer I need to. Since it will be a live ISO, I’ll need somewhere to save data. I want the USB drive to have about 1gb for the distro, and the other 15gb for data storage.
I made two FAT partitions, the first called ‘bootable’ and the second ‘storage’. The storage works fine in Linux, but Windows only sees the bootable partition. The storage isn’t accessible.

ansswer

I would do it like this (assuming that sdb is your stick):

Delete any previous partition table:

# dd if=/dev/zero of=/dev/sdb bs=512 count=1
Create the new ones:

# fdisk /dev/sdb
> n
> p
> 1
(+1GB)
> a
> 1
(toggles boot flag)
> t
> c
(filesystem type)
> n
> p
> 2
(defaults)
> t
(specify 2nd partition)
> c
(filesystem type)
> p
(prints current configuration)
> w
(write the new table and quit)
Create the filesystems:

# mkfs.vfat /dev/sdb1
# mkfs.vfat /dev/sdb2

and besides this: answer 2

The absolutely easiest way I found using Linux was the following:

  1. Partition the drive (I used GParted) in 2 partitions with the SECOND partition being large enough to hold your operating system. My drive was a 2gb Flash Drive so I created a 500Mb Partition 1 and the remainder as Partition2.

  2. I installed the latest version of UNetbootin on my Linux Computer.

do you mean - i should go this way - with the partition… on a stick!?

That seems really complicated. I usually do it like this if the device is /dev/sdc(Don’t overwrite the wrong device):

sudo parted /dev/sdc -- mklabel gpt
sudo mkfs.exfat /dev/sdc
1 Like

hi dear Dalto
many thanks for the awesome guidance and for showing me how to do direct and easy.

many many thanks for all you do! it so great - to see such awesome support-.

have a great day

greetings
otrott

1 Like

siehst du ? ganz einfach bei Bedarf eine Partitionstabelle erstellen und das gewünschte Dateiformat zuteilen. :+1: ( = formatieren)
das Ganze kannst du auch einfach mit GParted machen

if necessary you may create a partition table and the file format of your choice. same thing works under GParted

1 Like

danke schön colin - vg
danke auch für den tipp mit GParted

Aber Achtung!
Wenn Du den Stick mit Gparted oder im Terminal “neu” machst gehört er dem Nutzer root.
Du solltest nach dem Formatieren mit
sudo chown -R user:user /run/media/user/LABEL
die Zugriffsrechte auf Deinen User übertragen.
In der Befehlszeile user jeweils mit Deinem Usernamen ersetzen und LABEL mit der Laufwerksbezeichnung.

But attention!
If you “rebuild” the stick with Gparted or in the terminal, it belongs to the root user.
You should
sudo chown -R user:user /run/media/user/LABEL
after formatting the stick, to transfer the access rights to your user.
In the command line replace “user” with your user name and “LABEL” with the drive name.

1 Like

sorry, ich hatte hier angenomment daß man GParted kennt… :wink:
btw GParted geht auch im Terminal

sorry ! I thought the workings of GParted would be known.
btw GParted is also able to run in terminal

English ?
Or post in German subforum :wink:

done :wink:

In this case he wouldn’t have to ask how to reset his USB drive.

this is just your view…
@otrott asked how to restore an USB flash drive,
not how to handle GParted :laughing: