Verify a External USB Hard Drive On a CentOS Linux Computer

Recently I had a hard drive crash that was in a Windows XP laptop. The drive would  not mount under Windows however I was able to eventually mount it under Linux and rescue some of the data. In this article I will describe how to verify the USB hard drive enclosure is seen on a CentOS Linux computer and verify that Linux is able to see the USB device and the drive.

First you will want to remove the hard drive from your Windows XP computer and physically mount it into the USB hard drive enclosure. This will involve connecting it inside (IDE or SATA) and then plugging the USB cable or cables into the CentOS server. Since the hard drive is damaged its hard to know if its not reading it or if you have something misconfigured, a loose cable, etc. Below are a couple tips to make sure that the hard drive is being recognized via the USB connection.

A tool that should be installed by default that you can use to make sure the USB connections to the hard drive has been recognized is “dmesg”. Issue the below command from the shell on the Linux server after the hard drive is connected via USB.

Command to Locate USB Device:

dmesg | grep -i USB

The output should look something like the below if the drive has been recognized. You want to look for something along the lines of “Mass Storage” as you can see below in the log.

Example dmesg Output:

Initializing USB Mass Storage driver...
scsi0 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 2
usb-storage: waiting for device to settle before scanning
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
usb-storage: device scan complete
usb 2-2: reset full speed USB device using uhci_hcd and address 2
usb 2-2: reset full speed USB device using uhci_hcd and address 2
usb 2-2: reset full speed USB device using uhci_hcd and address 2
usb 2-2: reset full speed USB device using uhci_hcd and address 2

You will also need to find out where the drive is mounted which can also be done with dmesg by using grep to cut out one of the following or a similar combination: sda, hda, sdb, hdb, SCSI, or similar. The below is the example from my dmesg output which shows the USB enclosure mounted at /dev/sda.

Command/Output to Locate USB Device:

[root@hunter /]# dmesg | grep -i SCSI
SCSI subsystem initialized
scsi0 : SCSI emulation for USB Mass Storage devices
Type:   Direct-Access                      ANSI SCSI revision: 00
SCSI device sda: 156301488 512-byte hdwr sectors (80026 MB)
SCSI device sda: 156301488 512-byte hdwr sectors (80026 MB)
sd 0:0:0:0: Attached scsi disk sda
sd 0:0:0:0: Attached scsi generic sg0 type 0

Now if you want to find out information about the partitions on the device you can use fdisk which should also already be installed on the CentOS server. The below section shows the command and example output from the fdisk command.

Example Command/Output to Verify Partitions:

[root@hunter /]# fdisk -l /dev/sda

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1           6       48163+  de  Dell Utility
/dev/sda2   *           7        9728    78091965    7  HPFS/NTFS

Now the drive should be mounted and you can proceed with attempting to recover the data. Below is an example of a drive that is seen by the Linux computer however it is to damaged to be mounted.

Example Command/Output for Damaged Hard Drive Error Messages:

[root@hunter /]# dmesg | grep -i SCSI | more
SCSI subsystem initialized
scsi 0:0:0:0: rejecting I/O to dead device
scsi 0:0:0:0: rejecting I/O to dead device
scsi 0:0:0:0: rejecting I/O to dead device
scsi 0:0:0:0: rejecting I/O to dead device
scsi 0:0:0:0: rejecting I/O to dead device
scsi 0:0:0:0: rejecting I/O to dead device
scsi 0:0:0:0: rejecting I/O to dead device
scsi 0:0:0:0: rejecting I/O to dead device
scsi 0:0:0:0: rejecting I/O to dead device
scsi 0:0:0:0: rejecting I/O to dead device

The longer the device is connected to the CentOS server the more rejecting I/O to dead device messages that will appear. I wanted to include the error messages I noticed with another hard drive in case your drive is in really bad shape you are not trying to find out why you cannot see it all night long.

Below are a couple USB laptop hard drive enclosures from Amazon in case you don’t already have one. It will make your life much easier when attempting to recover data. There is one for 2.5″ SATA drives and one for 2.5″ IDE/PATA drives. Some laptops have 3.5″ drives while others have 1.8″ drives so make sure to order the correct USB hard drive enclosure.


List Price: $23.38 USD
New From: $14.41 USD In Stock
Used from: Out of Stock


List Price: $46.99 USD
New From: $75.00 USD In Stock
Used from: $15.99 USD In Stock

Share