1

Disclaimer: I initially posted this on SF : https://serverfault.com/q/645670, but I think it better fits here

First, a word of context: I'm trying to burn an ISO on a 16 Gb USB key, but I'm having difficulties properly setting up a basic MBR + mountable partition.

So far I collected the following non-matching informations :

  • /dev/sdb* expands to /dev/sdb & /dev/sdb2 : this seems to indicates one partitition with index 2. If I mount /dev/sdb2, df tells me it's a 2.0M VFAT filesystem.

  • fdisk & parted both detect a /dev/sdb device with 3929750 * 512 bytes sectors = 2 Gb capacity. They also both list one unique /dev/sdb1 child partition of 2 Gb.

  • dmesg correctly (?) detects a Kingston 16 Gb USB key

Invoking partprobe doesn't make any difference.

Why is the /dev/sdb2 partition detected by the OS but not by fdisk & parted ?

And secondarily : where does dmesg "16 Gb capacity" piece of information comes from ?


Some command output details :

$ uname -a
Linux DAEDALUS 3.13.0-39-generic #66-Ubuntu SMP Tue Oct 28 13:30:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

$ usb-devices | grep -A7 Bus=03
T:  Bus=03 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 2
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev=03.13
S:  Manufacturer=Linux 3.13.0-39-generic xhci_hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:04:00.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

$ ls -l /dev/sdb*
-rw-r--r-- 1 root root 2012049408 Nov 20 01:50 /dev/sdb
-rw-r--r-- 1 root root    2097152 Nov 20 01:18 /dev/sdb2

$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 2012 MB, 2012049408 bytes
158 heads, 33 sectors/track, 753 cylinders, total 3929784 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3262a45b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048     3929783     1963868   83  Linux

$ sudo parted /dev/sdb unit s print
Model:  (file)
Disk /dev/sdb: 3929784s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End       Size      File system  Name              Flags
 1      2048s  3929750s  3927703s               Linux filesystem  boot

$ sudo fdisk -l /dev/sdb2
You must set cylinders.
You can do this from the extra functions menu.

Disk /dev/sdb2: 2 MB, 2097152 bytes
255 heads, 63 sectors/track, 0 cylinders, total 4096 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System

$ sudo parted /dev/sdb2 unit s print
Model:  (file)
Disk /dev/sdb2: 4096s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End  Size  Type  File system  Flags

Extract of dmesg pertinent output, showing it correctly detects the 16 Gb capacity :

[Thu Nov 20 01:38:46 2014] usb-storage 2-1.2:1.0: USB Mass Storage device detected
[Thu Nov 20 01:38:46 2014] scsi22 : usb-storage 2-1.2:1.0
[Thu Nov 20 01:38:48 2014] scsi 22:0:0:0: Direct-Access     Kingston DataTraveler G2  PMAP PQ: 0 ANSI: 0 CCS
[Thu Nov 20 01:38:48 2014] sd 22:0:0:0: Attached scsi generic sg2 type 0
[Thu Nov 20 01:38:49 2014] sd 22:0:0:0: [sdb] 31252480 512-byte logical blocks: (16.0 GB/14.9 GiB)
[Thu Nov 20 01:38:49 2014] sd 22:0:0:0: [sdb] Write Protect is off
[Thu Nov 20 01:38:49 2014] sd 22:0:0:0: [sdb] Mode Sense: 23 00 00 00
[Thu Nov 20 01:38:49 2014] sd 22:0:0:0: [sdb] No Caching mode page found
[Thu Nov 20 01:38:49 2014] sd 22:0:0:0: [sdb] Assuming drive cache: write through
  • That's a strange one. If your machine has both USB3 and USB2 ports, do you see the same things on both? Can you try the stick in another machine (not necessarily one running Linux)? – Gilles Nov 20 '14 at 23:25
  • 1
    Looking at your output, /dev/sdb and /dev/sdb2 are ordinary files, not references to a storage device. Is that intentional? – Mark Plotnick Nov 20 '14 at 23:54
  • It's possible someone did mv image.iso /dev/sdb instead of using cp or dd and unintentionally replaced the device node. – Mark Plotnick Nov 23 '14 at 2:18
  • @MarkPlotnick: What tells you they are ordinary files ? But no, it wasn't an erroneous mv. I wanted to try @Gilles suggestion, but when I plugged the stick back today, it has been correctly detected as a 16Gb device ! Seemingly rebooting my Ubuntu solved the issue. – Lucas Cimon Nov 24 '14 at 21:56
  • @LucasCimon The ls -l output showed -rw-r--r--. Since the first character is a -, that indicates an ordinary file. It would be b for a block device such as a disk or solid-state drive. Ordinary files can be copied into /dev. Maybe someone used mv, or removed the device files (possibly by unplugging the drive) and then copied ordinary files to those paths. Rebooting fixes this, as you've seen; you could also rm the /dev/sdb and /dev/sdb2 files (first saving the contents somewhere if they were important), then unplug and plug in the USB drive. – Mark Plotnick Nov 25 '14 at 2:52

Your Answer

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

Browse other questions tagged or ask your own question.