LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (https://www.linuxquestions.org/questions/ubuntu-63/)
-   -   How to reformat a USB stick in Ubuntu (https://www.linuxquestions.org/questions/ubuntu-63/how-to-reformat-a-usb-stick-in-ubuntu-568157/)

izquierdista 07-10-2007 01:03 PM

How to reformat a USB stick in Ubuntu
 
I would like to know if there is any possible way for me to wipe everything on my USB stick and reformat it to its original state.

I am asking this because there are some files that I am unable to erase by simply putting them in the trash, everytime I try this the erasing files window hangs and nothing happens.

I already backed up all my crucial files and now I want to just want to clean this drive and free it of the junk files I dont need.

one last thing, I want to format it so that it can be used with windows and Ubuntu, I think it is the fat32, or whatever the default is on most usb sticks.

thanks,

b0uncer 07-10-2007 01:12 PM

Most usb "sticks" use fat16 actually, not fat32, but it shouldn't matter. Let's think your usb stick had the device file /dev/sda (otherwise change that):

Code:

dd if=/dev/zero of=/dev/sda
that would write it full of zero stuff from /dev/zero, making it pretty empty. After this just create a fat filesystem on the device.

To create a fat filesystem on the device you could use something like this, for example:
Code:

mkfs.vfat /dev/sda
A command called 'mkdosfs' may be the same as mkfs.vfat.

izquierdista 07-10-2007 01:24 PM

Ok just to make sure I dont screw something up,

I clicked on the USB drive icon on the desktop and went to properties, I looked at the volume information and it says this:

Mountpoint: /media/LexarMedia
Filesystem: vfat


judging from this does it mean that I can use the /dev/sda/ command you told me?

b0uncer 07-10-2007 01:27 PM

That information doesn't tell you much, but
Code:

mount | grep LexarMedia
shows the device file (it's the file that resides under /dev/ that the above command's result shows among other information). Command 'mount' without options shows all mounted devices (you'll need to have the stick plugged in and mounted while you do the above) and grep picks up the line that talks about your stick.

When starting to do the dd thing, umount the device; don't eject it, it has to be present on the system, but umount it so that the filesystem is not in use:
Code:

umount /dev/sda1
Another way is to command
Code:

dmesg
right after plugging the device in; there's information about it.

EDIT: if you go on with 'sda1' and your device was called something else, like 'sda4', it doesn't harm unless there actually is a connected device that is 'sda1'. If the device is not present, you'll simply get an error. However if you had two usb sticks for example, or had a sata harddisk, then it would possibly produce an unwanted result. If you don't have sata harddisks and you only have that one usb stick plugged in, it's very probably /dev/sda1, but if there are other USB or SATA devices connected, it might not.

About these device namings:
sda = primary usb or sata disk
sdb = secondary usb or sata disk
hda = primary ide harddisk
hdb = secondary ide harddisk
sda1 = first partition of the primary usb/sata disk
hdb3 = third partition of the secondary ide harddisk
etc....got it?

izquierdista 07-10-2007 01:42 PM

Ok I got this error message:


Code:

chacmool@link:~$ mkdosfs /dev/sda
mkdosfs 2.11 (12 Mar 2005)
mkdosfs: Will not try to make filesystem on full-disk device '/dev/sda' (use -I if wanted)

I tried typing -I but I got this:

Code:

chacmool@link:~$ -I
Usage: command-not-found [options] <command-name>


So now what should I do?
should I restart the whole process?

izquierdista 07-10-2007 01:45 PM

OK I did it now,

thanks for the help, all I had to do to make it reformat it was this:

Code:

chacmool@link:~$ mkdosfs /dev/sda -I

:) :) :cool:

dive 07-10-2007 01:46 PM

mkdosfs /dev/sda1?

edit- nevermind but sda1 is the actual partition


All times are GMT -5. The time now is 12:53 PM.