In this video, we will learn how to create a new storage partition.
That new storage and mounted on your Linux system.
To create or add a new storage to your Linux virtual machine.
The first thing you have to do is power off your virtual machine and add a new disk for this video.
If you're going to add a two gigabyte of disk from our virtualization software, our virtualization
software is an Oracle VirtualBox.
So I could show you real quick.
By the way, I have already added a disk to save some time.
So here is my Oracle Virtual Machine software.
I go to setting.
And then go to storage and select the controller Zeta and you will see you have your first discovery
added here.
Now, you could add a new disk here, right here, which I have already added by clicking this add new
storage attachment.
But right now you can see it's grayed out because my virtual machine is powered on.
Make sure your virtual machine is powered off in order to add a new disk.
All right.
So once you go through it, it's very simple.
It's a simple visitor.
Just follow the prompts and add two gig of disk and then click.
Okay.
All right.
Make sure also it's good practice that you take a snapshot just in case you make a mistake and you have
to come back again.
And this way you don't lose your virtual machine.
All right.
So once that is done, the next thing we have to do is we will use ported and mount module to run that
in the playbook.
Now, if you have an distribution, the basic one, sometimes it does not come with part, part it and
mount module.
So in that case, you have to install them and in order to install them you will have to run this command
as well.
Dash Galaxy Space Collection Space Installed Space Community General This command will install ported
or part d module for you.
Then you would run similar command ansible galaxy space collection, space install and this time ansible
pos pos.
This will install your mount module.
All right.
So if you do not have part or mount module, then you define these modules and your playbook.
Then most likely you will get an error which going to be like this error couldn't resolve module action
mount or module action ported.
This often indicates a misspelling, mis collection or incorrect module path.
So if you're getting this error message, it means you have to run these two commands.
Now, I have already taken the liberty and ran these two commands in my Linux control node, my Ansible
control node and I do have ported and mount modules.
All right.
So once that is the basic requirement is done, then we'll go ahead and create our playbook, which
will create our partition and then mount that partition to our directory.
Let's see how it's going to go.
All right.
Here we have a playbook.
We'll create a playbook with the name new storage.
YAML will define that.
It's a YAML file.
We'll define the name, create and mount new storage.
All right.
Host Okay, it is right here.
It says all, but we will create that on local host so you could change that while you're writing it.
Then we'll define the tasks and the task.
The very first task of this play is to create a new partition and to create a new partition.
We will be using new module which is ported.
Now once that module is defined, then you have to define the parameters, which is name what will be
the name.
Is this the file or is a swap file?
What is that?
It's files because we will be using that for a file system then label.
We have to define label as GPT.
This is the label for our partition table, not the file system label.
Then the device slash dev slash SDB.
Because when we added the new partition through our Oracle virtual box, it created a new disk and the
new disk is slash dev slash SDB.
I can show you right now.
I'm logged into my control node through a putty client.
If you do not have a putty client, you could actually just go simply to the Linux console, the Ansible
console.
All right, so if I do f desc minus L, you will notice that it has the main disk slash def slash SDA,
which is 20 gig and it has two partitions as to one and ACA two.
Now, when I added a new storage from Oracle VirtualBox, it gave me this new disk dev SDB and its size
is two gig.
That's the one I specified.
All right, good.
Now, let's go back to our playbook, then.
We have to start with the device number.
So we wanted to give it the partition number as SDB one.
So we have to specify number one, the state present.
Of course, we don't want to create it.
So we are creating with the present.
If you want to delete it, then you will do absent or part.
Underscore start the number you wanted to start.
This is the size of your partition.
You'll start with one megabyte and you end with one gigabyte.
Now if you wanted to use the entire two gig of space, you can, but you cannot specify exactly to gigabyte.
You have to be some a few numbers below it because some of the storage is needed to create this partition.
So anyway, just for the purpose of this lab, this video, I'm just picking one gig out of that two
gig.
All right.
Now, this this task or display within that task is going to create my new partition.
Now, the next task.
All of this play is to create a ZFS file system.
Now the partition is created, so now we have to define that this partition is ZFS.
For that we'll use the module file system.
The file system module is used.
Then you have to define the device.
Where are you putting that XFL file system?
You're putting it in dev SDB one, the partition we created in the earlier task and then the name of
the file system FS type ZFS.
If you're putting in, let's say SD four, then you put it down XD for here.
All right, then task three, then create mount directory.
Now of course, once the partition is created, it's labeled, it has a file system ZFS.
Now you have to mount it somewhere.
Now in order to mount it, you've got to have a directory that's already created, or you could create
it within this playbook.
So we'll create it in this playbook and we'll use the module file.
The path is slash data, state is directory because you always mount file system on a directory.
Then the fourth one is a mount.
The actual def file system for that will use the module mount.
The source will be slash def slash SDB one and the file system type we will be x FS.
These are parameters that you have to specify and the state mounted because that's what you want to
do and the last thing you will do is we will run this playbook.
All right.
Let's go right into our control node.
That's where we are creating this playbook.
So as I said, I am logged in through putty because this way it will give me a bigger screen.
Let's clear the screen once again.
If you do not have putty or you do not know how to log into putty, you could just simply go to your.
Control node through gooey right here.
This is the Google login and you could do the same thing over there from the console.
All right, here.
I'm logged in as ID root.
Which directory?
Amen.
At console playbook.
That's where I'm keeping all my playbooks.
All right.
I have already created this playbook earlier to save some time.
So let's go over it and see how I did it.
So, bam, I named it new storage hit enter here.
You notice I put it in local host, so make sure you put local hosts.
But anyway, if you wanted to create that same partition to your client, you could do that.
But of course, then you have to create or add that storage to your client, not to your control node.
All right, then we come down to task.
The first task is create new partition.
We already covered that.
Everything is defined, make sure the indentation is set up correctly, then create XFL file system.
File system is the module and the device is dev SDB one and FS type is ZFS.
Now we'll create the third one to create Mount Directory.
It will create the path in slash data and the state is to create, not file actually directory.
And the last one is to mount the file system.
Beautiful.
All right, now let's go ahead and save it.
Okay.
And by the way, this news story, diameter file I have already uploaded in the handout.
So you could just simply download that and copy that over to your YAML file or into your Linux machine.
All right, now it's time.
A moment of truth.
Let's run the command.
But by the way, before I run the command, you notice once again F disk minus l you notice this disk.
The one we are going to partition does not have any partition.
Once we do the partition, you will see the partition right here.
Also another thing, let's clear the screen D minus H, which will give us all the disk partitions mounted.
You will see it does not have SDB mounted and neither it is mounted on any data and we do not have data
created either.
So it will do it everything for us.
So let's clear the screen and run the command.
Ansible dash.
Playbook.
Neo Storage.
Enter.
Right.
Create and mount storage.
This is the name of the playbook.
Going to a local host.
Local host, create XFL, done, create mount directory, done, created the created mount the file
system.
Done change.
Beautiful.
Excellent.
So it worked.
We didn't get any error messages.
So now let's confirm it.
Let's clear the screen.
Let's do F disk first to see if it created the file system.
Yes, it did.
Right here.
So you see, this was the storage and this is the partition SDB one, and it is created size 1023,
which is almost one gig.
Now let's see if it has created a directory.
So we created a directory in slash.
So let's do ls minus l t r.
The worst order to see it created the data director.
Yes, it did look right.
So now let's clear the screen again.
Let's do DF minus H to see if it mounted.
That's the biggest thing.
All right, beautiful.
It did mount right here.
The SDB one is mounted on data, and the last thing will verify.
Did it create an ZFS file system for that will do DF minus T and right here tells you the device is
dev SDB one.
The file system type is ZFS the size and it's mounted on slash data.
Excellent.
So if you have followed it through, perfect.
If you're getting error, just make sure you have correct indentation.
Everything is typed correctly and you will be able to create and mount new storage.