LPI 101-500 – 104.2: Ensuring the integrity of file systems
July 21, 2023

1. du, df

In the last lesson, we learned how to create file systems from scratch. The next lessons are about observing these file systems using various tests to keep arrows free, correcting errors, or making new settings. First, let’s look at the command du du estimate file space usage summarize disk usage of the set of files recursively for Directories so Du stands for disk usage and shows us the used space let’s take a look at the total space pseudo duod. We want to know the total storage space from Root and we see what happens. The storage space of each individual file is now listed. We can’t do much with that, so we should use an additional option instead.

In which case it is the S option, which stands for summarize. In addition, I recommend the option H, so pseudo duhs. And then root. And the last line is the one that interests us. Root has 12GB. And of course you can do something with that. In this case, we can also check the size of individual folders. For example, pseudo duhs and then maybe the user folder. And we see this directory has 3. 9gb in size. Another interesting option. Should be the max depths option. With this, we can determine how many subfolders the command includes in its search. This option is intended more so that if you have already identified a directory that is much too big.

That you can then display the individual files and their size. So you don’t have to search in 1000 sub forest but for example, only in the next two or three. Maybe an example pseudo duh and then max depth equals four. And then I choose the home directory. And now the files are listed individually again, and we can further check whether we have a file that is particularly large. We see a maximum of four sub folders here. 1234. And then it is a file 1234. A file 1234 and then a fire. So you will not see five subfolders. Let’s try it out with Mark. Step five and 12345 subfolders. And then you see some more files of course, you could also sort the result. Sort is useful for this.

So we pipe this to sort. And now the files are sorted according to size, with the smallest files at the top and the largest files at the bottom. You see here is a cash file with 47 megabytes. Or this release 41 megabytes. And if we go up, then you see here the smallest file is 4 KB. We already discussed DF in a previous video, so I think I don’t have to say much more about it. To repeat, with DF, we can display the total memory, the used memory, and the free memory of the corresponding petition. So DF the option H and we see. The corresponding volumes. Up here we have Devsta five. It is the size of 12GB. 8. 2gb are used. 2. 6gb are available, so 77% are used.

Another very important option would be the I option. I does not show the storage space, but the corresponding I notes. And here we see the inodes. So we have here 753,000 inodes, 245 thousands are used and 507,000 inodes are free. In nodes are five system entries in the Linux system. The inodes contain various metadata for example, date and time of a file size, permissions and so on. A file system has a certain size and also a certain number of inodes. If you you for example write huge amount of very very small files to the hard drive then it may well happen that no more data can be written, although there is still enough memory available. In that case the innoce would actually be used up.

2. fsck, mke2fs

Let’s look at Ffc next. Ffc stands for File System Check and depending on the default setting, checks the individual petition or the consistency of the file system. It is comparable to the file system check that Windows executes when the system has crashed and is then restarted. The check takes place almost exclusively when the system restarted because only petitions can be checked that have not yet been mounted. If you want to run Fsck during normal runtime, you would have to unmount the corresponding petition beforehand. In the event that errors are found, the user is asked whether the corresponding error should be corrected or whether the error should only be listed.

Let’s take a look at the manual file system check. For this I have prepared another HDD. The petition is the device file devstc one and the mount point is home manual new HDD. So I’m already in my personal home directory, so I only have to switch to new HDD. And you can see I copied a couple of directories, including files into here so that we have some data that can be checked. Let’s see what happens when I run Fsck. The syntax is as follows pseudo fsck and then defsdc one. And we get a warning that Fsck cannot continue because the file system is still mounted. So it doesn’t work. Instead we have to unmount the petition first. We will do that with the following command pseudo umount, devstc one.

And of course this doesn’t work because I’m currently in the corresponding directory which is used by dev STC one, so it cannot be unmounted. I leave the folder now and run the command again. Now it should be unmounted. We will check that with the command mount. Very much to see here. Let’s take a look. Or let’s search for def SDC STC one. Okay, so no STC one here, so it is actually unmounted. Now let’s try Fsck again.And you saw the check now took maybe just a second. That is because the petition is only 1GB in size, that there is only a little data on it, and above all because this is an x four file system or an x four petition. Accordingly, a journaling function is used and the file system checks are massively accelerated.

If we take a closer look at the output, we see that although we ran Fsck, the task was apparently performed by e two fsck. E two fsck is the Fsck for x two partitions. Nevertheless, x three and x four file systems can also be checked with it. And yeah, now we can mount the file system again. Pseudo mount type x four. We will talk about that in detail in another video. And now it should be attached again. How do we proceed? If we want to check our root file system, we cannot unmount root because the entire system is on it. For this we need a so called Linux live CD or Life DVD. So a Linux that can be completely booted from CD. Most Linux distributions nowadays already bring this with them. We boot from the CD, then test the Linux system directly from CD without installing it and via the corresponding terminal.

