How to format USB device from terminal

USB-Linux

Hello, what a good day dear readers, this time lI will show how to format our USB devices from the terminal without the assistance of a program, although some may think that it is easier with the help of a tool, it is good to know how to do it from the terminal.

On several occasions I have seen myself in the need of having to change the format of some USB device in which I always turn to Gparted for it, although I can tell you that on certain occasions Gparted throws me errors and it is a headache.

That is why I resort to the use of the terminal for this work, to format a USB.

To begin lor first we will have to do is identify in which mount point we have our USB, for this we will have to open the terminal and run the following command:

sudo fdisk -l 

With it, it will display the information about the partitions and what mount points it has, it displays something like this:

Device     Boot      Start        End    Sectors   Size Id Type
/dev/sdb1             2048 1213757439 1213755392 578.8G  7 HPFS/NTFS/exFAT

/dev/sdb2       1213757440 1520955391  307197952 146.5G  7 HPFS/NTFS/exFAT

/dev/sdb3  *    1520957440 1953519939  432562500 206.3G 83 Linux

Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1        2048 312580095 312578048 149.1G  7 HPFS/NTFS/exFAT

Device     Boot  Start       End   Sectors   Size Id Type
/dev/sdc       64 25748 7.4G  7 HPFS/NTFS/exFAT

Here my USB device is 8Gb so the mount point is / dev / sdc, now we only have to define in which file system we will format our USB, by typing mkfs and with the tab key it will display the formatting options.

mkfs           mkfs.exfat     mkfs.f2fs      mkfs.msdos     mkfs.xfs

mkfs.bfs       mkfs.ext2      mkfs.fat       mkfs.ntfs      

mkfs.btrfs     mkfs.ext3      mkfs.jfs       mkfs.reiserfs  

mkfs.cramfs    mkfs.ext4      mkfs.minix     mkfs.vfat   

In my case, I am interested in formatting it in Fat32, so the command would look like this:

sudo mkfs.vfat -F 32 /dev/sdc -I

It is composed in this way:

mkfs.vfat, is the FAT format -F32, the FAT32 format type /giant/ndc, the path of the USB device -I, so that mkfs allows us to create a file system on the USB device

To know the information about the types of format we just have to write the one we choose and give a tab so that the terminal displays the options with your information.

If you know of any other alternative, do not hesitate to share it with us.


Leave a Comment

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

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  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.

  1.   Lorenzo said

    My problem is that he always tells me the same thing.

    Disk / dev / sdc: 30 GiB, 32212254720 bytes, 62914560 sectors
    Units: 1 * 512 sectors = 512 bytes
    Sector size (logical / physical): 512 bytes / 512 bytes
    I / O size (minimum / optimal): 512 bytes / 512 bytes
    Disc Label Type: Two
    Disk ID: 0x8f9bd31b
    Device Start Start End Sectors Size Id Type
    / dev / sdc1 * 2048 526335 524288 256M c W95 FAT32 (LBA)
    / dev / sdc2 526336 62890625 62364290 29,8G 83 Linux

    loren @ loren-B85M-D3H: ~ $ sudo mkfs.ntfs / dev / sdc -I
    Could not open / dev / sdc: Read-only file system
    loren @ loren-B85M-D3H: ~ $
    loren @ loren-B85M-D3H: ~ $
    loren @ loren-B85M-D3H: ~ $ sudo umount -f / dev / sdc
    umount: / dev / sdc: not mounted.
    loren @ loren-B85M-D3H: ~ $ sudo mkfs.ntfs / dev / sdc -I
    Could not open / dev / sdc: Read-only file system