LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices

Reply
 
Search this Thread
Old 07-10-2007, 02:03 PM   #1
izquierdista
Member
 
Registered: Mar 2005
Distribution: Ubuntu
Posts: 342

Rep: Reputation: 30
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,
 
Old 07-10-2007, 02:12 PM   #2
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
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.

Last edited by b0uncer; 07-10-2007 at 02:15 PM.
 
Old 07-10-2007, 02:24 PM   #3
izquierdista
Member
 
Registered: Mar 2005
Distribution: Ubuntu
Posts: 342

Original Poster
Rep: Reputation: 30
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?
 
Old 07-10-2007, 02:27 PM   #4
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
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?

Last edited by b0uncer; 07-10-2007 at 02:36 PM.
 
Old 07-10-2007, 02:42 PM   #5
izquierdista
Member
 
Registered: Mar 2005
Distribution: Ubuntu
Posts: 342

Original Poster
Rep: Reputation: 30
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?
 
Old 07-10-2007, 02:45 PM   #6
izquierdista
Member
 
Registered: Mar 2005
Distribution: Ubuntu
Posts: 342

Original Poster
Rep: Reputation: 30
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

 
Old 07-10-2007, 02:46 PM   #7
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,211

Rep: Reputation: 293Reputation: 293Reputation: 293
mkdosfs /dev/sda1?

edit- nevermind but sda1 is the actual partition
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
avm WLAN USB-stick on Ubuntu 6.10 (Edgy Eft) annuzzer Linux - Wireless Networking 2 02-26-2010 04:07 AM
avm WLAN USB-stick (Ubuntu 6.10) annuzzer Linux - Wireless Networking 1 11-27-2006 06:32 PM
Can't reformat drive with Ubuntu jadeorb Linux - Newbie 14 09-11-2006 07:54 AM
usb-stick Problems-ubuntu mihalisla Ubuntu 5 08-29-2006 06:36 AM
mount/umount usb stick - PQI Intelligent Stick 2.0 sandbag Linux - Software 5 05-06-2005 12:12 PM


All times are GMT -5. The time now is 02:48 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration