22

I'm a total newbie in Linux specially Ubuntu, I'm just asking on how to format a USB using Ubuntu terminal. Hope you can help me thanks!

warrior
  • 221
  • It is not that easy for a niewbie. Why do not use GUI tools? – Pilot6 Aug 18 '15 at 13:14
  • 1
    If you make a mistake, you can format your HDD. There will be no warning. – Pilot6 Aug 18 '15 at 13:24
  • This question is NOT a duplicate (at least not the one marked). That one asks for a GUI, and this one for a command line solution... – Calimo Aug 19 '15 at 10:06
  • @Calimo The other question has been broadened to include command-line solution, just the wording was never removed. – Seth Aug 20 '15 at 01:33

1 Answers1

34
  • First, you have to find out which device (/dev/sd??) your USB stick is. Therefore look at the output of

    sudo fdisk -l
    
  • After that unmount the device/partition (if necessary) by running

    sudo umount /dev/sd??
    

    Make sure you replaced ?? with the correct device/partition name from the previous output.

  • To format The partition as FAT32 use

    sudo mkdosfs -F 32 -I /dev/sd??
    

    Again replace ?? with your respective letters.

Be careful that if you enter the wrong device name, you might also accidentally format your hard disk!

You can also do

    sudo -s

and you don't have to put "sudo" in front of everything!

L. Barzic
  • 459
  • 1
    Hi, after doing this I get a: Error while copying to XXXXX The destination is read-only. any clue? – vabada Sep 09 '16 at 06:17
  • sudo chmod 777 /dev/sd?? – madzohan Mar 25 '17 at 16:54
  • Have a SCRIPT for the whole shebang would be nice (with some sanity checks, that it's a a) USB b) removable device c) no larger than 32 GB d) unrelated to the usual pack like /, /boot, etc. as an extra precaution) – Frank N Sep 16 '17 at 12:27
  • If you want to name the volume while formatting, add -n YOUR-NAME to the mkdosfs command. – Zoltán Sep 14 '18 at 14:34
  • I know it's been 4 years but @vabada you probably messed with the usb too much and it's broken – Nitwit May 13 '20 at 11:57