Hi.
So now this is the topic about creating a local repository from your DVD.
Now.
What is a repository?
A repository is something where all your packages are stored and then you could download and install
the package that you wish to.
Now you do need an internet access to go out of the outside repository and download and install the
RPM.
But what if you do not have internet access?
That's what exactly the local repository comes in.
So you have a Linux machine, right?
Whether it's a virtual or physical machine doesn't really matter.
It goes out to the Internet and then it goes out to a server, which is also most likely a Red Hat server
or CentOS server, which has a repository.
Now, some companies do have those repositories local to their environment, which which is called the
product that holds the repositories called satelite server.
So that is the repository which holds all your repos or RPM packages.
So you can bring them back in solid downloads.
Now, what happens if you do not have access to the outside world or if you do not have a red hat satellite
server in your environment, then how are you going to install new programs?
Well, in that case, you create a local repository within your server.
So this is what we're going to learn in this lesson on creating a local repository.
So the command to create or we will learn in this lesson it's create repo.
That's just one simple command.
So how does it work?
So let's get into our Linux machine.
My virtual machine is powered off.
Now I want you to go ahead and create a snapshot.
What snapshot does it's just takes a snapshot in case we need to revert back or if something goes wrong,
we could always go back to that snapshot.
Click right here, see the snapshot and click on take.
And it, by default gives the name snapshot one.
But you could give the the date or anything that you like that will make you remember.
I like to pick, date or sometime times if I'm creating multiple snapshots.
So now it has created a snapshot.
So in case I mess up during this creating log repository and I need to revert back to my original state,
which is right now, then I could always come back to it.
So now let's go ahead and power on.
So our machine has been started, so let's go ahead and become root.
So now you are creating a local repository.
So what you're going to do is you're going to take all the RPM, all the packages from your DVD or CD,
CD ROM drive, which is a disk which has all your packages.
So what you do is you go into these menu devices, optical drives, choose disk and pick CentOS ISO
image.
So I have it saved on my desktop, so just choose it and click open.
So now this should automatically mount your DVD to your Linux machine.
See right away.
A pop menu came up and also if you notice, it will also create an icon on your desktop saying this
is the disk that has been attached, so now we have it attached.
How can we verify it on the command line?
You do DF minus h and you will see right here, the last row tells you that it is at sr0 and it is mounted
on run media CentOS seven.
So now if it is not mounted automatically, then you could run a command mount slash dev, cd rom and
wherever you want it to be mounted anyway since it's already mounted for us.
Now the next step is where are you going to put all your packages?
So you have to create a directory, right?
So the directory I'm going to pick is let's go to slash, CD, Slash and under slash, make a directory,
let's call it local repo.
It's just the name.
You could pick anything.
You can pick Seinfeld, George Kramer or whatever you that you like.
So go ahead and hit enter do a list minus TR to verify it.
Is there.
Yes the directory is there.
Now I want you to copy all the contents to do the message.
Copy all the contents of the disk.
So do CD slash run slash media slash I.F. So now if you notice the name of this image is sent to us
space seven Space S 886.
Now Linux does not like spaces, so how are we going to put that in my pad?
So if I just put in cent OS space seven x 86 underscore 64, so it says no such file a directory.
Then how how can I make Linux understand that there are spaces to do that?
The best thing that I would tell you to do is do CD run media of soul.
And when you are at this point on the forth directory subdirectory then hit tab and it would automatically
pick the ISO image under the self directory.
So if you notice it has backslash backslash which is telling Linux that there are spaces in it.
So go ahead and hit enter now and you are in that directory.
Do ls myself here and see what's inside of it?
You see there are a few directories and files CD into packages.
That's where all the rpms are.
You could do it as myself.
Here you will see a bunch of rpms in there.
So if I wanted to see how many rpms do I have, I could do it.
S minus l tr high bit wc minus l and it's telling me there are 3973 packages or RPMs that are that are
coming within that DVD image.
Well, that's a lot.
So it is kind of like a repository.
So what are we going to do is we're going to copy all of these packages to our local drive, that local
folder that we just created, and the folder name is local repo, right?
So now before you do that, also make sure that you have enough space in your Linux machine.
So how do you find out first you are in that directory, write packages, run the command du minus s,
h and dot which telling it which asking the Linux machine give me this disk space of the current location
of the directory that I'm in.
It is saying 3.7 gig now do DF minus h and make sure your slash.
Victory.
Has that space empty?
Yes, we do have four four available.
So it's good.
So now we could go ahead with copying every package that we have in this location.
The command I would use to copy is copy everything from this directory.
DOT Or you could specify the full path of run media.
I also sent OS packages so you could do everything asterisk because you're copying everything under
packages to your local repo.
Hit enter.
Now it is going to copy every single rpm to the local repo directory.
This is going to take some time.
If you open up another window and then you go to CD to local repo and do ls minus l pipe it to wc minus
l, you will see the number of files being copied.
So right now we have 1480 files that have been copied.
We have to go up to 39 and something files to be copied.
Okay.
All the RPMs have been copied successfully.
Very good.
So we have to tell Linux.
Don't go outside.
We do have all the packages locally, so how do we define that?
So there are files in etsy yum dot repos dot.
These are all the files that tells the linux to go to these different mirrors.
So what are we going to do is we're going to remove everything in here.
Now, again, before you remove that, please make sure you do have a snapshot.
If you delete all of these packages and you do not have the snapshot, then you won't be able to go
to internet and download the packages through Yum commands.
Everything is gone now.
Go ahead and create a new repo here.
Call it local repo
and add these values.
West seven.
It's just telling it.
These are positive percent to seven name sent over seven base URL.
This is what matters.
So file slash slash slash local re local repo.
This is the the directory that we created in slash.
It always starts with two slashes, then the third slash with local repo directory enabled and one if
you want to make it enabled.
GPG check zero.
These are some of the default values you have to put in to that file.
Go ahead and save it.
Once that is saved now we'll run the command create repo.
And where is my repo?
Local repo.
You hit enter now it's actually what it's doing is it's actually going to that local repo directory
and it's saying, hey, I have three 3979 one packages.
I'm going to make them available to my local machine as a repository.
The Create Repo has created the database that will be available to our jump command.
Now go ahead and create a yum clean run.
This command to jump clean.
All this is going to clear out any cache from the old repository.
Go ahead and run.
Yum.
Repo list all.
Now, this should tell me my full list of repositories.
There you go.
So we have a repo list that has a total package of 3971.
These are the exact same number of RPMs we had, remember?
And it telling you the size, the repo ID, the centos is the name that we picked and that our RPM directory
file.
Now you could test it by running the command yum install.
Now what do you want to install?
Just for test type tomcat.
It's going to go into their repository and check if it has a packages that matches tomcat.
Okay.
Perfect.
It did find that package.
And this is basically how you create a log repository.
Now the system is now going out on the Internet or to your red hat satellite.
It is actually going to your local repository, which is sitting within your Linux machine.