How can I format my USB drive? Are there tools to format it or do I have to manually delete all files on my USB drive?
You can use Gnome Disk Utility. It is avaliable on the Software Centre and you can install it by:
searching the Software Centre for "Disks"
This command:
sudo apt-get install gnome-disk-utility
It looks like this:
Click the Stop button, to unmount the disk. Then there will be either a + or - button.
Remove the partitions untill you are left with "Free Space".
Add a partition, with the + button. You have to select the free space to do this.
When it is completed, you can click the play button to mount it again.
-
Why delete the partition, instead of just format it as the question asks? - By just clicking the gears button: 'Format' – user170 Jul 5 '15 at 11:35
-
1@cipricus in case there are multiple partitions. – user3 Jul 5 '15 at 11:37
-
The Ubuntu tool to write images to USBs (
usb-creator-gtk
) had a format option too. But I cannot install it on my system now. (I have an odd broken packages signal with respect to thisusb-creator-gtk
) – user170 Jul 5 '15 at 11:42
You can use GParted
Install it by entering the following command in the terminal:
sudo apt-get install gparted
Here is a tutorial for formatting your USB flash drive :
How to Format a USB Drive in Ubuntu Using GParted
Start Gparted.
Select the USB drive from the top write drop-down menu.
Right click the drive and select format, then check Apply
-
1When you have a live Linux USB, you may get errors when trying to format with Gparted. – user170 Jul 5 '15 at 12:47
Because sometimes erasing a drive can be tricky (see the cases mentioned below) I would recommend having different tools at hand for that purpose. Therefore, the following should be seen as a complement to the other answer(s).
Mintstick
My favorite is the USB Stick Formatter and the Image Writer from Linux Mint.
It's Mint's alternative to Ubuntu Unity default Startup Disk Creator (see below) - only that the formatting tool is run as a separate GUI.
sudo add-apt-repository ppa:tsvetko.tsvetkov/trusty-backports
sudo apt-get update
sudo apt-get install mintstick
The deb files can be found HERE.
This is a very powerful tool. When you have a live Linux system on an USB key it may be difficult to simply erase that drive. Sometimes, when even Gparted was unable to fix, re-create partition tables and format (see last part of this answer), this little tool was able to format it.
Startup Disk Creator
sudo apt-get install usb-creator-gtk
It is made for writing images to USB sticks but it has an erase option.
Emergency solution (Troubleshooting)
In some cases (like the one aforementioned, involving a Linux system on USB) you may get errors when trying to format with Gparted.
- If the USB key can be mounted but you get all kind of errors in Gparted, like so:
then, try other tools, like the ones mentioned under this question, especially Disks (gnome-disk-utility
) and USB Stick Formatter (mintstick
).
As far as I can tell, in many cases when Gparted will not work, Mintstick and Gnome Disk Utility (Disks) will.
- If the USB stick cannot be mounted anymore:
In this case, delete the partition in Gparted and create a new one.
When the USB stick cannot be mounted by the system, Gparted would still access it, delete and create partitions.
Gnome Disk Utility can access it too while not mounted and you may try delete or format the partition, but that may just get an error:
If none of the above works (whether the USB can be mounted or not), the
dd
tool can be used to wipe out all errors by filling the USB drive with zeros :- Open the terminal and check the path of the USB device with
lsblk
(in this case would besdb
):
- Open the terminal and check the path of the USB device with
- The next command wipes the entire disk, not only the partition table.
sudo dd if=/dev/zero of=/dev/sdb bs=1M
- That takes some tyme, so you might like to see the progress of the process.
Open a new Terminal window/tab and do
watch -n5 'sudo kill -USR1 `pgrep ^dd`'
then go back to the initial window/tab to see the progress
That will wipe the USB drive completely. You will need to use gparted
to create a new partition table and a new partition (Device > Create Partition Table; Partition > New).
The easiest way to format an USB stick on elementary (for now) is to install "Formatter" app from elementary appstore.