0

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.

milintime
  • 119
  • There are 3 partitions in you drive /dev/sdb. Why do you want to create new partitions? What kind of partitions do you want? Anyway, it is must easier to use gparted (which has an intuitive graphical user interface), and first create a fresh partition table and then create partitions and file systems. -- What you tried was to unmount the 'whole drive' or more precisely, the drive head, which does not contain any file system. Instead you should unmount the partitions /dev/sdb1 and dev/sdb3. Do not put a file system into the head of the drive, that's old floppy disk style. – sudodus Jun 22 '22 at 11:56
  • 1
    All of the /dev/sdb* partitions MUST be unmounted (with umount) before you can change partitions on /dev/sdb. For command line partition manipulation use parted. Read man parted, and be very, very careful to avoid typos. – waltinator Jun 22 '22 at 15:20

0 Answers0