Device versus File

holding data on a floppy with and without a fileystem

Read a little about devices versus files as alternative types of data containers. Work with 2 floppy diskettes.


The exercise for you to perform:

Acquire a copy of Abraham Lincoln's Gettysburg Address in file gettysburg.txt per your instructor. Below are two ways to put the contents of the Address onto a floppy. Do it both ways, once onto each of your 2 floppies.

1) put the Gettysburg Address onto the floppy directly, i.e. using the floppy itself as the housing container and starting at byte number one:

cat gettysburg.txt | dd of=/dev/fd0

2) put a file named "ga.txt" onto the floppy, and put the Gettysburg Address into that instead. It won't start at floppy byte number one; it will start at file byte number one instead. The housing container for the Address is the file, not the floppy.

mkfs /dev/fd0
mount /dev/fd0 /media/floppy
cat gettysburg.txt > /media/floppy/ga.txt
umount  /dev/fd0


Now to examine what you got. Successively put your floppies into the drive and for each execute:

dd if=/dev/fd0 | xxd -g1 | less

to see an A-to-Z (or 1-to-1.4MB) regurgitation of exactly what's on the floppy. Where on the floppy does the Mr. Lincoln's Address start? Locate it in both cases. In the latter, "file" case, where is the Address within the floppy? (you're within the "less" utility, where you can search for small fragments of known text from the Address by pressing the slash / key then typing target text and Enter, till the Address appears; exit less by pressing letter q.)

...How did you figure out the answer? When we ask the computer the same question (by "reading" the file), how can the computer figure it out?