I'm a little confused (even after reading this) post, about how *nix partitions work.

From my understanding, sda usually refers to the disk and sda1, sda2, etc, refer to the first, second, and so forth, partitions located on the disk. This seems logical, but then I've also read that some directories (or so I thought they were directories), are actually partitions, like /boot/, /var and /tmp.

Where are these partitions located? If sda is the disk and lsblk shows the only partitions on sda are sda1-sda8 and these 8 partitions start from the beginning and go all the way to the end of the disk, where could these other partitions exist?

  1. Are directories like /boot and /var actually partitions?
  2. If so, where are they located on the disk in reference to the sdaX partitions?
  3. I couldn't seem to find any information about these directories/partitions from parted, fdisk, or lsblk. How can I find out more about these on my machine?
  4. If /dev/sda is the disk, then what is /, and where is it on sda?

/dev does not hold any partitions. /dev is a de facto standrad place to keep all device nodes. Originally, /dev was a plain directory in the root file system (so the device nodes created survived a system reboot). Nowadays, the special virtual filesystem backed by RAM is used by most Linux distributions.

There is no standard of any kind to have some filesystem on a specific partition or total number of partitions required.

There is a number of good practices/distribution-specific-standards exist to place parts of a system on separate partitions, though.

You could find a Linux installation that occupies a single partition for all its needs.

In a multi-partitioned installation the '/boot' is usually a separate partition to maintain its readability by the BIOS and/or boot loader. Also some boot loaders and kernels have restrictions on root file system type to use.

The rest is up to you in most cases so you split the disk into partitions according to your needs (data storage requirements, temporary files, logs, etc)

  • Since I do have a multi-partition installation, I'm assuming my /boot is its own partition. Where is that partition on the disk?
    – Matt C
    Jun 4 '16 at 1:15
  • 1
    @MatthewCliatt: As I said in my answer, look in /etc/fstab to see if boot is listed there. The fact that you have more than one partition can not lead to any assumption on how your system was set up. Jun 4 '16 at 1:20
  • 1
    «the special virtual filesystem backed by RAM is used by most Linux distributions» And this saved me when I accidentally rm -rf-ed stuff inside /dev. :D Jun 4 '16 at 16:36

A file or directory in the filesystem need not actually correspond to anything on disk. For instance, you can have a filesystem (and its files) or part of it exist entirely in memory.

But they don't have to be files at all, at least in the sense we usually use the term. Think of the filesystem and its "files" as an abstract interface. Almost all of your files will simply correspond to a file on a disk (or other storage device) somewhere, but it can theoretically correspond to anything that can handle data in a stream format. Granted, that sort of thing is rarely seen outside the /dev directory except for special things like pipes and sockets.

For example, while this is probably oversimplifying things a bit, there could be a port on your computer named /dev/someport and writing the string "foo" to this "file" will actually send the string "foo" through the port without ever touching anything on any disk.

  • Great perspective; "filesystem" and "disk partition" are different concepts and they have a different definition of "file". I'll contest the "nowhere else" though: unix file names can also point to things like named pipes or domain sockets.
    – Kos
    Jun 4 '16 at 9:43
  • @Kos Partitions have no concept of files. Only file systems do.
    – user
    Jun 4 '16 at 13:14

The only thing resembling a partition in /dev/ is udev which is a pseudo filesystem used for dynamic device allocation which is a kernel feature to make device files flexible and easy to use.

What you see in /dev/ are device files which actually refer to real devices, including hard drives (/dev/sda) and their partitions (/dev/sda1).

Partitions are mounted on what is called a mounting point: the place where the partition is linked in the existing filesystem tree.

/ is the primary (root) partition mounting point. /boot/ is commonly a mount point for the boot partition. /var is not commonly a mount point. /tmp is commonly a tmpfs filesystem which is designed specifically to deal with temporary files in memory.

To list the mounted partitions, use mount. Predefined mount points are defined in /etc/fstab.


You sound confused.

/boot is a directory. It is possible to put the contents of /boot on a different partition, but /boot itself is a normal directory. It doesn't really make sense to say "/boot is a partition".

It is customary to have a directory named /dev, which contains "device nodes" such as sda, sda1, and so on. These look like files, but if you open (say) /dev/sda and read bytes from it, you see the raw bytes on the first harddisk. And if you write to it, the bytes are written directly to the harddisk (thereby destroying your disk partition table and other information, so don't actually try this!)

There are other device nodes; for example, if you open the file /dev/zero and read from it, no matter how many bytes you ask to read, you never reach the end of the file, and the bytes are always zeros. It's as if /dev/zero is a file that contains infinity bytes of zeros!

Of course, /dev/zero doesn't really contain infinity bytes. It's actually just a small stub with some magic code numbers in it telling the Linux kernel to talk to a specific device driver. Likewise, /dev/sda points to a different driver (the one for harddisks), /dev/sr0 points to another (the CD-ROM driver), and so on. (You might find /dev/soundcard, /dev/tty3, and so on.)

I think your question is basically "We need /dev to access disks, but /dev is stored on disk, so... wuh?!"

Once the partition that contains /dev is mounted, you can just access /dev normally. But how do we get to that position in the first place? Well, that's the black magic of the Linux boot sequence. ;-)

The old way was to write a Linux kernel parameter that says something like root=(hd0,3) to say to mount partition #3 on disk #0 as the root filesystem, and continue from there. (In particular, the kernel loads /bin/init as process #1.)

The new way is using something called an "initial RAM-disk" ("initrd"). The even newer way is "initramfs", which is subtly different in a way I won't bore you with now. Either way, your bootloader (typically GRUB) loads the Linux kernel and initrd into memory.

Basically initrd contains a little mini-version of your operating system; it contains files and folders and stuff. In particular, it contains the boot scripts that knew where to find the real boot partition, and mount it for you. One of the things the initrd contains is a /dev folder full of device nodes. Eventually, when the boot scripts do their thing, you find the real boot device, and mount it over the top of the initrd contents. And from there, you can access your real files as normal.


/boot and /var aren't necessarily on their own partition, but you can do so, on installing a *nix OS... Personnaly my /home has its own partition

The data these folders really contain is located on parts of the actual hard drive, and as I guess the /dev/sda* files are just info about the actual disk partition (like its beginnig and end on the disk, its filesystem...)

You don't get info about those suposed partitions, maybe it's just that you don't have them. You might have skipped this option while installing your Ubuntu (or *nix).

So /dev/sda is not the disk itself, it's a file that descripts the hard drive.
And / generally is your /dev/sda2 partition, if you have a boot partition

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.