LPI 101-500 – 104.1: Create partitions and file systems
July 22, 2023

1. File systems, fdisk part 1

This lesson is about different file systems and how to edit them with various tools. Let’s first take a look at the individual file systems. A file system defines the framework for how data is organized on a hard drive. Or another data carrier, saving files, searching for files, saving metadata, data path, date of manufacturer and so on. All these are things that are regulated by the relevant file system. Maybe you are familiar with Fat Fat 32 or ntfs from the Windows environment. In Linux there are various file systems, some of which are very similar, but some are also very different. The best known and probably most common file systems in Linux are x two, x three.

And x four. The X Two file system used to be the standard file system in Linux because it was very secure and very robust. XD Two was later replaced by its successor, XD Three. The big difference between these two file systems is that after a system crash or a hard reset on x two file systems, a time consuming check of the file system followed in x three a so called jeannallion function has been integrated. Which means? That before data is saved, the metadata first. For example, creation period or path of the files can be saved in the Jeannalin system. So if the system crashes, jeannalling can detect whether or not all data has been saved. And if not, which data is still missing.

A complete check of the file system is therefore no longer necessary. In principle, x three is nothing more than an XD two file system with an added journaling function. Accordingly, you can create an XD Three petition in two ways once directly as X Three and once as X Two, with the Jeannalin option. More on that later. X Four is in turn further development of x Three, which is characterized by the fact that file system checks only run faster and that the main memory is integrated differently. Xfs is a file system that also offers geniling functionality and is known for its high speeds and is also very major. And stable. In the desktop environment, xfs is used but rarely, but more often.

For example, on nest devices Vfat is an extension of fat 16 or fed 32 and actually refers to how the file system is, but fully. Supported by Linux. Finally, there is also Xfat, which is also based on Fed, but was developed exclusively for flash memory at the time and is therefore rarely found on normal computers or servers. Last but not least, there is the Btrfs file system. Btrfs has what it takes to replace the standard x three and x four file system as it breaks some restrictions that x file systems still have. Btrfs can, for example, manage a maximum of 16. Expabytes and snapshots can also be created directly with Btrfs.

It is a so called copy on write file system, which means that the copy of a file is only created when this copy is changed. What does that mean? Assuming we have a text file and copy it to another folder, this copy of the file is only created virtually and not written to the hard desk. Only when something is changed in the text file, the copy is actually made. A rate system is already integrated in Btrfs systems, the Btrfs Tools. So the package with Btrfs tools comes with the so called Btrfs convert, with which an existing x three or x four petition can be converted to Btrfs. Further advantages of Btrfs over other file systems would be, for example, more efficient storage of small files, dynamic inodes or multiple sub volumes that are possible.

There is data compression, file system check and defragmentation possible during runtime. Checksums are created and data backups are also possible. If we now become a little more practical, let’s first take a look at Fdisc, which stands for Fixed Disk and is a command line program for petitioning hard disks. Fdisc can only be executed with root permissions. In order to be able to use Fdisc in practice, we still need a few virtual hard disks which we first have to create. Briefly, we do the whole thing in the virtualbox settings. I also have to shut down the system once so that I can make these settings. So I will shut down. I am now in the Virtual Business Manager.

This is here my ubuntu. This is the operating system what I use all the time. And here we just have to add three hard drive. So we take that here and click once on Change. Sorry, this is only German language, the Virtualbox Manager in my case, but I think in English language it will be the same icon and it should be the word Change. So click change. And on the left please click on Mass Storage or Storage. And then you can see your mass storages. Here you have your EDI controller with your virtualbox guest editions. And then you have your Theta controller with your 12GB hard drive. So in my case it is 12GB. And here we have to add three more hard drives.

So please just click here on the symbol, the disk symbol and the plus. And then you can choose Hard drive here at the bottom and maybe you see it. I have prepared already three hard drive. Let me just show you how I have done this. You only have to click on the second icon. It means create. Then please just leave that Bdi next dynamic next. And then please just choose a hard drive size of 1GB. It is enough. Create. And then you see here, we have now a new hard drive. You see, these four hard drives are not attached. So please just click this one that you have just created and click here on choose. And now you see it is listed here.

