diff options
author | Minijackson <minijackson@riseup.net> | 2020-09-22 10:44:40 +0200 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2020-09-22 10:44:40 +0200 |
commit | 932169b4e2da4485c9a7a186eaed43a341467000 (patch) | |
tree | d7dc3e483b9935ff035e94186862a73ff7fc4196 | |
parent | 66a3e5444b62184f7520dcb64b77bb1f71b86594 (diff) | |
download | wtf-is-linux-website-932169b4e2da4485c9a7a186eaed43a341467000.tar.gz wtf-is-linux-website-932169b4e2da4485c9a7a186eaed43a341467000.zip |
file-system: small fixes
-rw-r--r-- | file-system.md | 41 |
1 files changed, 21 insertions, 20 deletions
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 | |||
13 | can see that this is not the most humane way of storing data. At the hardware | 13 | can see that this is not the most humane way of storing data. At the hardware |
14 | level, there is no concept of file or directories, so we need a way of | 14 | level, there is no concept of file or directories, so we need a way of |
15 | organizing these ones and zeroes in such a way that we can tell "such and such | 15 | organizing these ones and zeroes in such a way that we can tell "such and such |
16 | series of bytes corresponds to the `/home/user/file.txt` content". | 16 | series of bytes correspond to the `/home/user/file.txt` content". |
17 | 17 | ||
18 | This is exactly what a file system is. At the core, a file system is a way of | 18 | This is exactly what a file system is. At the core, a file system is a way of |
19 | organizing data (we can this a "format", since it's a way of "formatting" | 19 | organizing data (we call this a "format", since it's a way of "formatting" |
20 | data). | 20 | data). |
21 | 21 | ||
22 | Once we have some storage formatted for a known file system, we rely on the | 22 | Once we have some storage formatted for a known file system, we rely on the |
23 | kernel to be able to read this file system. | 23 | kernel to be able to read this file system. |
24 | 24 | ||
25 | Then, once we know the kernel is able to read the file system, we want to tell | 25 | Then, once we know the kernel is able to read the file system, we want to tell |
26 | the kernel where we would like to see it in our directory tree. This is called "[mounting](#mounts)" a file system. | 26 | the kernel where we would like to see it in our directory tree. This is called |
27 | "[mounting](#mounts)" a file system. | ||
27 | 28 | ||
28 | 29 | ||
29 | ## Storage devices | 30 | ## Storage devices |
@@ -42,7 +43,7 @@ In Flash Memory, used in USB Flash drives and often used in embedded systems, | |||
42 | you cannot set a single 0 to a 1, but instead have to erase a whole "sector" to | 43 | you cannot set a single 0 to a 1, but instead have to erase a whole "sector" to |
43 | set every bit in that sector back to a 1. | 44 | set every bit in that sector back to a 1. |
44 | 45 | ||
45 | While these specificities might have an impact in high end computing, or bare | 46 | While these specificities might have an impact in high-end computing, or bare |
46 | metal embedded systems (i.e. without a kernel), in our case, we thankfully | 47 | metal embedded systems (i.e. without a kernel), in our case, we thankfully |
47 | don't have to care about any of that. | 48 | don't have to care about any of that. |
48 | 49 | ||
@@ -51,7 +52,7 @@ implemented in the kernel, leaving us with a much simpler interface, like | |||
51 | `read` and `write` system calls. | 52 | `read` and `write` system calls. |
52 | 53 | ||
53 | 54 | ||
54 | ## Some known file systems | 55 | ## Some well-known file systems |
55 | 56 | ||
56 | Just as there are multiple ways of storing an image in a file (jpeg, png, bmp, | 57 | Just as there are multiple ways of storing an image in a file (jpeg, png, bmp, |
57 | etc.), there are multiple file system formats. | 58 | etc.), there are multiple file system formats. |
@@ -65,7 +66,7 @@ Flash Drive into something (computer, router, gaming console, etc.), you can be | |||
65 | pretty sure it'll work. | 66 | pretty sure it'll work. |
66 | 67 | ||
67 | It is not without drawbacks though: it is prone to fragmentation, can't handle | 68 | It is not without drawbacks though: it is prone to fragmentation, can't handle |
68 | files bigger than 4GB, and doesn't have many features that more modern file | 69 | files bigger than 4 GB, and doesn't have many features that more modern file |
69 | systems have (e.g. error recovery). | 70 | systems have (e.g. error recovery). |
70 | 71 | ||
71 | ### ext4 | 72 | ### ext4 |
@@ -78,7 +79,7 @@ using ext4. | |||
78 | 79 | ||
79 | NTFS is the standard file system used by Windows computers. To my knowledge, it | 80 | NTFS is the standard file system used by Windows computers. To my knowledge, it |
80 | is not much used elsewhere, except to have Windows compatible external drives, | 81 | is not much used elsewhere, except to have Windows compatible external drives, |
81 | and support files bigger than 4GB (so FAT32 is not a valid choice). | 82 | and support files bigger than 4 GB (so FAT32 is not a valid choice). |
82 | 83 | ||
83 | 84 | ||
84 | ## Enabling file systems in the kernel | 85 | ## Enabling file systems in the kernel |
@@ -102,13 +103,13 @@ To enable or disable a file system in the kernel, simply go to your | |||
102 | [configuration](kernel.md#configuring-the-kernel), look up your file system in | 103 | [configuration](kernel.md#configuring-the-kernel), look up your file system in |
103 | the "File Systems" menu, and enable or disable it. | 104 | the "File Systems" menu, and enable or disable it. |
104 | 105 | ||
105 | ## Usual format of a file system | 106 | ## Anatomy of a file system |
106 | 107 | ||
107 | Because a file system stores more that just the content of files, it needs | 108 | Because a file system stores more that just the content of files, it needs |
108 | space for this "meta data". Different file systems do this differently, and | 109 | space for this "metadata". Different file systems do this differently, and |
109 | have different needs, so let's quickly look at a few examples: | 110 | have different needs, so let's quickly look at a few examples: |
110 | 111 | ||
111 | TODO: reference source of image | 112 | TODO: install the pandoc-citeproc filter |
112 | 113 | ||
113 |  | 114 |  |
114 | 115 | ||
@@ -130,8 +131,8 @@ partitions fails, fall back on booting on the other (in case a system upgrade | |||
130 | broke something, for example). | 131 | broke something, for example). |
131 | 132 | ||
132 | Like everything else in computer science, you have several ways of doing it: in | 133 | Like everything else in computer science, you have several ways of doing it: in |
133 | a similar to file systems, partitioning schemes are a way of formatting ones | 134 | a similar way to file systems, partitioning schemes are a way of formatting |
134 | and zeroes, but instead of storing files, it stores file systems. | 135 | ones and zeroes, but instead of storing files, it stores file systems. |
135 | 136 | ||
136 | The two most common partitioning schemes are GPT (the most modern one) and MBR | 137 | The two most common partitioning schemes are GPT (the most modern one) and MBR |
137 | (which you'll often find on older systems). | 138 | (which you'll often find on older systems). |
@@ -141,7 +142,7 @@ TODO: reference source of image | |||
141 |  | 142 |  |
142 | 143 | ||
143 | 144 | ||
144 | Like file format, you'll find sections dedicated to the meta data of the | 145 | Like file format, you'll find sections dedicated to the metadata of the |
145 | partitions (i.e. name of the partitions, id of the partition, etc.), and | 146 | partitions (i.e. name of the partitions, id of the partition, etc.), and |
146 | a whole space (partition data) to put your file system. | 147 | a whole space (partition data) to put your file system. |
147 | 148 | ||
@@ -188,13 +189,13 @@ But this is not what we usually want, we want to access the partitions inside | |||
188 | the disk. For this, the kernel provides us with the files `/dev/sda1`, | 189 | the disk. For this, the kernel provides us with the files `/dev/sda1`, |
189 | `/dev/sda2`, etc. | 190 | `/dev/sda2`, etc. |
190 | 191 | ||
191 | In a similar fashion, if you were to read directly from the file `/dev/sda2`, | 192 | Similarly, if you were to read directly from the file `/dev/sda2`, you would |
192 | you would get the bytes that are stored in the second partition of the first | 193 | get the bytes that are stored in the second partition of the first disk (and |
193 | disk (and you could parse yourself the format ext4, fat32, etc.) | 194 | you could parse yourself the format ext4, fat32, etc.) |
194 | 195 | ||
195 | Again, we do not usually want to access the bytes inside of the partition, but | 196 | Again, we do not usually want to access the bytes inside the partition, but we |
196 | we want to access the files stored inside of the file system of the partition! | 197 | want to access the files stored inside the file system of the partition! To |
197 | To that end, what we do is [mount](#mounts) the file system. | 198 | that end, what we do is [mount](#mounts) the file system. |
198 | 199 | ||
199 | Accessing the raw bytes of the disk or partition is often useful, however. It | 200 | Accessing the raw bytes of the disk or partition is often useful, however. It |
200 | can be used to list all the partitions in a disk, resize partitions, or get | 201 | 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): | |||
253 | root@host:~$ mount /dev/sda1 /mnt | 254 | root@host:~$ mount /dev/sda1 /mnt |
254 | ``` | 255 | ``` |
255 | 256 | ||
256 | With this command, the kernel will try to auto detect the type of file system | 257 | With this command, the kernel will try to auto-detect the type of file system |
257 | (ext4, fat, etc.), and provide you with the files inside that file system under | 258 | (ext4, fat, etc.), and provide you with the files inside that file system under |
258 | the given directory (in this example: `/mnt`). | 259 | the given directory (in this example: `/mnt`). |
259 | 260 | ||