On Tue, 3 Sep 2013, 13:24, Craig Sanders wrote:
} On Tue, Sep 03, 2013 at 12:35:08PM +1000, Tony Crisp wrote:
} > To check to see if a drive has data on it, send the output to standard
} > out.
} >
} > dd if=/dev/sda
}
} this is pretty nearly completely useless, dumping of raw binary data
} to the tty is a) unlikely to be readable by any human and b) likely to
} screw up the tty settings - many control characters move the cursor
} around, change colors and other attributes, put ttys into weird
} graphics-character modes, and even mess up keyboard input/display.
}
} at least use a hexdumper program to get hex+ascii output, like 'hd' aka
} 'hexdump'. not only will it be actually readable, it will protect the
} tty from raw control and escape codes (actually, even piping dd output
} into less will help with the latter).
}
} for example:
}
} hd /dev/sda | less
}
} hd is in the bsdmainutils main utils package in debian.
}
} example output (30 lines is just enough to show readable ascii text from
} grub):
}
} # hd /dev/sda | head -30
} 00000000 eb 63 90 00 00 00 00 00 00 00 00 00 00 00 00 00 |.c..............|
} 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
} *
} 00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 02 |................|
} 00000040 ff 00 00 20 01 00 00 00 00 02 fa 90 90 f6 c2 80 |... ............|
} 00000050 75 02 b2 80 ea 59 7c 00 00 31 00 80 01 00 00 00 |u....Y|..1......|
} 00000060 00 00 00 00 ff fa 90 90 f6 c2 80 74 05 f6 c2 70 |...........t...p|
} 00000070 74 02 b2 80 ea 79 7c 00 00 31 c0 8e d8 8e d0 bc |t....y|..1......|
} 00000080 00 20 fb a0 64 7c 3c ff 74 02 88 c2 52 be 80 7d |. ..d|<.t...R..}|
} 00000090 e8 17 01 be 05 7c b4 41 bb aa 55 cd 13 5a 52 72 |.....|.A..U..ZRr|
} 000000a0 3d 81 fb 55 aa 75 37 83 e1 01 74 32 31 c0 89 44 |=..U.u7...t21..D|
} 000000b0 04 40 88 44 ff 89 44 02 c7 04 10 00 66 8b 1e 5c |[email protected]..\|
} 000000c0 7c 66 89 5c 08 66 8b 1e 60 7c 66 89 5c 0c c7 44 ||f.\.f..`|f.\..D|
} 000000d0 06 00 70 b4 42 cd 13 72 05 bb 00 70 eb 76 b4 08 |..p.B..r...p.v..|
} 000000e0 cd 13 73 0d f6 c2 80 0f 84 d8 00 be 8b 7d e9 82 |..s..........}..|
} 000000f0 00 66 0f b6 c6 88 64 ff 40 66 89 44 04 0f b6 d1 |[email protected]....|
} 00000100 c1 e2 02 88 e8 88 f4 40 89 44 08 0f b6 c2 c0 e8 |[email protected]......|
} 00000110 02 66 89 04 66 a1 60 7c 66 09 c0 75 4e 66 a1 5c |.f..f.`|f..uNf.\|
} 00000120 7c 66 31 d2 66 f7 34 88 d1 31 d2 66 f7 74 04 3b ||f1.f.4..1.f.t.;|
} 00000130 44 08 7d 37 fe c1 88 c5 30 c0 c1 e8 02 08 c1 88 |D.}7....0.......|
} 00000140 d0 5a 88 c6 bb 00 70 8e c3 31 db b8 01 02 cd 13 |.Z....p..1......|
} 00000150 72 1e 8c c3 60 1e b9 00 01 8e db 31 f6 bf 00 80 |r...`......1....|
} 00000160 8e c6 fc f3 a5 1f 61 ff 26 5a 7c be 86 7d eb 03 |......a.&Z|..}..|
} 00000170 be 95 7d e8 34 00 be 9a 7d e8 2e 00 cd 18 eb fe |..}.4...}.......|
} 00000180 47 52 55 42 20 00 47 65 6f 6d 00 48 61 72 64 20 |GRUB .Geom.Hard |
} 00000190 44 69 73 6b 00 52 65 61 64 00 20 45 72 72 6f 72 |Disk.Read. Error|
} 000001a0 0d 0a 00 bb 01 00 b4 0e cd 10 ac 3c 00 75 f4 c3 |...........<.u..|
} 000001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff |................|
} 000001c0 ff ff ee ff ff ff 01 00 00 00 af 6d 70 74 00 00 |...........mpt..|
} 000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
}
}
} BTW, note how it consolidated consecutive lines of all zeroes (00000010
} to 00000020) - in this case, only two consecutive lines but it does the
} same thing no matter how many there are. so if the disk is completely
} zeroed, you'll only see two or three lines of output total.
}
}
} craig
hmmm, I like it, works on partitions too =]
# hexdump -C /dev/sda2 | head
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000400 01 00 00 00 6d 42 0f 00 00 00 00 00 06 7f 25 6d |....mB........%m|
00000410 64 c1 43 f9 92 06 58 bc ee 00 b6 1d 00 00 00 00 |dÁCù..X¼î.¶.....|
00000420 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000ff0 00 00 00 00 00 00 53 57 41 50 53 50 41 43 45 32 |......SWAPSPACE2|
00001000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00008000 40 7f d9 fc ba 7f 00 00 16 c3 ef f6 ba 7f 00 00 |@.Ùüº....Ãïöº...|
T.
_______________________________________________
luv-main mailing list
[email protected]
http://lists.luv.asn.au/listinfo/luv-main