
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 |.@.D..D.....f..\| 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 |.f....d.@f.D....| 00000100 c1 e2 02 88 e8 88 f4 40 89 44 08 0f b6 c2 c0 e8 |.......@.D......| 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 ps: oh no! now i've posted the partition table of one of my drives for the entire world to see, and archived by google and their colleagues[1] at the NSA forever. [1] they're both in the business of spying on you, for pretty much the same reasons. the political and the commercial worlds aren't as different as they should be. -- craig sanders <cas@taz.net.au>