1
$\begingroup$

Ok. I know this is probably a commonly asked question. Before you refer me to a site or answer this yourself, I ask for you to please read this through. I have been into computers and electronics for quite a while. I have a pretty good understanding of electronics, and would like to become a computer hardware engineer eventually. For quite a while now, I have been searching for an answer to my question: How to hard drives send and recieve data, and in general, how do they work? Every site I find, simply explains the basics, of which I already am quite familiar with.

An example of what I am trying to figure out: Suppose you want to save a very small file (less than 1KB for simplicity) to a hard drive. Is there a site that explains exactly what information is exchanged between the hard drive and the rest of the computer? I would like to understand what is sent, and when it is sent ( down to ones and zeros ). I would eventually like to know enough information that, in theory, I could build a small storage device compatible with a modern computer. The more information, the better.

$\endgroup$
  • $\begingroup$ Have you taken a class on operating systems? $\endgroup$ – Yuval Filmus Sep 7 '17 at 7:22
  • 1
    $\begingroup$ Literally any textbook on operating systems covers this. $\endgroup$ – David Richerby Sep 7 '17 at 8:50
  • $\begingroup$ @YuvalFilmus I am actually taking a basic class on operating systems right now! $\endgroup$ – Samuel Weber Sep 7 '17 at 9:30
  • $\begingroup$ @YuvalFilmus I am not sure how in depth it is going to get, since it is just an entry level class. $\endgroup$ – Samuel Weber Sep 7 '17 at 9:37
2
$\begingroup$

As it stands, this isn't a Computer Science question. Actually, it's several questions, some of which could be phrased of as computer science questions.

Disk-like devices (these days we'd include flash memory) do not understand the concept of a "file" or "directory". You can think of a disk as a big array of fixed-size blocks. The two basic operations are "read a block" and "write a block". Files are an abstraction on top of this implemented by the operating system.

All of this is explained in any operating systems course. But if you just want the short version, I recommend Maurice Bach's classic book The Design of the UNIX Operating System. It doesn't reflect modern operating systems or filesystems that well, but it will give you a good idea about what operating systems do and what they expect of a disk device. If that wasn't enough for you, Practical File System Design by Dominic Giampaolo is a whole book which gives an in-depth look at a more modern filesystem design.

The hardware that sits between there and the disk is a topic all by itself. On a modern system, disks can be connected to a computer using a variety of different hardware connection (e.g. USB, SATA, SCSI), and a modern operating system needs to both be able to talk to the host controller for this bus, but also be able to tell what is attached to the bus. For some busses (e.g. USB) there may be a complex topology for the operating system to discover; the disk may be connected via a hub, for example.

The final link in the chain is what lies between the bus and the storage medium itself, and this is presumably what you're interested in.

My suggestion, if hardware engineering is what you're most interested in, is to hook a simple computer (e.g. a microcontroller) up to a simple storage device (e.g. MMC) and see what you can do. You will learn a lot this way.

As a final comment, there is a book by Jan Axelson called USB Mass Storage: Designing and Programming Devices and Embedded Hosts. I can't recommend it because I haven't read it, but it looks like the sort of thing you might want to know. If I'm reading the table of contents correctly, it looks like it gives you everything you need to know to build a USB flash drive. That sounds like a fun project to me.

$\endgroup$
  • $\begingroup$ Thank you for the response! I am thinking about getting a raspberry pi, and based on your answer, I could probably learn a lot just from experimentation with different components. Also, I will be sure to check out the different books you recommended, as they all seem to offer plenty of information towards my question! $\endgroup$ – Samuel Weber Sep 7 '17 at 9:36
1
$\begingroup$

What data is exchanged between "computer" and "hard drive" is specified by the protocol that they're talking. For example SATA is a popular protocol. In general you should be able to look up the bus protocol for any connector in your computer.

It is probably also helpful to check out some open source operating system's code for talking to hard drives.

$\endgroup$
  • $\begingroup$ Thanks for the suggestion. I have do not know much about the language(s) used to code operating systems, but I am beginning to learn assembly (at a slow rate). I will be sure to check out some open source operation systems once I am somewhat comfortable with the languages. $\endgroup$ – Samuel Weber Sep 7 '17 at 9:41
  • $\begingroup$ It might be a bit easier to start with C. $\endgroup$ – adrianN Sep 7 '17 at 9:50
  • $\begingroup$ You might enjoy nand2tetris.org $\endgroup$ – adrianN Sep 7 '17 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.