Setting up an environment

So, in order to have a vanilla environment where I’ll get to play around and have to configure most of the stuff myself (in order to force myself to learn), I decided to install CentOS 7 in a virtual machine. This will give the added benefit of keeping snapshots so that in case I get locked out of the linux box, I’ll be able to just revert to a previous snapshot. Of course, I could use a filesystem that supports snapshots itself, however I don’t want to. 😛 That’s something that I would like to learn on the distant future, so, point and click snapshots for the time being.

Currently, there are various packages installed on my Mac that I can’t even recall, mostly via homebrew, and I don’t want to uninstall them as I pretty much depend on them for my day to day development work. To complicate things a bit, Apple provides their own versions of various command line tools that may or may not provide the same features as their GNU equivalents. So, the decision to start with a clean OS is really lack of other options.

I decided to go with CentOS as it’s based on the RHEL, which means the documentation of one pretty much applies to the other, unchanged. Furthermore, CentOS is very popular among hosting companies as it gets the same long-term support releases as RHEL.

I should note here that I currently have installed Arch Linux in a Cubox-i4pro as well as Debian and Mint installations lying around in various virtual machines. While I’m not using them and I will not be using them for the purpose of my day to day learning, I will be trying/comparing various things eventually.

Creating a virtual machine

Nothing special to note here. I’ve just created a virtual machine in VirtualBox with mostly default values. I’ve set the type to Linux, version to Red Hat (64-bit), base memory to 512MB (I decreased it from the recommended 768MB as I don’t have much spare on my system), 1 processor, 8MB of video memory and 8GB VDI virtual disk. Now, I don’t really know what the other virtual disk format are exactly, I don’t really care for interoperability so I just went with the default. I also disabled audio support (no point having it).

Now, I need to decide about networking. As the virtual machine will be living in my laptop, I need to be able to access it no matter what network I am connected to. Day to day, this means I have to be able to easily connect from my Mac’s (host) terminal to my CentOS (guest) ssh service, in a consistent way, without having to have to look around for the guest’s IP address, since I move from my house to the co-working space that I work from. The VirtualBox manual explains quite nicely the differences between the various networking modes. Have a read.

Choosing a network mode

Now, NAT seems to be the most foolproof way of connecting the virtual machine to the Internet, but since one of my aims is to learn to configure a firewall, NAT will block inbound connections by default, so it will not really be convenient having to manually set port-forwarding through VirtualBox, only to have it blocked by the CentOS firewall.

This leaves me with the only other option that can talk to the outside world, the Bridged networking mode. Now, this is pretty much like any normal network connection on a machine. While it uses your existing network interface, it presents itself as a different interface, and so it talks to your home router as if it was a different machine. This means the guest OS can be configured to use DHCP to automatically get the network settings, or use static configuration (static IP etc).

Now, once CentOS gets installed, if I use DHCP the IP address will most certainly be different every time I switch places and I’ll be unable to access it through ssh via a consistent address. On the other hand, if it has a static configuration, it’ll be unable to connect at all as the router’s IP, DNS settings, etc, are different in each place.

I guess I’m going with bridged networking for now. I know there are some solutions for cases like this, although not exactly what and how. I know a piece of software called Avahi does something like that, as well as something related to DHCP itself (the DHCP client announces a hostname to the router, and the router announces it to the rest of the clients? something like that).

Installing CentOS

I’m installing the bare minimum of CentOS that I can. I’ve downloaded the Minimal ISO, and once I booted up the image and the graphical installed popped up, I just selected English as the installation language, my current timezone, made absolutely sure that Minimal Install is selected on the Software Selection option (and nothing else), and disabled kdump as it holds up some memory (which I have little to spare) and even if it was running, I wouldn’t know what to do with it.

I would choose even less stuff to install, if possible.
I would choose even less stuff to install, if possible.

While the installation is running, you are prompted to set a root password and create a new user. Of course I’m creating a new user, as this will be the account that I’ll be working from, only using root privileges when needed. Now, the new user screen has a checkbox to make the user an Administrator. I’m not enabling this, as I don’t know what it will do exactly. There’s always the sudo command 🙂

New user creation during install
No admin for me. I’ll get it myself.

That’s it

That should be it anyway. Once the installation finishes, reboot the virtual machine and it should boot right into the CentOS login screen. Login as root with your password, and type shutdown -h now to safely turn off the VM immediately.

Finally, with the VM turned off, make sure you keep a snapshot of the current state, just in case we need to come back at this point in time. I called mine Vanilla Installation.

You might be interested in …

Screenshot of a terminal with tmux running Midnight Commander, vim and htop

New Year’s Resolution v0.16

Speaking terminal

Shame on me. It’s been almost four years without writing a single word in this blog. You can’t – of course – force creativity, but it’s not like I’d write long essays anyway. I do however like the technical side of things and I enjoy challenges in unhealthy amounts, if the enjoyment could be measured, […]

Read More

Setting up networking (I can has internetz)

Speaking terminal

In my previously misleadingly titled “Setting up an environment” post, we created a brand new minimal CentOS 7 installation. The title is misleading in the sense that in order to set up an environment, I’ll need far more than a few posts to explore and configure an ideal environment. In this post, we’ll configure networking […]

Read More

Setting up a hostname and Avahi (mDNS)

Speaking terminal

We previously made sure our machine can access the internet. In this post, we’ll configure our machine so that we can access it from the local network, without ever knowing its IP address.

Read More

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *