[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

copying disks with dd and cat



  Hi all.

  I've just been copying a floppy disk onto my hard drive to back it up.
  I initially used
% dd if=/dev/fd0 of=disk_image

  However it barfed with an IO error, and dmesg shows:

% dmesg
  <snip>
VFS: Disk change detected on device fd(2,0)
floppy0: CRC error: track 53, head 0, sector 16, size 2
floppy0: CRC error: track 53, head 0, sector 16, size 2
end_request: I/O error, dev 02:00 (floppy), sector 1923

  So then for some reason I tried cating the file:
% cat /dev/fd0 > disk_image.cat


  This didn't produce any information about errors. Doing an ls -l
  shows:
% ls -l
-rw-r--r--    1 ghc      ghc        983040 Jan 21 13:50 disk_image
-rw-r--r--    1 ghc      ghc       1474560 Jan 21 14:15 disk_image.cat

  What has got me really confused is the result of diff'ing a hexdump.

% hexdump -C disk_image > hex_dimage_dd
% hexdump -C disk_image.cat > hex_dimage_cat

% diff hex_dimage_dd hex_dimage_cat
41111c41111
< 00168000
---
> 000f0000

  So now it seems that the files are exactly the same, except for the
  last bit of the file, or rather the output of hexdump. The end of the
  hex_dimage_dd file shows:

% tail hex_dimage_dd
000aa920  c4 c4 c6 c6 c0 c0 c2 c2  cc cc ce ce c8 c8 ca ca  |................|
000aa930  d4 d4 d6 d6 d0 d0 d2 d2  dc dc de de d8 d8 da da  |................|
000aa940  24 24 26 26 20 20 22 22  2c 2c 2e 2e 28 28 2a 2a  |$$&&  "",,..((**|
000aa950  34 34 36 36 30 30 32 32  3c 3c 3e 3e 38 38 3a 3a  |44660022<<>>88::|
000aa960  04 04 06 06 00 00 02 02  0c 0c 0e 0e 08 08 0a 0a  |................|
000aa970  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000aaa00  f6 f6 f6 f6 f6 f6 f6 f6  f6 f6 f6 f6 f6 f6 f6 f6  |................|
*
000f0000

  It is only the last line of the file that is different in the other
hexdump.

  Can anyone explain how hexdump produces an almost identical listing
  for a file that differs in size by 491520 bytes?

  Cheers
  Geoff Crompton



Reply to: