Linux – Input/Output Error during fdisk with Passport

hard drivelinuxUbuntu

I bought a brand new WD Passport off Newegg. I couldn't copy anything to it (copy operations hung indefinitely then ended with IO error), so I tried reformatting it via the GUI. It now appears to be formatted as EXT4. Unfortunately, I still couldn't copy things to it. It formatted suspiciously fast (a few seconds; it's a 1TB drive). So I figured maybe it formatted wrong. So I tried:

$ sudo fdisk /dev/sdb1   

and got:

fdisk: unable to read /dev/sdb1: Input/output error

What do I do?! I'm in Ubuntu 12.10 in case it matters.

Best Answer

fdisk works on disks, not partitions. On Linux, a disk is referred to as e.g. /dev/sdb, whereas the partitions on it are referred to as /dev/sdb1, /dev/sdb2 etc. Note that old-style (/dev/[hs]d?, /dev/[hs]d??) partition specifiers always end with a digit, whereas disk specifiers always end with a letter.

If you just format the disk (no bad blocks checking etc.), then a format time of a few seconds is not entirely unreasonable. All you did was write the initial file system metadata structures to disk, and while I don't have any exact numbers to cite, those are fairly small, and USB is pretty fast for writing such relatively small amounts of data. If you didn't get any errors, the format process probably did its thing.

The first thing you should do is run fdisk on the proper device. In your case, it sounds like that will be sudo fdisk /dev/sdb, but note that in some cases the device name can change with time. I recommend using one of the entries in /dev/disk/by-id instead, as those will not change. You can see what the disk shows up with there by running, immediately before you connect the disk:

diff <(ls /dev/disk/by-id) <(sleep 15; ls /dev/disk/by-id)

This will show the differences in directory content between the two executions of ls, which will be spaced 15 seconds apart thanks to the sleep invocation in the second input pipe. 15 seconds should give the kernel enough time to identify the disk and let udev create the appropriate device nodes. If it doesn't show any differences (empty output), unplug the disk and try it again increasing the delay. You will see both partition devices (ending with -part followed by a number and possibly @) and disk devices (without the -part part). If the file names do end with @, disregard that character; it's a ls output artefact.

Once you have partition(s) properly in place, you can make a file system on it/them. For example, sudo mkfs.ext4 -v /dev/disk/by-id/xxxxx-Passport-XXXXXXX-part1. The -v turns on extra output ("v" for verbose) which will give you an idea of whether the file system is created successfully.

After that, the disk should be perfectly usable.

Related Question