So here again at the plus symbol and choose the second one choose and another time. The third one. Choose and you see. Here we have our twelve gigabyte hots disk. And we have 1GB 1GB, 1GB and that’s okay. So just click OK. And now we can start our system again. Okay, we can now use Fdisc to check which petition we have installed and which hard drives. Do not have a petition yet. Fdisc must always be used with pseudo rights and the option L lists the petitions accordingly. So pseudo Fdisc and the option l. Here we have the loop editions. That is not important for us. Here we have Devsda with 12GB. This is the disk on which our system runs.

Now we have a Dev Sdb with 1GB, devstc with 1GB and Devstd with one gigabytes. So these are the three hard drives we just added. We can also read some details here. For example, the disk model name, the size invites the sectors and the IO size, the disk label type and so on. Here in this case with Devsda we can see we have a disclaimer type dos. And we have here our three partitions. And here we have so called boot flag. So we know that on this petition there is our bootloader installed. And on our new hard drives there is of course nothing installed yet. So they are not partitioned yet. And we will do this in the next video.

2. fdisk part 2, mkfs, mkswap

Okay, so let’s access one of these new hard drives with Fdisc and that goes with the following command pseudo Fdisc and then in this case, for example, devstb So, or second hard drive. So Sdb is the next free hard disk and we get the message that there is no petition table, so nothing at all. And we can already see that Ft is an interactive program that requires further input from us. The M key takes us to help, which is actually very useful. Here you see here command M for help. So let’s press M for the help. And here we can see what we can do with Fdisc. And since we want to create a petition right away, let’s see the known file system types. This is the L key. So here you see it l list known petition types. So let’s press L.

And here we see all the file system types that are available, and number 82 and 83 that are the most interesting for us. 82 is used for Linux swap petitions, and 83 is generally used for Linux petitions. Let’s create a petition. We will look at the help again with M and we see here with N we can create a new petition. So let’s press N. And now we are asked if it should be a primary or an extended petition. We will take a primary petition. So p it is the default value, the petition number. Since it is the first petition on the hard disk and will remain the only one, we take the number one first sector. The first available sector is 2048. So let’s choose that. I just press Enter, because this is the default value. And the last sector is here, the last sector of the disk.

So we want to create a partition on the whole disk and I use the default value. And now we get the message that a new petition of the type Linux with the size of 1023 megabytes has been created. It is important to know, very important to know that contrary to the message here, no petition has yet been created, because a final step is still missing. To create this petition we have to press the W key, which in this case stands for right. You see it here in the Help, save and access w write table to Disk and Exit. So everything we have just done should now be finally written to the hard disk and we press accordingly W and the program is exited at the same time. And we have also received the information.

The petition table has been changed and the hard drives are synchronized with Fdisc. We now check whether the petition was actually written. So pseudo fdiscl. And we have just edited the hard drive DevST Sdb. And here we have our dev Sdb. And here we can see this table, which was not there before. So the dev Sdb one is the first petition of this hard drive. No boot flag is set here because the disk is not being used for booting. We have the beginning for the start size starts x sector size and the end sector size. We have here the size 1023 megabytes. We have the ID 83 and the type Linux. So as you remember, we have not specified the type explicitly, so it was selected that way by default.

So we have created a petition with fdisc, but it is not yet usable because the file system is still missing. In principle we only built a shell, so not the Linux shell shell and we still have to insert the appropriate file system into this shell. We can create this with the program mkfs. The program mkfs stands for make file system and is located in the folder sbin because of course only root is allowed to run this program. So let’s take a look at that folder. So we need pseudo rights for that Aspen and we are looking for mkfs and we see that there are several mkfs programs here. We also see that some mkfs programs are linked to another program named mke two FS. So you can use mkfs or directly mke two FS.

In the end it’s the same. Assuming we want to equip the petition that has just been created with the x four file system here, we could then choose the following command you see here mkfs four x four so we could choose pseudo mks x four and then devsdb one we choose lastly the petition we just created and that would be one possibility. The second possibility is we can use the option t for type with mkfs, for example pseudo mkfs. So we are using this program here, not this one, but this one. So FKFS with the option t for type and then we are choosing x four and then devstb one. So this is basically the same with this way of writing. It is automatically used on this program MKVs x four. Now we get some information.

