how to formate usb-sticks
Tags: webdev, usb, linux
Published: 2023-02-20 10:48:01


i want to make sure how to formate usb-sticks on Ubuntu-.  on the command-line and not with gui-tools
so i thought it would be the best to write down my idea. Well its so: writing down the things helps me to make sure that i can discuss all the ideas and plans with others - this helps me alot
so i loe to hear from you  - do you think that the written down procedures are all right - an i do so!?

to begin with the beginning:
To show the USB drive among all storage partitions and volumes on your computer use:

lsblk
we can also use:
df
Suppose it may be /dev/sdy1. Unmount it with:

sudo umount /dev/sdy1
sTo format drive with the FAT32 file system format:
udo mkfs.vfat -F 32 /dev/sdy1

To set a file system label for our pen drive in the process:

sudo mkfs.vfat -F 32 -n 'name_for_our_pendrive' /dev/sdy1
well that said i think we must include the -F 32 part to specify the FAT size, it is not 32 by default in ubuntu 19.10. For more info see man mkfs.fat.h-drive

well i wanna do this the Command-Line way.
I dont wanna formate the  device from the GUI, i will go the Command lie way and do this way.
first of all-  i Open the Terminal (Ctrl+Alt+T)
then i list my block storage devices by issuing the command lsblk
afterwards i identify my pen drive by it's SIZE. In my case its /dev/sdb

see like so:
charles@NS010: $ lsbkk
#NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 232.9G  0 disk
├─sda1   8:1    0    10G  0 part /
├─sda2   8:2    0 208.1G  0 part /home/han/daten
└─sda3   8:3    0  14.8G  0 part
sdb      8:17   1  1.8G  0 disk
└─sdb1   8:17   1  1.8G  0 part  /media/charles/data
sr0     11:0    1  1024M  0 rom

then i do the following: i erase everything in the pen drive (well my friends say that this step is also optional):
then i do the following

sudo dd status=progress if=/dev/zero of=/dev/sdb bs=4k && sync

and then i continue
Replace /dev/sdb with our corresponding device.
well its ptretty important that we type very carefully this name or we may end up erasing one of our other disks. This will take some time. (option status=progress is not mandatory but provide ou some feedback)
It will pretend to be stuck. Just be patient.
for example:

dd if=/dev/zero of=/dev/sdb bs=4k && sync
dd: error writing '/dev/sdb': No space left on device

3984257+0 records in
3984256+0 records out
9127512576 bytes (8.1 GB) copied, 1236.37 s, 6.6 MB/s

now we are going to make a new partition table in the device:
sudo fdisk /dev/sdb
Then here we ress letter o to create a new empty DOS partition table.

and now i am ready  to make a new partition:

doing so i first:
press letter n to add a new partition. then i will be prompted for the size of the partition.
Making a primary partition when prompted, if i am  not very sure.
Then i press letter w to write table to disk and exit.

Format the  new partition.
so my new partition label with the command lsblk

well - in my case it is /dev/sdb1.
Once again at this point we have to pay attention to this name as there will
not be any protection to prevent we to erase an other disk.

charles@NS010: $ lsbkk
#NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 232.9G  0 disk
├─sda1   8:1    0    10G  0 part /
├─sda2   8:2    0 208.1G  0 part /home/han/daten
└─sda3   8:3    0  14.8G  0 part

sdb      8:17   1  1.8G  0 disk
└─sdb1   8:17   1  1.8G  0 part
sr0     11:0    1  1024M 0 rom

charles@NS010: $
well its so : writing down the things helps me to make sure that i can discuss all the ideas and plans with others - this helps me alot

so i loe to hear from you
what do you say!?


**update: **
The** exFAT file system **is just great that limitation. 
the exFAT - well we can call it  another Microsoft format, 
That said - we can tell that it is compatible with macOS and—since kernel 5.4—Linux. 
So we can say - that makes it a strong contender for the best file system for USB drives that need to work with the big three operating systems.
i think that we have to ponder - it doesn’t have the drawbacks of FAT32, but neither does it carry the overheads and extra functionality of the system NTFS.
that said - we have to  say that it is pretty fast too.
As long as we’re on a Linux kernel that is version 5.4 or higher, we ll be able to use exFAT just as easily as we can any of the other supported file systems.