DEV Community

hub
hub

Posted on • Updated on

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

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

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.

update: another method could be to go like this way:

https://unix.stackexchange.com/questions/30322/how-do-i-partition-a-usb-drive-so-that-its-bootable-and-has-a-windows-compatibl

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.

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

`

https://unix.stackexchange.com/questions/30322/how-do-i-partition-a-usb-drive-so-that-its-bootable-and-has-a-windows-compatibl

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.

or - much less complicated: 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

*update: *

we can use also the "dd" -Kommando,

sudo mkfs.ext4 /dev/sdX

with the filesystem "ext4"

sudo fdisk /dev/sdX

sudo dd if=/dev/zero of=/dev/sdX bs=1M status=progress

Top comments (0)