The file system is created inode, tables are created, the genre is created and so on. So everything seems to be done. We can check this with lsblk, which shows us hard drives among other things. And we should use the option f, because option f shows us the corresponding file system. So lsblk with the option f and here we have Sdb one and the x 45 system. That means the hard disk is ready and could theoretically be used. Now let’s look at another example. We are now using the still untouched hard drive def SDC, so pseudofdisc defst and recreate a new petition again with the N maybe for repeating here we have the n add a new petition so n we want to have a primary petition, we want to have the petition number one.

We want to have the default first sector and we want to have the default last sector and we press now W for right and thus the file system framework would be ready this time. We want to install an x three file system, of course, but in our case we use mkfs x two now and tell the program that it should also use the zhongnalin function to recap. X three is actually an x two file system with additional journaling. Accordingly, we can use pseudo mkfs x two with the option j for Jola Jonaling and then dev SDC one. And the option j ensures that the jeannalin is written. Done. We will check that again with lsblk and the option f and the result is that we see SDC one has the file system x three, although we have formatted it with x two.

But since the option j has been added, it is basically an x three file system for jeannalin. What happens if we use mkfs without any additions? So without explicitly telling the program which file system to use so let’s try it out. I have already prepared the hard drive dev sdd with fdisc, so we don’t have to do that again. And now I choose pseudo mkfsdef STD STD one. So the tool did something without asking any questions. Let’s see which file system he used LS blk with f and we see he wrote the x two file system. So that file system is the default unless the program is told otherwise. We have now filled all three hard drives that we have newly created with the file system. And we would like to delete the corresponding file system again, so that we can now carry out further tests.

We can do that with Fdisc as well. So we want to delete the last hard drive, the devstd so pseudoft disk devstd and we are choosing again the m for help. And let’s search for something like that. D delete a petition so I press deep and here selected petition one. Petition one has been deleted. We are not asked which petition we want to delete, as there is of course only one petition here. But the petition isn’t deleted yet. We have first we first have to press W for right? To actually delete the petition afterwards. So that’s it. We will do the same with the other two hard drives. So pseudo fdiscd for delete and W for right? And then again with STB delete, right? So the hard drives are now empty again.

In order to create a petition with Btrfs or xfs, packages may have to be installed later. For xfs this would be for example, the xfs Prox package, and for Btrfs it would be the Btrfs tools package. So let’s install them. First of all, pseudo apt install xfs Prox.  In my case it’s already installed. And then pseudo apt install btrfs tools and here this is something new. Before. In ODA ubuntu versions, the name was Btrfs Twoids. So please try it if it fits in your case. If not, then please try pseudoaptinsel btrfs prox. So that’s the new name in my case, and that works. So let’s look again at our spin folder, mkfs. And here we have now this new one mkfs xfs and the creation of the petition works the same way as with the X Petition.

And we have now also mkfs btrfs. And it works in the same way as with the X Petition. So now we want to create a swap. Petition. The whole thing works a little differently. For this we have to use Fdisc a little differently. We take the hard drive sdb so pseudofdiscdefsdb and first let’s do it as before.So we press n for a new. Petition. We press P for a primary petition. We press one for the first petition and we choose the default first sector and the default last sector. And here we have the message that the signature still exists and whether we want to remove it here we say yes and we get the information that the signature will be removed by the right command.

We have now done this accordingly. But now we have to change the file system type. We look again at the help and here there is where is I’m looking for the tst change a petition type as a reminder if we do not explicitly specify a petition type then type 83 linux is used automatically. In that case we have to change it to the Linux Swap Petition so I press T and now we should write the hexa code type l to list all codes so I type the capital L and here I have all codes again and I think code 82 is the right one for us so I choose 82 change type of petition Linux to Linux Swap so that’s correct and now I press W for right and that’s it. With Pseudofdiscl. Let’s check whether everything fits.

