Linux Partitions: A Primer - page 3
How Linux Sees Drives and Partitions
Notice in Figure 4 how there's this weird label associated with each of the partitions I mentioned. In the Windows world, partitions and hard drives are labeled exactly the same way, starting with C:, then D:, and so on. In the Linux world, each drive also has a letter associated with it, and from there it gets more complicated (but in the end it makes a lot more sense once you understand it).
So let's start with the hard drives, themselves. The primary drive in your machine is drive a, the secondary is b, and so on. Then you have to distinguish between an IDE drive, and a SCSI drive; most people these days use IDE drives in their home computers, if you're using a SCSI drive, you had to go out of your way to get it, so hopefully you'll know that's what you've got. Linux sees all IDE drives as hd, and all SCSI drives as sd.
Therefore, if the first drive on your machine is an IDE, then Linux sees that drive as hda. The second IDE drive is hdb, and so on. If your first drive is a SCSI, then it's seen as sda, the second as sdb, and so on. On a machine where for some odd reason you've mixed and matched hardware between SCSI and IDE, Linux will letter the drives in the order that the computer sees them.
Now on to the partitions. Each partition gets a number, just as you saw in Figure 4. No matter what drive we're talking about, the partitions are simply numbered in order: 1, 2, 3, 4, and so on. The number is then tacked onto the end of the drive reference, so the first partition on the first IDE hard drive is hda1, the second on that drive is hda2, etc. If your second drive is a SCSI, then you'd end up with sdb1, sdb2, sdb3, and so on.
There's just one more thing in Figure 4 I haven't explained yet. Understanding it requires wrapping your mind around the fact that everything to Linux is a file. Your hard drive is a file, your partitions are files, your printers are files, your directories are files, your monitor's a file, and so on.
All devices on your system (pieces of hardware that Linux needs to interact with) have a corresponding file in the /dev directory. This fact includes both your hard drives and your partitions. This is why, in Figure 4, you see references to /dev/hda1, /dev/hda2, and so on. That's how the Linux kernel looks at your drives and partitions. The nice thing is that of course, each type of hard drive needs a different driver to interface with the kernel, but we're spared that much of it. We can just use these handy shortcuts.
Aside from the drive designators (/dev/hda1, etc.), your partitions are named after where you want the kernel to place them within the filesystem. Unlike Windows where you treat every partition as a different drive, Linux leaves the physical locations out of it and just lets you navigate through directories and files. So your root directory (/) might be on /dev/hda1, your home directories (all stored in /home) might all be on /dev/hda2, and then maybe Fred's home directory (/home/fred) is even on another machine across the network but you're using NFS to attach it to this machine as well.
- 1Linux Top 3: Fedora 24, Peppermint 7 and Solus 1.2
- 2Linux Top 3: Alpine Linux 3.4, deepin 15.2 and Linux Lite 3.0
- 3Linux 4.7 Set to Boost Live Patching, Security and Power Management
- 4Linux 4.6 Charred Weasel adds USB 3.1 Support
- 5Linux Top 3: OpenIndiana 2016.04, Ubuntu 16.04 and Debian's New Leader