how to view the content of /dev/sda file?

I formatted a 160GB drive using:

dd if=/dev/zeros of=/dev/sda bs=512

I expect the entire drive is filled with zeros, but how do I check it?

I thought I could just cat /dev/sda and see all zeros, however, after I did that, the terminal appeared to freeze.


Notice on usage

It is /dev/zero and not /dev/zeros so your command should be:

dd if=/dev/zero of=/dev/sda bs=512

And not:

dd if=/dev/zeros of=/dev/sda bs=512

How to verify?

There are many ways to verify the drive contains only zeros but opening the drive as a file and viewing it is not the most efficient method at all.

A simple method wold be to use cmp which will compare two files byte by byte and report the first difference. Basically, you would compare /dev/zero as a file ( all zeros ) to your drive as another file like so:

cmp /dev/zero /dev/sda

If you get something like this:

cmp: EOF on....

Then files are identical up to the end of the shorter file ( your drive in this case ) and all there are are zeros.

A difference would be reported by cmp with something like this:

... differ: byte 1, line 1

I am sure it didn't freeze; it just takes a looong time. One screenful (80x25) are 1920 characters, i.e. not quite 2k. And you are trying to view 160 GB worth of zeroes, i.e.

160 * 1024 * 1024 * 1024 characters, i.e. 171798691840 characters.

I hope you didn't make any plans for the next few weeks... ;-)