With the terminal: Format a USB memory

When we don't have a graphical tool like GParted or the option to format memories as in Gnome, we can use a command that actually does the same thing as the two tools mentioned above.

The first thing we have to do is make sure we have the package installed dosfstools.

$ sudo aptitude install dosfstools

Once installed, we will check where our flash memory is located. We can use the command:

$ sudo fdisk -l

Which will return something like this:

The line that interests us is the one that says:

/dev/sdc1  *      62       7983863     3991901   b  W95 FAT32

Once we know which device to format is, we use the command:

sudo mkfs.vfat -F 32 -n Mi_Memoria /dev/sdc1

With option -F32 we tell you that it will be formatted as fat32, and with the option -n We put a label or name to the device.

Simple right?

Edito: I forgot to say that to execute this operation, the device has to be unmounted.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

      KZKG ^ Gaara <"Linux said

    mmm I do it in another way:
    mkdosfs ("-n", "MI-PENDRIVE", "-v", "/dev/sdb1")

    -n let me name or label the USB device.
    -v it will indicate which device is the one to be formatted.

         moa said

      You have to run it without quotes and parentheses I imagine

      Oscar said

    I found on the net this link from where you can get the deb package to install, I tried it and it works very well.

    https://sites.google.com/site/kubuntufacil/formatear-memorias-usb-en-kubuntu

    I hope it is useful for you.

         KZKG ^ Gaara <"Linux said

      Because we are in Cuba, we do not have access to Google sites or code.google or anything like that, if you can download the soft and send it to kzkggaara@myopera.com 😀

           Neo61 said

        KZKG ^ Gaara, friend, one question, how could I rename a device without formatting? You are looking at the command string and I thought about that.

           BlackHack said

        Have you tried tor….?

      Oscar said

    I already sent it to you by Gmail, let me know if you do not receive it to send it by another mail.

         KZKG ^ Gaara <"Linux said

      Yep it came to me, and I answered you with a question 😉
      Thanks really friend 😀

      CubaRed said

    The documentation that we can have here is very good ...

         elav <° Linux said

      Thanks for the comment CubaRed. A pleasure to have you here.

      regards

         KZKG ^ Gaara <"Linux said

      Thanks for the comment and welcome to the site 😉

      elynx said

    I'm running from Slax Linux (Live CD of course: P) and use the following command:

    mkfs -T -F32 / dev / sda

    / dev = mount point
    / sda = drive or removable media

    Regards!

      Sun said

    Genie, you saved my life.

      wayne7 said

    Years go by and I keep checking the post xD.
    Good tuto elav.
    Regards!

         elav said

      Hahaha thanks

      Ramon said

    Well, nothing, there is no way, neither by gparted nor in console with your option: it answers me:

    mkfs.vfat: unable to open / dev / sdg1: Read-only file system

         HELLO CRAZY said

      You have to have the dosfstools package installed, to be able to format in the terminal, as if you are in a Gnome environment you can use the Disks utility is very easy.

      genuine-usb said

    I thought it was a little more complicated, with the tutor it has become easier.

      yamil said

    Thanks, after searching in several places, I was able to repair it with this info, I put the command sudo mkfs.vfat -F 32 -n My_Memory / dev / sdx then I opened gparted and formatted it to fat32, and now it works great, everything is dung had happened to take the pen to a printing with windous. I hope I don't make that mistake again.
    Greetings, good blog.

      Claudi said

    Friend Elav and Linux users,

    Thank you ! It has been 2 years since you wrote this and in each site they say something different, most do not work, are inaccurate or steps are missing. It would be nice if the correct solutions like this appear somewhere so you don't go crazy trying things that don't work. I take note of this blog. Cheers

      gabux22 said

    The truth is that I did the steps that elav shows us, today, and I revived my 16GB pendrive ... thanks elav, your knowledge is very timely ... 🙂

      Miguel said

    Brother I love you. Thank you very well explained

      Rene Izarra Izarra said

    In the command:

    mkfs.vfat -F 32 -n My_Memory / dev / sdc1

    need to use "-I" so that it can overwrite the usb partition.

      hidden said

    I found another option that is also very well explained in http://wp.me/p2mNJ6-3I

      Rodrigooo said

    How great!
    This tutorial saved me in an important way !!!

      eduardo said

    Someone knows how to make a bottable usb with a linux iso image of more than 4 Gb since for Fat 32 this image is no longer possible, someone could guide me how to prepare the usb, greetings and thanks

      ferreyrawm said

    check unetbootin or clonezilla

      Isaac said

    Hello, look, I have a USB that I cannot format, since it is with write-only permission, I already tried with gparted and nothing, I would recommend some software, the memory recognizes it, I can see what is in the memory, I can copy from memory to pc, but not from pc to memory since I get that the destination is read-only, please. If you have the knowledge, give me a hand. cheers ...

         Ignacio said

      I also have the same problem, apparently some malware on another computer changed the memory to read-only and the content cannot be erased or even formatted or with linux not with windows, I followed several tutorials with console commands that supposedly solve it and nothing , nothing can be done with the memory, does anyone know how to recover the use of the usb memory with this problem?

         eastlondon said

      Hello Isaac!
      Sometimes that has happened to me. It has worked for me, with gparted, to use the option to "destroy" (not just delete it) the partition and then create a new partition table. Sometimes I have to remove and reconnect the memory so that I can create the new table.
      I hope you serve.

      chacho said

    The problem is that this formats in b W95 FAT32 but with my old windows XP it does not read the pendrives, I have to format them in another way with the format c W95 FAT32 (LBA)

      Javier said

    None of these instructions helped me, I don't know where the problem is.

      Hector said

    thanks, I always consult it

      Anonymous said

    Hi. If you can help me to format the machine please

      Richard said

    You need to unmount the usb drive with the umount command to be able to format

      sergio. 59 said

    Hello I have a USB that the system does not recognize, I send you the information if you can help me thanks

    dmesg

    [83384.348839] USB 1-1: New High-Speed ​​USB Device Number 8 Using EHCI-PCI
    [83384.506219] usb 1-1: New USB device found, idVendor = 0c76, idProduct = 0005, bcdDevice = 1.00
    [83384.506225] usb 1-1: New USB device strings: Mfr = 1, Product = 2, SerialNumber = 0
    [83384.506228] usb 1-1: Product: USB Mass Storage
    [83384.506231] usb 1-1: Manufacturer: GENERIC
    [83384.506848] usb-storage 1-1: 1.0: USB Mass Storage device detected
    [83384.508235] scsi host5: usb-storage 1-1: 1.0
    [83385.524951] scsi 5: 0: 0: 0: Direct-Access GENERIC USB Mass Storage 1.00 PQ: 0 ANSI: 2
    [83385.556757] sd 5: 0: 0: 0: Attached scsi generic sg3 type 0
    [83385.561706] sd 5: 0: 0: 0: [sdc] Attached SCSI removable disk

    root @ localhost: ~ # fdisk -l
    Disk / dev / sda: 698.7 GiB, 750156374016 bytes, 1465149168 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical / physical): 512 bytes / 4096 bytes
    I / O size (minimum / optimal): 4096 bytes / 4096 bytes
    Disklabel type: gpt
    Disk identifier: 995F9474-C5F1-4EE9-8FD7-13EA790423DC

    Device Start End Sectors Size Type
    / dev / sda1 2048 1050623 1048576 512M EFI System
    / dev / sda2 1050624 49879039 48828416 23.3G Linux filesystem
    / dev / sda3 49879040 69410815 19531776 9.3G Linux filesystem
    / dev / sda4 69410816 76107775 6696960 3.2G Linux swap
    / dev / sda5 76107776 80013311 3905536 1.9G Linux filesystem
    / dev / sda6 80013312 1465147391 1385134080 660.5G Linux filesystem

    root @ localhost: ~ # fdisk -l / dev / sdc
    fdisk: cannot open / dev / sdc: No medium found

    root @ localhost: ~ # hdparm / dev / sdc

    / dev / sdc:
    SG_IO: bad / missing sense data, sb []: f0 00 02 00 00 00 00 0b 00 00 00 00 3a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    multicount = 0 (off)
    readonly = 0 (off)
    readahead = 256 (on)

    root @ localhost: ~ # hdparm -C / dev / sdc

    / dev / sdc:
    drive state is: standby

    root @ localhost: ~ # hdparm -I / dev / sdc

    / dev / sdc:
    SG_IO: bad / missing sense data, sb []: f0 00 02 00 00 00 00 0b 00 00 00 00 3a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

    ATA device, with non-removable media
    Standards:
    Likely used: 1
    Configuration:
    logical max current
    cylinder 0 0
    heads 0 0
    sectors / track 0 0

    Logical / Physical Sector size: 512 bytes
    device size with M = 1024 * 1024: 0 MBytes
    device size with M = 1000 * 1000: 0 MBytes
    cache / buffer size = unknown
    capabilities:
    IORDY not likely
    Cannot perform double-word IO
    R / W multiple sector transfer: not supported
    DMA: not supported
    IOP: pio0