2017-01-31

Python / Linux / VMware 1: Installing CentOS

I'm trying to expand my knowledge of Linux and Python. I'm taking a "start from scratch" approach, building some virtual environments at home, and documenting every step along the way. This is the first of five posts capturing those steps; the end-state is PyCharm IDE, Python 3.6, CentOS 7.3, VMware Workstation Pro 12 running on Windows 10.

This is Part 1: Installing VMware and CentOS
Part 2: Expanding CentOS's Minimal Install
Part 3: Installing Python 3.6
Part 4: Linking PyCharm to Github via SSH
Part 5: Running through Git-It again, this time with PyCharm

Create the Virtual Machine

As part of creating your Virtual Machine, it's useful to already have an image of the operating system you want to install - so go to https://www.centos.org/download/ and click on Minimal ISO, then choose one of those files to download the latest version of CentOS. Odds are good that you're going to want the 64-bit version.

In VMware, click on Create a New Virtual Machine to start the wizard. You'll be prompted to choose your configuration type; stick with Typical and click on Next.

Next you'll be prompted to select your installation source. Browse to the CentOS ISO that you downloaded earlier, then click on Next.

Name the virtual machine, and select a location to store its files. Because I'm eventually going to have multiple VMs, all with CentOS7, I've named this machine CentOS7A. I like to avoid non-alphanumeric characters here, since I'll be using this same name for the operating system host name later.

For our purposes, 20GB should be plenty of drive space. Split the virtual disk into multiple files, to make it easier to move around later (just in case, for example, you want to copy it to a travel laptop to take on a trip, or to a work machine).

There are a few last things to check before we kick off the CentOS installation. On the next screen, click Customize Hardware to give them a look.

Select Memory in the left-hand pane, and confirm that the blue slider on the right is at least next to the green pointer for Recommended memory. Much less than this, and I've found that virtual machine performance can get particularly sluggish. Make this bigger if you need to, but think about how many other VMs you might be creating or running simultaneously, and think about the total real memory you have on the host system.

Select Network Adapter in the left-hand pane, and put a check in Connect at power on.

Next, you'll choose your Network connection type. This defaults to NAT, which is what I'll be using for the rest of this setup. Depending on your requirements for the virtual machine, though, you may want to use one of the other modes.

  • In NAT mode, your host computer will act as a gateway to the network for your virtual machine. Outside of the host, no other machines on the network will be able to see the virtual machine - although virtual machines on the same host will be able to see each other. If the host computer has Internet access, the virtual machine will too - but any connection between a virtual machine and an outside machine must be initiated by the virtual machine. Use NAT mode if your virtual machine is not going to be functioning as a server that requires access from outside the host.
  • In Bridged mode, your host computer will share its physical network connection with the virtual machine. The virtual machine will function as if it were an additional physical computer on the network; other machines on the network will be able to see and interact with it directly. If the host computer has Internet access, the virtual machine will too - and computers outside the host machine will be able to initiate connections directly with the virtual machine. Use Bridged mode if your virtual machine is going to be functioning as a server of some sort (like a web server to which you'll connect from other computers).
  • In Host-only mode, your virtual machine lives on a network that is contained entirely within the host computer. This allows your virtual machine to communicate with other virtual machines on the same host, and with the host itself, but not with anything outside of the host. Use this if your intent is to create an isolated test network - but remember that because it cannot communicate outside the host, a virtual machine configured in this way will not have Internet access (at least, not without some other shenanigans).

Once you've confirmed your memory and network settings (and possibly tuned the others, too, if needed), click on Finish. At this point, the virtual machine will be created, and the Linux installation will begin.

Install Linux

By default, CentOS wants to test the disk first, but it's a virtual disk so let's skip that. Use your arrow keys to move the selection up to Install CentOS Linux 7, then press Enter, and press Enter again to begin the installation process.

Some initialization steps will occur, and you will be presented with the first graphical installation screen. Select your language preference, then click on Continue.

On the Installation Summary screen which appears next, the order matters. I prefer to select installation destination first, but more importantly, you shouldn't configure Date & Time until after you've set up networking.

Click on Installation Destination. On the subsequent screen, make sure there's a checkmark on the 20 GB virtual drive you created earlier, then click on Done.

Back on the Installation Summary screen, click on Network & Host Name. On the subsequent screen, enable the network by clicking on the switch in the upper right. Then, change your host name in the lower left, if you like (don't forget to click Apply). Don't click Done - we aren't finished here.


Click on Configure in the lower right. On the subsequent screen click on the General tab, then make sure that the first box is checked, for "Automatically connect to this network when it is available". Click on Save in the lower right of this screen, and then click on Done back on Network & Host Name configuration screen.

Finally, we'll configure date and time settings. Click on Date & Time near the top of the Installation Summary screen. On the subsequent screen, click the switch in the upper right to enable Network Time, and then click your time zone on the world map (or use the drop down menus). Click on Done to get back to the Installation Summary screen.

At this point we're ready to kick things off; click on Begin Installation. When this begins, you'll be presented with a screen to set the root password, and to create a user account.

Click on Root Password to set the password for your root account, then save that to return to this screen. Click on User Creation next, and add at least one user. For my own account, I also prefer to check the box to Make this user administrator, so I don't have to mess around with sudo rights later. Note that if this were going to be a production system, I would recommend leaving that box blank, and being more granular with security permissions after the operating system is installed.

Once the files have finished copying, and your passwords have been set up, you're done with this phase - click on the blue Reboot button in the lower right. When you're prompted to log in, use the user account that you set up a moment ago, and you'll be at a console.

Confirm that you have basic Internet access by pinging an outside IP address. I use 8.8.8.8 (one of Google's DNS servers) because it's easy to remember and to type.
$ ping -c 2 8.8.8.8  
 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.  
 64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=10.3 ms  
 64 bytes from 8.8.8.8: icmp_seq=2 ttl=128 time=10.3 ms  

--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1005ms
rtt min/avg/max/mdev = 10.305/13.100/15.896/2.797 ms
$

If ping gets no response, take a look at your host operating system's firewall to make sure it's not blocking that traffic. Look at host antivirus software, too (for the same reason). I had this problem on my system and it turned out that Bitdefender was blocking ICMP return packets. If that reveals nothing, try switching your Network Adapter's Network Connection type to Bridged (or to NAT, if you'd originally chosen Bridged). Finally, there's a chance that you forgot to set the interface to automatically connect on startup - have a peek at the interface's configuration file in /etc/sysconfig/network-scripts and make sure that ONBOOT is set to yes.

Now that you've confirmed basic Internet connectivity, it's time to run a quick check for updates, reboot, and be done with this section.
$ sudo yum update -y
 ## status will display here until the update is complete
$ shutdown -r now

Once you've logged back in after the reboot, back in VMware, right-click on the VM itself, and from the context menu select Snapshot / Take Snapshot. Call it "Minimal Install Complete" and save it. This will allow you to return your machine to this state if it gets wonky over time, just saving you the early steps of reinstalling the operating system.

That's it for this section. In the next, we'll install a few things on Linux that were missing based on our minimal install - things like nslookup, a graphical desktop environment, and some development tools that we'll be using later.

This was Part 1: Installing VMware and CentOS
Part 2: Expanding CentOS's Minimal Install
Part 3: Installing Python 3.6
Part 4: Linking PyCharm to Github via SSH
Part 5: Running through Git-It again, this time with PyCharm

No comments:

Post a Comment