0

I've an USB key that I want to format, but I can't :

  • format it in command line :

Results:

$ sudo mkfs.ext2 /dev/sdb
mke2fs 1.42.9 (4-Feb-2014)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
mkfs.ext2: Permission denied while trying to determine filesystem size
$ sudo mkfs.ext2 /dev/sdb1
mke2fs 1.42.9 (4-Feb-2014)
Could not stat /dev/sdb1 --- No such file or directory

The device apparently does not exist; did you specify it correctly?
  • create a partition :

Results:

$ sudo fdisk /dev/sdb
fdisk: unable to open /dev/sdb: No medium found
  • see it in GParted or in USB Stick Formatter

  • see a the partition with ls -l /dev/sd*

Results:

$ ls -l /dev/sd*
brw-rw---- 1 root disk 8,  0 Jan  4 14:43 /dev/sda
brw-rw---- 1 root disk 8,  1 Jan  4 12:07 /dev/sda1
brw-rw---- 1 root disk 8,  2 Jan  4 14:43 /dev/sda2
brw-rw---- 1 root disk 8,  5 Jan  4 11:22 /dev/sda5
brw-rw---- 1 root disk 8, 16 Jan  4 12:30 /dev/sdb
  • read from it

Results:

$ sudo dd if=/dev/sdb of=/tmp/xxx bs=512 count=1
dd: failed to open ‘/dev/sdb’: No medium found
$ sudo dmesg | tail
[22002.140008] usb 2-1.4: new high-speed USB device number 12 using ehci-pci
[22002.238743] usb 2-1.4: New USB device found, idVendor=090c, idProduct=3000
[22002.238748] usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[22002.238750] usb 2-1.4: Product: SM3252A MEMORY BAR  
[22002.238752] usb 2-1.4: Manufacturer: Silicon Motion,Inc. 
[22002.239190] usb-storage 2-1.4:1.0: USB Mass Storage device detected
[22002.239430] scsi37 : usb-storage 2-1.4:1.0
[22003.238585] scsi 37:0:0:0: Direct-Access              USB MEMORY BAR   1000 PQ: 0 ANSI: 0 CCS
[22003.241074] sd 37:0:0:0: Attached scsi generic sg2 type 0
[22003.246714] sd 37:0:0:0: [sdb] Attached SCSI removable disk
  • find it using fdisk :

Results:

$ sudo fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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
Disk identifier: 0x2aa8f047

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   362375167   181186560    7  HPFS/NTFS/exFAT
/dev/sda2       362378205   823732874   230677335    f  W95 Ext'd (LBA)
Partition 2 does not start on physical sector boundary.
/dev/sda5       362378268   823732874   230677303+   7  HPFS/NTFS/exFAT
Partition 5 does not start on physical sector boundary.

fdisk -l /dev/sdb

$ sudo fdisk -l /dev/sdb
Cannot open /dev/sdb
  • see it with sudo cat /proc/partitions

Results :

$ sudo cat /proc/partitions
major minor  #blocks  name

   7        0    1548652 loop0
   8        0  488386584 sda
   8        1  181186560 sda1
   8        2          1 sda2
   8        5  230677303 sda5
  11        0    1593088 sr0
  • find any errors with dmesg | tail :

Results:

$ sudo dmesg | tail
[ 5519.189351] usb 2-1.4: new high-speed USB device number 10 using ehci-pci
[ 5519.288491] usb 2-1.4: New USB device found, idVendor=090c, idProduct=3000
[ 5519.288498] usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 5519.288502] usb 2-1.4: Product: SM3252A MEMORY BAR  
[ 5519.288505] usb 2-1.4: Manufacturer: Silicon Motion,Inc. 
[ 5519.289008] usb-storage 2-1.4:1.0: USB Mass Storage device detected
[ 5519.289150] scsi35 : usb-storage 2-1.4:1.0
[ 5520.292225] scsi 35:0:0:0: Direct-Access              USB MEMORY BAR   1000 PQ: 0 ANSI: 0 CCS
[ 5520.292771] sd 35:0:0:0: Attached scsi generic sg2 type 0
[ 5520.294124] sd 35:0:0:0: [sdb] Attached SCSI removable disk

And yet I see all the proper information (Manufacturer, ...) about it.

Any suggestions?

2

For fdisk and mkfs you need to use sudo. Also if you need to format, you first need to create partitions. For doing that, the stick can not be mounted.

  • Maybe it's easiest for you to use a GUI:

gksudo gparted

  • command line

    • find /dev/sdX for your stick

      sudo fdisk -l

    • empty the stick

      sudo dd if=/dev/zero of=/dev/sdX bs=4k && sync

    • create primary partition

      sudo fdisk /dev/sdX

      then press n - primary - w

    • format the partition

      sudo mkfs.vfat /dev/sdX1

| improve this answer | |
  • 1
    Thx but I still get No medium found when trying to refer to my USB with /dev/sdb... So I can't empty it with the command you proposed... :'( – R3uK Jan 4 '17 at 16:40
  • this didn't work for me either but Disks let me format the drive – Michael Schock Feb 18 '19 at 20:53
1

First, you should probably run your commands as root, as that might be part of the problem. (See your permission denied errors?)

I notice

/dev/sdb is entire device, not just one partition!

which means your device is detected, but it has no logical partitions.

fdisk only shows partitions. You should really be using parted

root@hostname~# parted
(parted) print all

this will show all storage devices and not just the ones with partitions.

To create a partition on the device, you can use gparted or you can use parted in the command line if you have no desktop environment.

make sure your device is unmounted

root@hostname~# umount /dev/sdb

start parted

root@hostname~# parted

list devices

(parted) print all

select your device

(parted) select /dev/sdb

make a new partition

(parted) mkpart

it will come up and ask for different things. To ensure compatibility with all systems, and not just Linux, I recommend setting your partition-type to fat32 instead of ext.

Once you make a new partition, you can exit parted

(parted) q

then you can mount your new partition

root@hostname~# mount /dev/sdb1 /mnt/

hope this helps!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.