From 932169b4e2da4485c9a7a186eaed43a341467000 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Tue, 22 Sep 2020 10:44:40 +0200 Subject: file-system: small fixes --- file-system.md | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'file-system.md') diff --git a/file-system.md b/file-system.md index acd7ab5..fa98d8e 100644 --- a/file-system.md +++ b/file-system.md @@ -13,17 +13,18 @@ If we look at storage devices as a way to store a bunch of ones and zeroes, we can see that this is not the most humane way of storing data. At the hardware level, there is no concept of file or directories, so we need a way of organizing these ones and zeroes in such a way that we can tell "such and such -series of bytes corresponds to the `/home/user/file.txt` content". +series of bytes correspond to the `/home/user/file.txt` content". This is exactly what a file system is. At the core, a file system is a way of -organizing data (we can this a "format", since it's a way of "formatting" +organizing data (we call this a "format", since it's a way of "formatting" data). Once we have some storage formatted for a known file system, we rely on the kernel to be able to read this file system. Then, once we know the kernel is able to read the file system, we want to tell -the kernel where we would like to see it in our directory tree. This is called "[mounting](#mounts)" a file system. +the kernel where we would like to see it in our directory tree. This is called +"[mounting](#mounts)" a file system. ## Storage devices @@ -42,7 +43,7 @@ In Flash Memory, used in USB Flash drives and often used in embedded systems, you cannot set a single 0 to a 1, but instead have to erase a whole "sector" to set every bit in that sector back to a 1. -While these specificities might have an impact in high end computing, or bare +While these specificities might have an impact in high-end computing, or bare metal embedded systems (i.e. without a kernel), in our case, we thankfully don't have to care about any of that. @@ -51,7 +52,7 @@ implemented in the kernel, leaving us with a much simpler interface, like `read` and `write` system calls. -## Some known file systems +## Some well-known file systems Just as there are multiple ways of storing an image in a file (jpeg, png, bmp, etc.), there are multiple file system formats. @@ -65,7 +66,7 @@ Flash Drive into something (computer, router, gaming console, etc.), you can be pretty sure it'll work. It is not without drawbacks though: it is prone to fragmentation, can't handle -files bigger than 4GB, and doesn't have many features that more modern file +files bigger than 4 GB, and doesn't have many features that more modern file systems have (e.g. error recovery). ### ext4 @@ -78,7 +79,7 @@ using ext4. NTFS is the standard file system used by Windows computers. To my knowledge, it is not much used elsewhere, except to have Windows compatible external drives, -and support files bigger than 4GB (so FAT32 is not a valid choice). +and support files bigger than 4 GB (so FAT32 is not a valid choice). ## Enabling file systems in the kernel @@ -102,13 +103,13 @@ To enable or disable a file system in the kernel, simply go to your [configuration](kernel.md#configuring-the-kernel), look up your file system in the "File Systems" menu, and enable or disable it. -## Usual format of a file system +## Anatomy of a file system Because a file system stores more that just the content of files, it needs -space for this "meta data". Different file systems do this differently, and +space for this "metadata". Different file systems do this differently, and have different needs, so let's quickly look at a few examples: -TODO: reference source of image +TODO: install the pandoc-citeproc filter ![FAT32 format](./res/fat32.jpg) @@ -130,8 +131,8 @@ partitions fails, fall back on booting on the other (in case a system upgrade broke something, for example). Like everything else in computer science, you have several ways of doing it: in -a similar to file systems, partitioning schemes are a way of formatting ones -and zeroes, but instead of storing files, it stores file systems. +a similar way to file systems, partitioning schemes are a way of formatting +ones and zeroes, but instead of storing files, it stores file systems. The two most common partitioning schemes are GPT (the most modern one) and MBR (which you'll often find on older systems). @@ -141,7 +142,7 @@ TODO: reference source of image ![GPT format](./res/GUID-Partition-Table-Scheme.svg) -Like file format, you'll find sections dedicated to the meta data of the +Like file format, you'll find sections dedicated to the metadata of the partitions (i.e. name of the partitions, id of the partition, etc.), and a whole space (partition data) to put your file system. @@ -188,13 +189,13 @@ But this is not what we usually want, we want to access the partitions inside the disk. For this, the kernel provides us with the files `/dev/sda1`, `/dev/sda2`, etc. -In a similar fashion, if you were to read directly from the file `/dev/sda2`, -you would get the bytes that are stored in the second partition of the first -disk (and you could parse yourself the format ext4, fat32, etc.) +Similarly, if you were to read directly from the file `/dev/sda2`, you would +get the bytes that are stored in the second partition of the first disk (and +you could parse yourself the format ext4, fat32, etc.) -Again, we do not usually want to access the bytes inside of the partition, but -we want to access the files stored inside of the file system of the partition! -To that end, what we do is [mount](#mounts) the file system. +Again, we do not usually want to access the bytes inside the partition, but we +want to access the files stored inside the file system of the partition! To +that end, what we do is [mount](#mounts) the file system. Accessing the raw bytes of the disk or partition is often useful, however. It can be used to list all the partitions in a disk, resize partitions, or get @@ -253,7 +254,7 @@ To mount a file system, we can use the `mount` command (being root is needed): root@host:~$ mount /dev/sda1 /mnt ``` -With this command, the kernel will try to auto detect the type of file system +With this command, the kernel will try to auto-detect the type of file system (ext4, fat, etc.), and provide you with the files inside that file system under the given directory (in this example: `/mnt`). -- cgit v1.2.3