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 where 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 Redhat server
or CentOS server, which has
repositories. Now, some companies do
have those repositories local to their
environment, which is called, the
product that holds the repository is
called satellite server. So that is the
repository which holds all your repos or
RPM packages. So you could bring them
back and solid downloads. Now what
happens if you do not have access to the
outside world, or if you do not have a
Redhat 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. Now, just
remember, if you do have an Internet
access to your VM, or your machine, you
don't have to worry about this lesson.
Or if you just want to learn for just
for educational purposes, how to create
a local repository, then please go
through this video. So the command to
create or we will learn in this lesson
it's createrepo, 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 is, it just takes a snapshot
in case we need to revert back or if
something goes wrong, we could always go
back to the snapshot. Click right here says Snapshot,
[No audio]
and click on Take, and it
by default gives the name Snapshot 1,
but you could give 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 local repository and I
need to report back to my original state
which is right now that I could always
come back to it. So now let's go ahead and power on.
[No audio]
Okay, so our machine has
been started. So let's go ahead and become root.
[No audio]
Okay, 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 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 disk this has been
attached. So now we have it attached.
How can we verify it on the command line?
You do df -h, and you will see right
here, the last row tells you that it is
at /dev/sr0 and it is mounted on /run/media/iafzal/CentOS 7.
So now if it is not mounted automatically, then
you go 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 underneath slash make a
directory. Let's call a localrepo.
It's just the name, we've got pick
anything, you will pick seinfeld, george,
kramer, whatever you that you like. So
go ahead and hit enter do ls -ltr
to verify it is there. Yes, the
directory is there. Now I want you to
copy all the contents, so do df -h
to copy all the content of the disk. So
do cd slash run slash media slash iafzal.
Now as you notice, the name of this
ISO image is CentOS space 7 space
x86. Now Linux does not
like spaces. So how are we going to put
that in my path? So if I just put in
CentOS 7 x86_64? See
it says no such file or 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/iafzal. And
when you are at this point on the fourth
directory, subdirectory, then hit tab.
And it will automatically pick the ISO
image under the I have solved directory.
So if you notice, it has backslash
backslash, which is telling Linux that
it there are spaces in it. So go ahead
and hit enter. And now 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 RPM jar.
If you do ls myself here, you'll see a
bunch of RPMs in there. Okay, so if I
wanted to see how many RPMs do I have, I
could do ls minus of your pipe ID, WC
minus l. And it's telling me there are
3973 packages or RPMs that are that are
coming within that DVD ISO image. Well,
that's a lot. So it is kind of like a
repository. So what we're going to do is
you'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 right
packages, run the command d u 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, hit enter is
saying 3.7 game now do d f minus h and
make sure your slash directory has that
space empty Yes, we do have 4.4
available so it's good. So now we could
go ahead with the copying every package
that we have in this location. The
command I would choose to copy is copy
everything from this directory.or You
can specify the full path to run media.
I have solved CentOS packages so you
could do everything asterik 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 report 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 14 180 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 Apt
See ya On da repose dot deep 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
okay, everything is gone. Now go ahead
and create a new repo here, call it
local dot repo and add these values
CentOS seven is just telling me that
these are positive for CentOS seven
name, sent OS seven. Base URL. This is
what matters file slash slash slash
local read local repo. This is the
directory that we created in slash that
will always start with two slashes, then
the third slash will local repo
directory. Enable. And one two if you
want to make it enable 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 303,009 or 71 packages, I'm going
to make them available to my local
machine as a repository. The Create repo
had created the database that will be
available to our jump command. Now go
ahead and create a jump clean, run this
command jump clean all this is going to
clear out any cash from the old
repository. Go ahead and run jump repo
list all 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 Riad, remember and it
telling you the size. The report ID the
center was is the name that we picked
and that RPM dot d directory file. Now
you could test it by running the command
yum install. Now what do we 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 local repository. Now the
system is not 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. So if you are following this,
then go ahead and delete the local repo
repo directory that we created and
revert back to our snapshot. Good luck.
[No audio]