4

I have an external 80G hard drive, connected with USB. I've used this for multiple things in the past, including running an Ubuntu OS off it (I know, bad idea). In any case, it came unplugged while I was running Ubuntu. Of course, Ubuntu promptly generated errors and I shut down the computer. I plugged it in again and started it up, but my BIOS didn't recognize the hard drive in the devices list. While running off the LiveCD (or another Ubuntu OS, now on the internal hard drive), a ls /dev/ | grep sd shows the device (sdc) when it's plugged in and omits it when it's not (so I know that's the correct drive), but gparted doesn't show it in the device list. If I run parted /dev/sdc, parted doesn't start up and there is no error message; if I type select /dev/sdc while already in a parted interactive prompt, I again get no message, and it's still on /dev/sda. The same goes for the Gparted LiveCD.

cat /proc/partitions outputs

major minor  #blocks  name

   8        0  244198584 sda
   8        1     102400 sda1
   8        2  119950336 sda2
   8        3  119950336 sda3
   8        4    4194304 sda4
   8       16    3913728 sdb
   8       17    3913664 sdb1

Does anyone have any suggestions as to what I should do?

EDIT: want to make it clear that I am willing to format the drive if it means I can use it at all again.

EDIT 2: Here's the output from dmesg | tail -25 as suggested by marto:

usb 2-4: new high speed USB device using ehci_hcd and address 8
usb-storage 2-4:1.0: Quirks match for vid 05e3 pid 0702: 520
scsi8 : usb-storage 2-4:1.0
scsi 8:0:0:0: Direct-Access     811 ATA/ ATAPI Device     0014 PQ: 0 ANSI: 0
Attached scsi generic sg3 type 0
sd 8:0:0:0: [sdc] Test WP failed, assume Write Enabled
sd 8:0:0:0: [sdc] Asking for cache data failed
sd 8:0:0:0: [sdc] Assuming drive cache: write through
sd 8:0:0:0: [sdc] Test WP failed, assume Write Enabled
sd 8:0:0:0: [sdc] Asking for cache data failed
sd 8:0:0:0: [sdc] Assuming drive cache: write through
sd 8:0:0:0: [sdc] Attached SCSI disk

Upon disconnecting: usb 2-4: USB disconnect, address 8

5
  • i'm not too hot on usb drives, but i expect that the output from the commands dmesg, lsusb, and an attempt to mount it manually mount /dev/sdc /media/drive, would help you get your answer. Jun 19, 2011 at 13:46
  • 1
    Whoa... dmesg gives me a lot of output (973 lines, 65343 bytes). If you want me to upload it to some site so you can look at it I can, though. lsusb seems to recognize the device (Bus 002 Device 003: ID 03f0:3207 Hewlett-Packard ). sudo mount /dev/sdc /media/drive gives me mount: you must specify the filesystem type. If I use -t vfat, it gives me mount: /dev/sdc: can't read superblock, and -t ext4 gives mount: wrong fs type, bad option, bad superblock on /dev/sdc, missing codepage or helper program, or other error
    – wchargin
    Jun 19, 2011 at 18:25
  • the only dmesg i would think helpful would be what the dmesg says when you plug your drive in, as that's probably where the error stops it mounting is logged. Jun 19, 2011 at 18:58
  • you could open a terminal and put in 'watch "dmesg | tail -10"', then plug in the drive and see what appears on screen! (I cant put it in nice code-format here)
    – marto
    Jun 19, 2011 at 22:28
  • @marto: Thanks, added output to question (too long to put here, and line breaks don't work)
    – wchargin
    Jun 21, 2011 at 16:58

2 Answers 2

1

looking from your attempt at mounting the drive, do you know what the filesystem is? its probably ext4 if you let ubuntu choose when it was formatted/installed.

if its ext4 then, given the scenario surrounding its failure, the problem is probably a bad superblock (i.e. the filesystem became malformed due to incomplete writing, etc.) the following command will identify the extent of the problem and tell you how it can be solved:

sudo fsck.ext4 -v /dev/xxx
6
  • I believe it is ext4. fsck.ext4 -v /dev/sdc gives me "Invalid argument while trying to open /dev/sdc. The superblock could not be read or it does not contain a valid ext2 file system." Why does it say ext2? Also, the other fsck. commands give me errors: fsck.msdos gives Got 0 bytes instead of 512 at 0; fsck.nfs gives /dev/sdc: NFS file system (which I assume is an error because it says it of my main HDD as well); fsck.vfat gives the same as fsck.nfs. Thanks for the help; do you have any other ideas?
    – wchargin
    Jun 21, 2011 at 16:43
  • /dev/sdc is the whole drive. If you partitioned the drive (and that is the most common way to put a filesystem on a drive), your first partition is /dev/sdc1.
    – elmicha
    Jun 21, 2011 at 16:55
  • I did, yes, and that's what I would think too, but there is no device file /dev/sdc1. As shown: fsck.ext4: No such file or directory while trying to open /dev/sdc1. Possibly non-existent device?
    – wchargin
    Jun 21, 2011 at 16:59
  • linuxexpresso.wordpress.com/2010/03/31/… contains a very good guide (which i'd only be copying) on how to restore your superblock. Jun 21, 2011 at 20:23
  • Thanks for the guide; however, this seems to be for a single partition - recall that I don't have a /dev/sdb1, (it was changed from c to b somehow), only /dev/sdb (according to ls /dev/ | grep sd). sudo fdisk -l doesn't list /dev/sdb, and sudo fdisk /dev/sdb gives Unable to read /dev/sdb, while sudo fdisk /dev/sda or .../sdc are ok. On another note, Window$ now recognizes the drive, gets drivers for it, but can't mount it... any other ideas?
    – wchargin
    Jun 21, 2011 at 22:42
1

The drive looks like it was spinning at normal speed while power was supplied to the disk via the USB interface. The spec for most drives is +- 1% of the nominal spin speed is acceptable. The drive lost power while reading and writing so it may have queered your partition table area - the very first 512 bytes of the drive.

So checking /proc/partitions is useful. cat /proc/partitions

dmesg should report the last drive letter being acquired by the kernel eg. b or c or d. Use fdisk -l /dev/sdX where X is a b or c or d. If it reports a problem you can probably re-create the partition table using parted gparted or fdisk.

The trick is to examine the possible partitions - offset and type

To save your data - you need to run a dd command and copy the complete disk image from /dev/sdX to a file on a much larger disk partition - mounted as /home maybe.

dd if=/dev/sdc of=/home/sdc.dd conv=noerror,sync

It will take a while - maybe a day and most of the night for large Gigabyte drives.

Then you can play with the drive itself - recreate a filesystem etc.

The biggest test that dd will provide is the integrity of the drive while just reading blocks.

Similar to a fsck -t ext3 -c command which should check for bad-blocks on a drive.

If the dd command fails it should provide a bit of info on where on the drive it fought bad sector errors.

If the drive reports errors early on - that may explain the loss of partition info.

I often do a od -cx /dev/sdX | less to check the possible offsets to make things easy some od commands take options for convenience eg. od -cx -Ad /dev/sdX | less

0000000 353   H 220 020 216 320 274  \0 260 270  \0  \0 216 330 216 300
        48eb 1090 d08e 00bc b8b0 0000 d88e c08e
0000016 373 276  \0   | 277  \0 006 271  \0 002 363 244 352   ! 006  \0
        befb 7c00 00bf b906 0200 a4f3 21ea 0006
0000032  \0 276 276  \a   8 004   u  \v 203 306 020 201 376 376  \a   u
        be00 07be 0438 0b75 c683 8110 fefe 7507
0000048 363 353 026 264 002 260 001 273  \0   | 262 200 212   t 003 002
        ebf3 b416 b002 bb01 7c00 80b2 748a 0203
0000064 200  \0  \0 200   E 202  \r  \0  \0  \b 372 220 220 366 302 200
        0080 8000 8245 000d 0800 90fa f690 80c2
0000080   u 002 262 200 352   Y   |  \0  \0   1 300 216 330 216 320 274
        0275 80b2 59ea 007c 3100 8ec0 8ed8 bcd0
0000096  \0     373 240   @   |   < 377   t 002 210 302   R 276 177   }
        2000 a0fb 7c40 ff3c 0274 c288 be52 7d7f
0000112 350   4 001 366 302 200   t   T 264   A 273 252   U 315 023   Z
        34e8 f601 80c2 5474 41b4 aabb cd55 5a13
0000128   R   r   I 201 373   U 252   u   C 240   A   | 204 300   u 005
        7252 8149 55fb 75aa a043 7c41 c084 0575
0000144 203 341 001   t   7   f 213   L 020 276 005   | 306   D 377 001
        e183 7401 6637 4c8b be10 7c05 44c6 01ff
0000160   f 213 036   D   | 307 004 020  \0 307   D 002 001  \0   f 211
        8b66 441e c77c 1004 c700 0244 0001 8966
0000176   \  \b 307   D 006  \0   p   f   1 300 211   D 004   f 211   D
        085c 44c7 0006 6670 c031 4489 6604 4489
0000192  \f 264   B 315 023   r 005 273  \0   p 353   } 264  \b 315 023
        b40c cd42 7213 bb05 7000 7deb 08b4 13cd
0000208   s  \n 366 302 200 017 204 352  \0 351 215  \0 276 005   | 306
        0a73 c2f6 0f80 ea84 e900 008d 05be c67c
0000224   D 377  \0   f   1 300 210 360   @   f 211   D 004   1 322 210
        ff44 6600 c031 f088 6640 4489 3104 88d2
0000240 312 301 342 002 210 350 210 364   @ 211   D  \b   1 300 210 320
        c1ca 02e2 e888 f488 8940 0844 c031 d088
0000256 300 350 002   f 211 004   f 241   D   |   f   1 322   f 367   4
        e8c0 6602 0489 a166 7c44 3166 66d2 34f7
0000272 210   T  \n   f   1 322   f 367   t 004 210   T  \v 211   D  \f
        5488 660a d231 f766 0474 5488 890b 0c44
0000288   ;   D  \b   }   < 212   T  \r 300 342 006 212   L  \n 376 301
        443b 7d08 8a3c 0d54 e2c0 8a06 0a4c c1fe
