To store files and directories inside a partition.
First, we need to create a file system on it
by default, red hat operating systems use the XFS file system
and
Ubuntu uses the EXT four file system.
So we'll learn how to work with. Both
note that these defaults can change in the
future as they have also changed in the past
to format a partition with the XFS file system.
The simplest command we can use is this
pseudo MKFS dot XFS slash DEV slash S db one.
And as you know, slash DEV slash S db, one is the partition that we're targeting
to create an ext four file system.
We changed the suffix to ext four.
Now MKFS comes from the words Makefile system.
Any file system has settings that we can adjust
with the commands above the default settings would
be used which are acceptable for most purposes.
If we don't want to use the defaults,
we can adjust things with some command-line options.
We can see what file system settings can be changed by reading the commands manual.
Now here I'm typing man, mkfs dot XFS.
By using that dot XFS extension,
it tells us that this is the manual for MKFS specific to XFS.
Now, for example, here,
we can see that we have the dash L option to choose a label for this file system.
But let's see how this should be used.
We press forward slash
then type dash uppercase L to search for this option
and then we'll press N
to find the next one
we see this
here. We see that the label has to be rather short 12 characters at most.
Let's set the label to backup volume.
Let's do a quick listing to see our file systems here.
OK? And we've got several of them here.
But S db is the device that we're going to be working with today.
Note how it shows us the default options that it used to create this file system.
Instead of going through the manual,
we also have a quicker way to look at adjustable file system options for
XFS.
If we write in the command without any arguments,
now we'll complain that no device name was specified,
but it will also show us a condensed list of options that can be used
here. We see we can choose a custom I
node size in an I node.
Things such as file attributes are stored for example, file creation date.
So with larger I node sizes,
we can store more attributes such as extended
attributes which we'll explore in a later lesson
to use an I node size of 512 bytes, we can pass the dash I option.
Ok. And the utility complains here that a file system already exists.
Now,
this is actually good since it can prevent
us from accidentally overwriting the wrong file system.
But if we're certain that we don't need the data on
this partition and we just want to overwrite whatever exists there,
we can force a format with the dash F option.
We can also combine multiple options.
We can force the format set an inode size to 512
bytes and also set the label for the file system.
Now, if we type in XFS and press tab, we'll see a list of
XFS utilities
XFS admin can be used to change things on already created file systems.
Let's say we have one that we labeled wrong.
We can display the current label with the dash L option and it's a lowercase L.
There we go
to change the label. We use the uppercase L as we did with the mkfs command.
Now let's take a look at the other popular file system,
the one that's used by default on
Ubuntu ext four
and we can see the options available for EXT four similar
to how we did it before we type in man,
MKFS
dot ext four.
Now, in here, we'll see a manual for command called Mke two FS.
And this can be confusing at first glance,
but that's the original name for the command
for dealing with EXT file system creation,
at least since EXT version two.
Now we can ignore this discrepancy since using MKE two FS or MKFS dot EXT four,
both point to the same thing.
They both reference the same program and mkfsext
four is easier to remember as a command.
We also have a quick way to see the available
options just by typing in the command with no arguments.
And the usage is very similar to MKFS dot XFS
to create an EXT four file system with default options.
We would type in this
pseudo MKFS dot ext four
slash DEV slash S db two.
And there we go.
And if the file system is already created, you'll get a warning for that as well.
Like say, we try to run it again.
It's going to give us a warning where he says proceed anyway. Yes or no.
So that's a good way to know that you're not overwriting a file system by accident
to pick a specific number of I nodes. We would type in this.
Let's talk about I nodes on ext four. A weird thing can happen.
We can have hundreds of gigabytes of free space
but discover that we can't create any new files.
That's because we can run out of inodes.
Each file or directory uses an I node.
And if we run out of I nodes, then no more files or directories can be created.
Now on a system where we expect to create many small files.
We can choose a large number here
with XFS. We had
XFS underscore admin to change properties of an existing file system.
What utility can we use for? Ext four?
Well, we can open up the manual again
and we'll scroll all the way down to the end
and we'll see ext four related utilities suggested here
and tune two FS is the one that we need
to see the current properties of an EXT four file system.
We use the
lowercase L option.
Now, this same utility is used to change file system properties.
For example, to change the label, we use an uppercase L
and we're going to name this one second FS for second file system.
Now, if we run CFDISK,
we can examine our slash DEV slash S db device and verify
here. We can see the labels and file system types for our new file systems.
Here. We have first FS
which is using the XFS file system.
Here. We have second FS
that's using
EXT four
and I hope that helps. And that concludes our demo on file systems.