I want to format a usb using the command line, I am aware of the existence of gparted but I want to learn to do it using the command-line.
I found this question that has covers the issue that I was experiencing.
I run the lsblk command in order to ident the removable media that I want to format.
lblk output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465,8G 0 disk
├─sda1 8:1 0 300M 0 part /boot/efi
└─sda2 8:2 0 465,5G 0 part /
sdb 8:16 1 116,2G 0 disk
├─sdb1 8:17 1 3,2G 0 part /media/x/Ubuntu 20.04.4 LTS amd6
├─sdb2 8:18 1 3,9M 0 part
└─sdb3 8:19 1 113,1G 0 part /media/x/writable
sr0 11:0 1 1024M 0 rom
I run umount /dev/sdb and get:
umount: /dev/sdb: not mounted.
Then:
x@x:~$ sudo mkfs.vfat -I /dev/sdb
mkfs.fat 4.1 (2017-01-24)
mkfs.vfat: unable to open /dev/sdb: Device or resource busy
I think that the issue is that it hasn't been unmounted properly. Maybe because sdb has like sub "sdb" partitions and the commands hasn't unmounted them so the removable media (usb) is still active.