You can also test the petition def SDA one or Devsta five via fsck. Also in the list of tools and terms we will learn in this chapter is mke two FS. In my opinion, this chapter should have been in the last chapter since we dealt with mkfs among other things, perhaps you still remember when we displayed all tools beginning with mkfs in the ESPN folder. We noticed that some of them are just a link to the mke two FS program. We will look at that again and we see that mkfs x two x three x four are linked to mke two FS. When we created the file system with mkfs in the last lesson, we actually used the mke two FS program. Mke two FS is only be able to create x file systems. So if we want to create an x two x three x four file system, we can use both mkfs and mke two FS. There is no difference here because the same program is used just called differently.

3. tune2fs

With the tool Tune to FS, we can make settings on the file system or change existing settings very briefly. So let’s have a quick look at the man page. Man tune to FS tune to FS adjusts tunable file system parameters on x two, three, four file systems. Roughly translated, it means changing customizable file system parameters on x file systems. With june twofs you can adjust when fsck should be executed. For example, specify that a file system check should be carried out after 100 mounds. So after 100 system restarts, or after how many days, weeks or months a file system check should be carried out with Sfsck. First of all, it would be interesting to know how the file system is currently set. We can of course look at that with Tune to fsudo, tune to FS option L, and then in my case dev SDA Five.

And here we see all information about the petition dev SDA Five. For example, we can see the mount point here. Last, mounted on root, we can see the Uuid. We can see the file system state it’s clean. Here we can see how the file system should behave in an event of an error. So in our case continue. The number of inodes can also be viewed here in the inode count with the entries for mount count. Where is it? Here mount Count we can for example, determine when the next file system check should take place. Or Mount Count shows us how often the petition has been mounted so far. In this case, 18 times. The maximum mount count shows us if we had 20 here, then it would mean that if we had now mounted two times more again a file system check would be carried out because we have here 18 mounts or 18 restarts and maximum count 20.

So two times left and then a file system check would be carried out. The minus one in this case means that the function is deactivated. We change the maximum amount count value, or to set it at all, we use the tune to FS command with the option C. It’s small C. In this case, the option capital C would change the number or the current number, so that max count. So let’s try it with pseudo tune two FSC 100 and then dev SDA Five and Tune to FS gives us a success message. We will check it again anyway with pseudo Tune to FSLA Five and I think we can grab it to Mount Count. And we can now see here that the mount count is still 18 and we have changed the maximum mount count to 100. Alternatively, as I said, we can also specify a time in days, weeks or months after which a file system checks should take place.

Let’s look again at the current status. And the interesting setting for us is this one check interval, which is set to zero by us, which means that now automatic system check is carried out after X days, weeks or months. To set a time we use the capital T or the small I option. The capital T stands for time, so time and the I stands for interval. So for example, we would use pseudo tune two FSI and then 5D FSDA five and 5D stands for five days. The interval between tests is therefore now five days or 432,000 seconds. And it works in the same way. Of course, if instead of D, we use W for weeks or M for months and so on. So please feel free to just play a little bit with the commands, with the options and just try something so that you get familiar with these options.

4. xfs_repair, xfs_db, xfs_fsr

As I said, tune to fs can only be used for X File systems. There are separate tools for Xfs File systems, and unfortunately ffc cannot be used here. Let us first come to Xfs repair. It scans the Xfs File system for errors, checks the concept consistency, and can accordingly repair the errors independently. In order to be able to execute Xfs repair, the file system must also be unmounted beforehand. I have prepared a corresponding Xfs petition, as you can see here. And this will initially hang out from or with pseudo U mount and then defd one. So now it should be unmounted. Yes. Okay. So we can use Xfs Repair in such a way that errors are not repaired, only listed. For this we use the N option pseudo xfs repair n and then FStd one. And here we have some information about what Xfs Repair did.

Without the option N, corresponding errors or various cleanups are processed. Pseudo xfs repair option B, for example, one you can see here. We have the same here as before, but some more information here, so we can see what actually happened. Here we come to Xfsdb, which does not stand for database, but for xfs debug. With Xfsdb you can examine the file system and display various data. Here too, the file system must be unmounted beforehand. And then we can use this command xfsdbdev STD one, and Xfsdb expects further input here. So we could try it with help. And then we get some information and we can see what kind of inputs we could make. For example, with uuid we can display the corresponding udu uid, or with frac we can see whether the file system is fragmented, and with quit we can leave Xfsdb again.

lastly, let’s look at Fxfsr, which stands for File System reorganization. It improves the organization of Xfs File systems, which can be compared to defragmentation in a Windows environment. Here, scattered data on the hard disk are brought together again and correctly arranged, thereby reducing the workload and increasing speed. As an exception, xfs fsr can be executed in a mounted file system. So we first mount the file system again pseudo mount txfsd one with home xfs so now it’s mounted again and we can run xfs fsr devstone. And as expected, nothing happened here, because the file system is new and only has a handful of data on it. But this is how you will do it. The important thing is simply to know what the tool it does and what the tool does, or the tools do, and how to run them.

Leave a Reply

How It Works

img
Step 1. Choose Exam
on ExamLabs
Download IT Exams Questions & Answers
img
Step 2. Open Exam with
Avanset Exam Simulator
Press here to download VCE Exam Simulator that simulates real exam environment
img
Step 3. Study
& Pass
IT Exams Anywhere, Anytime!