I'm learning about the /dev
filesystem. I've begun with /dev/sd*
(Linux) and /dev/disk*
(OS X), and I've found some interesting behaviour. If I run:
$ sudo xxd -l 1024 /dev/disk0
I get the following output:
0000000: 33c0 8ed0 bc00 7c8e c08e d8be 007c bf00 3.....|......|..
0000010: 06b9 0002 fcf3 a450 681c 06cb fbb9 0400 .......Ph.......
0000020: bdbe 0780 7e00 007c 0b0f 850e 0183 c510 ....~..|........
0000030: e2f1 cd18 8856 0055 c646 1105 c646 1000 .....V.U.F...F..
0000040: b441 bbaa 55cd 135d 720f 81fb 55aa 7509 .A..U..]r...U.u.
0000050: f7c1 0100 7403 fe46 1066 6080 7e10 0074 ....t..F.f`.~..t
0000060: 2666 6800 0000 0066 ff76 0868 0000 6800 &fh....f.v.h..h.
0000070: 7c68 0100 6810 00b4 428a 5600 8bf4 cd13 |h..h...B.V.....
< ... >
A little Googling seems to identify this as the start of an MBR (I have Bootcamp installed).
However, the following doesn't work:
$ sudo xxd -l 1000 < /dev/disk0
-bash: /dev/disk0: Permission denied
My questions are:
- Many applications hide critical sections of disks (e.g. MBR, file system inodes, partition boundaries, etc). Is the output from
xxd
a true low-level dump of a device? Am I seeing everything byte-by-byte on the device? - As
/dev/disk0
clearly contains data, why can I not use it as a stdin stream?