But first, we'd like to briefly address something you might have found confusing, especially if you're coming from a Windows background where you're used to multiple disks/partitions in the form of C:\, D:\, E:\, and so on. With the preceding directory structure, and the information that the highest point in the filesystem is at /, how does Linux deal with multiple disks/partitions?
The answer is actually pretty simple. Linux mounts filesystems somewhere within the tree structure. The first mount is found on the primary partition we have already covered: it is mounted on /! Let's see how this looks while we check out a new df tool:
reader@ubuntu:~$ df -hT
Filesystem Type Size Used Avail Use% Mounted on
udev devtmpfs 464M 0 464M 0% /dev
tmpfs tmpfs 99M 920K 98M 1% /run
/dev/sda2 ext4 9.8G 4.4G 5.0G 47% /
tmpfs tmpfs 493M 0 493M 0% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs tmpfs 493M 0 493M 0% /sys/fs/cgroup
/dev/loop0 squashfs 87M 87M 0 100% /snap/core/4917
/dev/loop1 squashfs 87M 87M 0 100% /snap/core/4486
/dev/loop2 squashfs 87M 87M 0 100% /snap/core/4830
tmpfs tmpfs 99M 0 99M 0% /run/user/1000
While this is a lot of output by df (which reports filesystem disk space usage), the most interesting was highlighted previously: the partition /dev/sda2 of type ext4 (remember?) is mounted on /. You're getting a preview of the everything is a file later in this chapter: /dev/sda2 is handled as a file, but it is actually a reference to a partition on the disk (which is, in this case, a virtual disk). Another example from our Arch Linux host gives even more information (don't worry if you don't have a Linux host, we'll explain later):
[root@caladan ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
dev devtmpfs 7.8G 0 7.8G 0% /dev
run tmpfs 7.8G 1.5M 7.8G 1% /run
/dev/mapper/vg_caladan-lv_arch_root ext4 50G 29G 19G 60% /
tmpfs tmpfs 7.8G 287M 7.5G 4% /dev/shm
tmpfs tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
tmpfs tmpfs 7.8G 212K 7.8G 1% /tmp
/dev/sda1 vfat 550M 97M 453M 18% /boot
tmpfs tmpfs 1.6G 16K 1.6G 1% /run/user/120
tmpfs tmpfs 1.6G 14M 1.6G 1% /run/user/1000
/dev/sdc1 vfat 15G 552M 14G 4% /run/media/tammert/ARCH_201803
/dev/mapper/vg_caladan-lv_data btrfs 10G 17M 9.8G 1% /data
You can see I have an ext4 filesystem mounted as my root. However, I also have an extra btrfs partition mounted on /data/ and a vfat boot partition (which is needed on bare-metal installations, but not on virtual machines) on /boot/. To top it off, there's also a vfat USB device with the Arch Linux installer connected, which was automatically mounted under /run/media/. So not only does Linux handle multiple partitions or disks gracefully, even different types of filesystems can be used side by side under the same tree structure!