# USB drive not showing up, until fdisk -l /dev/sda

## DingbatCA

This is an embedded gentoo system, so do not assume I have every package installed, or setup correctly.

I have a 60GB disk attached with USB.  Boot the system off of its internal 256MB drive.  Once the system is done booting, I look at all the drives:

```

-bash-3.2# fdisk -l

Disk /dev/hda: 32 MB, 32047104 bytes

4 heads, 32 sectors/track, 489 cylinders

Units = cylinders of 128 * 512 = 65536 bytes

   Device Boot      Start         End      Blocks  Id System

/dev/hda1   *           1         489       31280  83 Linux

-bash-3.2#

```

Nothing on /dev/sda?   The drive is installed and running, but does not show until I direct fdisk to look at it.

```

-bash-3.2# fdisk -l /dev/sda

Disk /dev/sda: 60.0 GB, 60011642880 bytes

64 heads, 32 sectors/track, 57231 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

   Device Boot      Start         End      Blocks  Id System

/dev/sda1               1       57231    58604528  83 Linux

-bash-3.2# 

-bash-3.2# fdisk -l

Disk /dev/hda: 32 MB, 32047104 bytes

4 heads, 32 sectors/track, 489 cylinders

Units = cylinders of 128 * 512 = 65536 bytes

   Device Boot      Start         End      Blocks  Id System

/dev/hda1   *           1         489       31280  83 Linux

Disk /dev/sda: 60.0 GB, 60011642880 bytes

64 heads, 32 sectors/track, 57231 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

   Device Boot      Start         End      Blocks  Id System

/dev/sda1               1       57231    58604528  83 Linux

-bash-3.2# 

```

Here it the dmesg right after boot, and right after the `fdisk -l /dev/sda`

```

[...]

scsi 0:0:0:0: Direct-Access     USB 2.0  Storage Device   0100 PQ: 0 ANSI: 0 CCS

scsi 0:0:0:0: Attached scsi generic sg0 type 0

usb-storage: device scan complete

-bash-3.2# fdisk -l /dev/sda ; dmesg

[...]

scsi 0:0:0:0: Direct-Access     USB 2.0  Storage Device   0100 PQ: 0 ANSI: 0 CCS

scsi 0:0:0:0: Attached scsi generic sg0 type 0

usb-storage: device scan complete

[All new stuff]

sd 0:0:0:0: [sda] 117210240 512-byte hardware sectors (60012 MB)

sd 0:0:0:0: [sda] Write Protect is off

sd 0:0:0:0: [sda] Mode Sense: 08 00 00 00

sd 0:0:0:0: [sda] Assuming drive cache: write through

sd 0:0:0:0: [sda] 117210240 512-byte hardware sectors (60012 MB)

sd 0:0:0:0: [sda] Write Protect is off

sd 0:0:0:0: [sda] Mode Sense: 08 00 00 00

sd 0:0:0:0: [sda] Assuming drive cache: write through

 sda: sda1

sd 0:0:0:0: [sda] Attached SCSI disk

```

What is doing the scan, how do I run a scan by hand, with out knowing the sdX?

ideas?

----------

## eracks

That's very strange.  /dev/sda should have been detected as soon as the machine finished booting successfully.  I assume usb storage support is enabled in the kernel and is not just a module, right (though it shouldn't matter)?