0000304  \b 321 212   l  \f   Z 212   t  \v 273  \0   p 216 303   1 333
        d108 6c8a 5a0c 748a bb0b 7000 c38e db31
0000320 270 001 002 315 023   r   * 214 303 216 006   H   |   ` 036 271
        01b8 cd02 7213 8c2a 8ec3 4806 607c b91e
0000336  \0 001 216 333   1 366   1 377 374 363 245 037   a 377   &   B
        0100 db8e f631 ff31 f3fc 1fa5 ff61 4226
0000352   | 276 205   } 350   @  \0 353 016 276 212   } 350   8  \0 353
        be7c 7d85 40e8 eb00 be0e 7d8a 38e8 eb00
0000368 006 276 224   } 350   0  \0 276 231   } 350   *  \0 353 376   G
        be06 7d94 30e8 be00 7d99 2ae8 eb00 47fe
0000384   R   U   B      \0   G   e   o   m  \0   H   a   r   d       D
        5552 2042 4700 6f65 006d 6148 6472 4420
0000400   i   s   k  \0   R   e   a   d  \0       E   r   r   o   r  \0
        7369 006b 6552 6461 2000 7245 6f72 0072
0000416 273 001  \0 264 016 315 020 254   <  \0   u 364 303  \0  \0  \0
        01bb b400 cd0e ac10 003c f475 00c3 0000
0000432  \0  \0  \0  \0  \0  \0  \0  \0   S 005  \v  \0  \0  \0 200 001
        0000 0000 0000 0000 0553 000b 0000 0180
0000448 001  \0 203 376   ?   >   ?  \0  \0  \0   @   q 017  \0  \0  \0
        0001 fe83 3e3f 003f 0000 7140 000f 0000
0000464 001   ? 203 376 377 377 177   q 017  \0 276 275   q 022  \0 376
        3f01 fe83 ffff 717f 000f bdbe 1271 fe00
0000480 377 377 202 376 377 377   =   / 201 022 002 336 037  \0  \0  \0
        ffff fe82 ffff 2f3d 1281 de02 001f 0000
0000496  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0   U 252
        0000 0000 0000 0000 0000 0000 0000 aa55
0000512  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
        0000 0000 0000 0000 0000 0000 0000 0000
*
0001024 352 317 202  \0  \0  \0 004  \0 204   >  \0  \0   X   t  \0  \0
        cfea 0082 0000 0004 3e84 0000 7458 0000
0001040  \b   X  \0  \0 001  \0  \0  \0 377 377 377 377   /   b   o   o
        5808 0000 0001 0000 ffff ffff 622f 6f6f
0001056   t   /   g   r   u   b  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
        2f74 7267 6275 0000 0000 0000 0000 0000
0001072  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
        0000 0000 0000 0000 0000 0000 0000 0000
*
0001104  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0 002 260 255 033
        0000 0000 0000 0000 0000 0000 b002 1bad
0001120  \0  \0 001  \0 376   O   Q 344   \ 002 020  \0  \0  \0 020  \0
        0000 0001 4ffe e451 025c 0010 0000 0010
0001136  \0  \0  \0  \0  \0  \0  \0  \0   | 002 020  \0 213   S  \f 275
        0000 0000 0000 0000 027c 0010 538b bd0c
0001152 360 377  \a  \0 211 354 271   L  \b  \0  \0 003  \r 020 002 020
        fff0 0007 ec89 4cb9 0008 0300 100d 1002
0001168  \0 276  \0  \0 020  \0 277  \0 200  \0  \0 374 363 244 270 245
        be00 0000 0010 00bf 0080 fc00 a4f3 a5b8
0001184 202  \0  \0 377 340 211 320 301 350  \b   1 333 200 374 377   t
        0082 ff00 89e0 c1d0 08e8 db31 fc80 74ff
0001200  \b 210 343 211 035 024 202  \0  \0   < 377   t  \b 210 303 211
        8808 89e3 141d 0082 3c00 74ff 8808 89c3

NOTE the * on the left hand side They indicate a lot more null or zero byte values so my offset for a partition appears to be 1024 bytes into the drive. which is 2 x 512 byte sectors or 1 x 1024 byte sectors

Given that most drives will probably look like this

root@rhbeta:/home/chrthomp # fdisk -l /dev/sdX

Disk /dev/sdX: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          63      506016   83  Linux
/dev/sda2              64       19325   154722015   83  Linux
/dev/sda3           19326       19455     1044225   82  Linux swap / Solaris
root@rhbeta:/home/chrthomp # 

My drive appears to have a partition start at 1 and end at 63, which is usually a small /boot ext2 partition. The 64 to 19325 area is a LVM file system apparently. Then comes the swap area. So since you have a backup - try to fix the problem by partitioning the drive.

fdisk /dev/sdX

create a 'n' partition '1' starting at '1' and ending at '63' and then 'w' write the partition table.

that appears to be a reasonably safe bet. Run the following commands

file -s /dev/sdX1
fsck -t ext2 /dev/sdX1
mount -t ext2 /dev/sdX1 /mnt

/mnt on a CDROM that boots is most probably available - you may have to mkdir /mnt/sdX1 and try mount -t ext2 /dev/sdX1 /mnt/sdX1

The other reason things may screw up is that the drive has been made unstable - the electronics may never recover - particularly if its an old drive.

I've seen these pop up, have trouble and die and disappear - only to reappear again in a loop.

Some people see this when /sbin/fsck.ntfs is not installed. the dmesg and /var/log/messages file will complain that the fsck.ntfs does not exist.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .