When working on new Linux skills (or, as I was, studying for a Linux certification), it is helpful to have a few virtual machines (VMs) available on your laptop so you can do some learning on the go.
But what happens if you are working somewhere without a good internet connection and you want to work on a web server? What about using other software that you don't already have installed? If you were depending on downloading it from the distribution's repositories, you may be out of luck. With a bit of preparation, you can set up a homelab that will allow you to install anything you need wherever you are, with or without a network connection.
The requirements are:
- A downloaded ISO file of the Linux distribution you intend to use (for example, CentOS, Red Hat, etc.)
- A host computer with virtualization. I use Fedora with KVM and virt-manager, but any Linux will work similarly. You could even use Windows or Mac with virtualization, with some difference in implementation
- About an hour of time
1. Create a VM for your repo host
Use virt-manager to create a VM with modest specs; 1GB RAM, one CPU, and 16GB of disk space are plenty.
Install CentOS 7 on the VM.
Select your language and continue.
Click Installation Destination, select your local disk, mark the Automatically Configure Partitioning checkbox, and click Done in the upper-left corner.
Under Software Selection, select Infrastructure Server, mark the FTP Server checkbox, and click Done.
Select Network and Host Name, enable Ethernet in the upper-right, then click Done in the upper-left corner.
Click Begin Installation to start installing the OS.
You must create a root password, then you can create a user with a password as it installs.
2. Start the FTP service
The next step is to start and set the FTP service to run and allow it through the firewall.
Log in with your root password, then start the FTP server:
systemctl start vsftpd
Enable it to work on every start:
systemctl enable vsftpd
Set the port as allowed through the firewall:
firewall-cmd --add-service=ftp --perm
Enable this change immediately:
Get your IP address:
(it's probably eth0). You'll need it in a minute.
3. Copy the files for your local repositoryMount the CD you installed from to your VM through your virtualization software.
Create a directory for the CD to be mounted to temporarily:
Mount the install CD:
mount /dev/cdrom /root/temp
Copy all the files to the FTP server directory:
rsync -avhP /root/temp/ /var/ftp/pub/
4. Point the server to the local repository
Red Hat-based systems use files that end in .repo to identify where to get updates and new software. Those files can be found at
You need to get rid of the repo files that point your server to look to the CentOS repositories on the internet. I prefer to copy them to root's home directory to get them out of the way:
mv * ~
Then create a new repo file to point to your server. Use your favorite text editor to create a file named network.repo with the following lines (substituting the IP address you got in step 2 for <your IP>), then save it:
[network] name=network baseurl=ftp://192.168.122.<your ip>/pub gpgcheck=0
When that's done, we can test it out with the following:
yum clean all; yum install ftp
If your FTP client installs as expected from the "network" repository, your local repo is set up!
5. Install a new VM with the repository you set up
Go back to the virtual machine manager, and create another VM—but this time, select Network Install with a URL of:
If you're using a different host OS or virtualization manager, install your VM similarly as before, and skip to the next section.
6. Set the new VM to use your existing network repository
You can copy the repo file from your existing server to use here.
As in the first server example, enter:
cd /etc/yum.repos.d mv * ~
scp email@example.com.<your IP>:/etc/yum.repos.d/network.repo /etc/yum.repos.d
Now you should be ready to work with your new VM and get all your software from your local repository.
Test this again:
yum clean all; yum install screen
This will install your software from your local repo server.
This setup, which gives you independence from the network with the ability to install software, can create a much more dependable environment for expanding your skills on the road.
Bob Murphy will present this topic as well as an introduction to GNU Screen at Southeast Linux Fest, June 15-16 in Charlotte, N.C.