As root, run the command lsusb (before issuing the fdisk -l /dev/sda command) and see if the device shows up.  It could be that for some reason, you need to do something that forces the kernel to probe for USB devices (though, I would assume that the usbstorage driver would do this automatically the first time it's loaded...)

James

----------

## DingbatCA

On a clean boot, with a pen drives and a USB HDD plugged in...  This is just strange.  Take a look.

```

-bash-3.2# lsusb 

Bus 003 Device 001: ID 0000:0000  

Bus 002 Device 001: ID 0000:0000  

Bus 001 Device 001: ID 0000:0000

tail /var/log/messages

May 26 15:44:03 tinytoo user.notice kernel: scsi 0:0:0:0: Direct-Access     USB007   mini-USB2BU      0.00 PQ: 0 ANSI: 2

May 26 15:44:03 tinytoo user.notice kernel: scsi 0:0:0:0: Attached scsi generic sg0 type 0

May 26 15:44:03 tinytoo user.debug kernel: usb-storage: device scan complete

May 26 15:44:03 tinytoo user.notice kernel: scsi 1:0:0:0: Direct-Access     USB 2.0  Storage Device   0100 PQ: 0 ANSI: 0 CCS

May 26 15:44:03 tinytoo user.notice kernel: scsi 1:0:0:0: Attached scsi generic sg1 type 0

May 26 15:44:03 tinytoo user.debug kernel: usb-storage: device scan complete

-bash-3.2# rmmod usb-storage

-bash-3.2# modprobe usb-storage

-bash-3.2# lsusb

Bus 003 Device 001: ID 0000:0000  

Bus 002 Device 001: ID 0000:0000  

Bus 001 Device 001: ID 0000:0000  

-bash-3.2# fdisk -l

Disk /dev/hda: 32 MB, 32047104 bytes

4 heads, 32 sectors/track, 489 cylinders

Units = cylinders of 128 * 512 = 65536 bytes

   Device Boot      Start         End      Blocks  Id System

/dev/hda1   *           1         489       31280  83 Linux

-bash-3.2# 

-bash-3.2# fdisk -l

Disk /dev/hda: 32 MB, 32047104 bytes

4 heads, 32 sectors/track, 489 cylinders

Units = cylinders of 128 * 512 = 65536 bytes

   Device Boot      Start         End      Blocks  Id System

/dev/hda1   *           1         489       31280  83 Linux

-bash-3.2# fdisk -l /dev/sda

Disk /dev/sda: 60.0 GB, 60011642880 bytes

64 heads, 32 sectors/track, 57231 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

   Device Boot      Start         End      Blocks  Id System

/dev/sda1               1       57231    58604528  83 Linux

-bash-3.2# fdisk -l

Disk /dev/hda: 32 MB, 32047104 bytes

4 heads, 32 sectors/track, 489 cylinders

Units = cylinders of 128 * 512 = 65536 bytes

   Device Boot      Start         End      Blocks  Id System

/dev/hda1   *           1         489       31280  83 Linux

Disk /dev/sda: 60.0 GB, 60011642880 bytes

64 heads, 32 sectors/track, 57231 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

   Device Boot      Start         End      Blocks  Id System

/dev/sda1               1       57231    58604528  83 Linux

Disk /dev/sdb: 1031 MB, 1031798272 bytes

255 heads, 63 sectors/track, 125 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks  Id System

/dev/sdb1               1         125     1004031  83 Linux

-bash-3.2# 

-bash-3.2# lsusb

Bus 003 Device 001: ID 0000:0000  

Bus 002 Device 001: ID 0000:0000  

Bus 001 Device 001: ID 0000:0000                  

```

----------

## eracks

Strange, indeed.  With a USB thumb drive plugged into my laptop, as soon as I boot up the machine (usbstorage support is compiled in and not a module) it's detected, and fdisk -l shows it to me, no problem.  What kernel version are you using?  I'm using 2.6.23.1.  If you want, I can send you my kernel .config, and you can diff it against yours to see the differences.

You have a very strange problem on your hands...  :Razz: 

James

----------

## DingbatCA

"This is an embedded gentoo system"  Keep that in mind.  So, it does not have all the normal tools on it.  If you want all the exact details, check out my web site http://www.batbuilds.com/linux/embedded/

Kernel config is just fine.  The same config runs just fine on my non-embedded systems.

I currently think this is a problem with udev, I dont have something setup right.

```

-bash-3.2# uname -a

Linux tinytoo 2.6.23-gentoo-r1 #8 Wed Nov 28 19:31:50 UTC 2007 i586 unknown

```

----------

## eracks

Ah, that makes sense then.  Looking back to my dmesg in more detail, I see that my thumb drive is being detected AFTER the root filesystem is mounted, so it looks as if udev is responsible for making it work.  Let me know if you fix the problem.  I'm curious as to what exactly the problem is.

James

----------

## DingbatCA

That was an easy fix.

modprobe sd_mod

----------