Here the hard drive dev Sdb one and we see here type linux swap ID 82 so everything’s correct. We now have to add a so called swap file system. This time it doesn’t work with mkfs because there is its own tool and it’s called mkswap. So make swap. It stands for Make Swap. We do the following screen. First pseudo mkswap and then devstb one. And we have here setting up swap space. Version one, size 1GB, no label. And this uuid. Now the system must finally be integrated into the system. This swap space has to be integrated into the system. So we have to tell the system that a swap petition is to be added.

This actually works with a Swap on command. If we use swap on without an option, then swap on shows us the current swap petitions and files and we see it only has the result swap file with 544 megabytes. But it doesn’t have our petition that we have just created yet. Accordingly, we have to include it. We go along with that pseudo swapon and then devsdb one and then again swap on. And now we see. We have also the swap petition to permanently mount the new swap petition. We have to add it to the etsyfs tab file, but we’re we will look at that in a later lesson.

3. gdisk, parted

We have now gone all the way to make a new hard drive usable. The petition or the basic petition structure is created with Fdisc and the file system is written with mkfs. There are still alternatives to Fdisc, in this case Gdisk and Parted. Let’s take a look at Gdisk first. It looks similarly to Fdisc in that it is also interactive pseudo Gdisc def SDC for example and here we get some information petition table scan font invalid GPT and so on. With the command question mark we can get help and again it is very helpful for us. So I press question mark and then we see our options. We want to create a new petition and here it’s the same it’s N. So I press N for a new petition, then I have to use the petition number.

I choose one. I have to choose the first sector I leave it to default 2048 and the last sector number I leave it to default and now I have to enter the hex code or Guid capital l shows the codes type search string or Enter. To show all codes I just press Enter and now I have all the codes and I would use this one 8300 Linux file system. So I first use Q for quit and now here I use 8300 changed type of partition to Linux file system and just like with Fdisc we also have to use the W wants at the end of an operation to confirm that the data is actually written. Final checks complete, about to write GPT data. This will override existing petitions. Do you want to proceed? Yes, we want to and the operation has completed successfully. We check whether everything was written correctly.

We can use for this pseudo Gdiscl and then defstc and here we see number one sector, sector size code enter the name, the name of the code Linux file system. So everything is fine with Gdisk. We can of course delete petitions too. So let’s try that pseudo Gdiscdef SDC question mark for help and we can choose now again the D for deleted petition using one it’s also automatically and then we have to use one W for write final checks complete. This will override. Do we want to proceed? Yes, and the operation has completed successfully. Now the petition is deleted. Okay, now we come to Parted. With Parted you can also create petitions and even change them later. There are still essays for Parted, namely G parted or QT parted.

While Parted is a pure command line tool g parted and QT parted are graphical interfaces four parted. However, we will not look at the graphical interfaces in this course as they are irrelevant for the exam. With Parted we can also display the individual petitions and it works in a similar way. So pseudo parted l and we see here devsda with petitions number one, two and five. We have here petition devastb with petition number one. And we have here dev SDC and devstdb with no petitions at this time. So now let’s create a petition with parted on devstc so pseudo partedc. And here too it is interactive. In this case we can use the word help to display further help. So let’s try that help. And here we see our options. It’s a little bit different from the other two ones.

And here maybe that’s interesting for us. Create a new disk label petition table MK label with MK label we can create a corresponding petition table. We can find out exactly how MK label works with a further help command. For example with help MK label and here we can see which so called label types are available. And in contrast to Fdisc or Gdisc, there is no Linux type. Here the label type Ms Dos is used for Linux petitions at parted. So we will create a label like that with MK label and then Ms Dos warning the existing disk label on devstc will be destroyed and all data on this disk will be lost. Do you want to continue? Yes, we want to continue and yeah, that’s it. Now, to create the file system, we use the MK part command. So with help MK part, we can see what the command is all about.

We want to create a primary petition. So we type mkcart primary and now we are asked for the file system. Type x two is also standard here and in that case we would choose now Btrfs. At the start we give a zero and at the end maybe 1000 megabytes and we ignore the warning and the corresponding petition is ready. With print, we can check it all over again. So print and here we see the petition data. We have petition number, the size, type, primary file system, Btrfs. And yeah, of course we can also delete petitions with parted, in which case we choose RM and we are asked for the petition number. This is one, and accordingly it should now be deleted. We can check it again with print and the petition is really deleted.

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!