LPI 101-500 – 104.3: Controlling the mounting and unmounting of file systems
July 21, 2023

1. mount, umount

Let’s go back to the last lesson about petitions. With Fdisc we have defined the basic structure of a linux file system, and with mkfs we have installed the corresponding file system. A crucial step in order to be able to use the corresponding petition is still missing, namely mounting the file system. So mounting the new petition in the system. I’ve covered it in other lessons, but here it gets a little more details. Let’s check again which petitions we currently have available. And we can see here SDC One and STD One are two petitions that are fresh, because we can see here that they don’t have any mount point yet, so they are not yet mounted anywhere with mount. To be on the safe side, we can confirm that the two petitions have not yet been mounted. Maybe it was mount and then grab sd.

We can output it a little more clearly. Here you can clearly see that SDC One and sdd One do not exist, so they are not mounted. With the mount command we can mount these petitions, which we use as follows pseudo mount TX four def STC one home monroe new hdd with the option T. We specify the type. Since this is an x four file system, we of course use the type x four here. Next follows the device file of the petition that is devstc one, and finally the mount point follows. And in that case it is home manual new hdd. So the mount point is the location in the file system in which this petition is to be mounted. Now the new petition is mounted and as soon as we access the home manual new htd directory, we access the new petition def SDC One. We can choose here to new htd. And here some data included.

And here we are on the file system dev SDC One. So let me get out here one more word about the type. Mount knows various file types. For example x two, three or four xfs btrfs and so on. These have to be specified in the command as showed. The exception is Cdrom. If you want to mount a Cdrom drive, you enter either t and then cdrom or t and then ISO 9660 as the type. Please keep that in mind for the exam. We also mount the petition devstd one, so pseudo mount with the type xfs. Because we have an xfs file system here on dev sdd One. And as mount point I choose home manual xfs new, for example. And you can see if we specify xfs new as the mount point, it will not work. This is because the xfs new directory does not exist. That means the mount command cannot create directory itself.

We have to do that beforehand. So mkdir xfres new and then let’s try it again. And now it works. Check that we go to xfs new and here we can we are on the file system of devstd one can show that. And it’s blk with the option F. And here you can see SDC One x four file system is mounted now to home manual new hdd and the sdd file system sdd One with Xfs is mounted to home runner xfs new. If we now want to unmount a petition, we use the umount command. Attention. It is called umount and not unmount. Please keep that in mind for the exam. We can execute this command with a device file or with the mount point itself. Both ways are working. For example, pseudo umount def SCD one or with the mount point home final xfs new. We unmounted def STD one, but devstc one is still mounted.

We will check that again with mount grab and we see here defsda five sd One. SDC One is still mounted and sd D one is no longer mounted. Now we are restarting the system. At this point it becomes immediately clear why shut down R now? And I just stopped the video. Until the restart is done. The system is up again. Let’s take a look at the mounts and we see that def SEC one can no longer be found. The mount that we performed manually is not retained after a restart. A manual mount is only valid until the next system restart. Of course, we can also tell the system that the petition should be mounted even after the restart. This is where the etc fstap file comes into play. Because this file contains the file systems that are to be started automatically when the system is started. We will look at exactly how this works in the next lesson.

2. /etc/fstab

As discussed in the last lesson. In this lesson we come to the Etsy Fstap file. To repeat etsy Fstap is the file that contains the corresponding petitions that are to be automatically mounted. At System start we will take a look at that file pseudo bid step. We see a few entries in tabular form here. Let’s take a look at the individual columns. On the far left we see the petition. So there could be for example, the petition def SDA One or dev SDA Five or something else. But in this case the Uuid is here, here and here. Instead of the Uuid the volume name could theoretically also be specified. That is also possible. Next to it we find the mount point here. In this case or here. Here we have the headings file system mount point in that case of devastating five.

With this Uuid it is the Mount point route. Next we can see the file system type, which is x four for this hard drive or for this petition and swap for the swap file. Then we find the options here for the file system, which I will go into in more detail later. The penultimate column with the name dump. So this zero year and this zero belong to Dump specifies whether the corresponding petition should be backed up with a backup program Dump or not. Zero means no backup. So these two petitions are not backed up by a backup program called Dump. The last column with a path here on at zero states whether the petition has to run a system check with Fsck at startup or not. Zero means no system check.

And if a system check is to be carried out, this should be a one.If we have several petitions and all of them should be checked with Fsck, then ascending numbers would have to be stored here depending on the order. Incidentally, this one here does not mean that Fsck is filled in every time the system is started. It just means that an Fsck or Fsck check is possible. It then depends on how the whole thing is set via tune to FS. If it says every three months, then it only happens every three months. If every three months are set in tune to FS but there is a zero here, then a file system check will never be carried out here either. So let’s add our petition dev STC one here.

So we enter on the left our device file or our petition file, a petition path and that is devsed as the second point. We have the mount point here. We would now enter home manual new HDD.The type then follows in the third column. In this case it is x four. Then we have the options here, in which case I write defaults. Then we have the dump value. Since we do not want the petition to be backed up, we take the zero row and finally we have the path value whether fsck should be executed or not. So I would use also a zero here and now I would save this file after another restart. The newly added line in the CFS tab file would result in the petition devstc one being mounted automatically.

We don’t restart the system now, but instead execute the mount command with the A option. This option stands for all and causes the mount command to mount all petitions if they are not already there, which can be found in the Etsy FS tab file. If we now execute the command, we should be able to access home manual new htd immediately afterwards. So let’s try it out pseudo mount a and let me check that with mount and we see here now we have devstc one on home on new htd with the type x four. So the mount worked without us having to explicitly specify a type a, mount point, et cetera. Because this data can already be found in the Etsy fstab file, I open the file again now.

In this Etsy fstub file, every column is basically self explanatory except for the options column. Various options can be set for mounting a file system. For example, the option no auto. If I give a petition in the Etsy FS tap file, the value no auto. This value would ensure that this petition is not automatically mounted despite mount with the option A. The value auto, which is stored by default, ensures that it is mounted. Otherwise you can use options to specify whether only root file systems are allowed to mount or also normal users. This option would then simply be called user. Whether a file system should be writable or read only, there are the terms RW for read write or ro for read only, et cetera.

In our case we have here at the top error errors equal remountro, which means something like if an error occurs in the file system, then unmount the system, remount it, but only with read access. In the main page of mount you can find all the options that mount provides and I recommend at least a look at them. And here below the heading file system independent mount options we found find the options that we can use in the Etsy fstab file. So these are the options async a time no a time auto. You see it can be mounted with the A option no auto can only be mounted explicitly. Defaults use the default options read, write, sued, auto, no user asking and so on and so on.

3. blkid, systemd mount units

In the FCF. Stupid file. As we could see from the Fcsda Five petition, the Uuid of the petition can also be used instead of the device name file name. How do we get the Uuid at all? There are several possibilities. First of all, the already known possibility via lsblk with the option f lsblk with F. And we see here the corresponding petitions the file system type, here the file system type and at this point here the Uuid. It also works with tune to FS with the l option and the appropriate petition. So for example, pseudo tune to FSL and then FSCI five for example. And here at the third place we have the corresponding file system Uuid. Another option that we haven’t seen before is the blkid command blkid without options it outputs the device file name, the UID and if available, a label or a volume name.

You could see here we have no label names here s r zero. We have enable virtualbox guest editions for example. And here we also have the type and lastly the part Uuid, which is not important for us. We have now learned about various ways of manually mounting a petition. We used and edited the file at CFS tab, then mounted everything that is in the Etsyfs tab file with the command mount and the option A. There is another possibility, but this only applies to system D systems. But if you are using a reasonably up to date Linux then that should be a system de system anyway, so it would work too on system D systems. The automatic mounts can also be carried out by system D itself.

System D either continues to access the Etsyf step file or to its own mount units. If your own mount units are used, these are usually created automatically by the system D mount generator, which in turn accesses the Atcfstep file. Assuming we have mounted the petition dev SDC One to the mount point HDD Two. So I changed that in the Etsyfs tab file. Let me show that shortly. And you can see here we have our dev STC One petition and the mount point is Hddv Two. I have used the X 45 systems and I used the same options that the petition DefSec five has. So errors equals remount Ro and with system Ctl we can query the mount status. It works exactly as we know it from before. The first lessons were about systemctl and in this case we are not given a program, but basically just the mount point.

So for example, pseudo system Ctl status and then the mount point is HDD two. And here we get the information that this mount point is active, it is mounted, we get the information when it has been mounted. So five minutes ago we get the information where it is mounted. So HDD two we get the information which device file it is, it is dev SDC One and we can see that system CTF first used the Atcfs tab file and then generated a new file, a mount file which is called in this case HDD two mount. If these informations look different on your system, maybe if there is no hint to at CFS tab file and so on. So it could be that you have just to reload the system Ctl daemon. So just use this one here, systemctl demon reload reload it and you have to enter your password if you forget user pseudo.

And then I think you will have the same information than I have here. Okay, when you want to unmount the file system, you can use the following command pseudo system ctl stop and then again the mount point http. And now the system should be unmounted. We will check that with pseudo systemctl status HDD Two and we see here that it is inactive, that is dead since 12 seconds. And we can also check it with the mount command. And you see here there is no SEC one petition anymore. So if we want to mount it now, again we choose pseudo system ctl start and then the mount point again HDT two. We check it with pseudo system ctl status Hdtwo and it is active again. The type of mounting only works if the corresponding entry can be found in the etsyfstep file, or if there is a corresponding mount unit that you created yourself beforehand.

The mount unit is written by the system, the mount generator itself. As I said, this accesses the etsy fstab file, reads out the corresponding data and creates a corresponding mount file. This is then in the run system D generator directory. Let’s take a look at this directory CD run system D generator and we look at the content. And here we can see that we have a file now called HDD two dot mount. So it was created automatically, I think. So let’s take a look at this file with cat HDD two mount. And here we see the command automatically generated by system Dfstep generator. And here we have our unit. The source pass here source file is the etsy FS tab file. And we have here our mount unit. So where httwdef SDC one type and the options.

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!