Tag Archives: Ubuntu

Running CentOS 8 with Oracle VirtualBox

Recently it was necessary for me to prepare couple of VMs with CentOS Linux 8 to do some labs/practice, and in this blog post I just want to share my notes about the process/steps involved into creating CentOS 8 VM using Virtual Box.

My base OS is Ubuntu 20.04, so I first needed grab DEB package with the latest version of Oracle Virtual Box from official downloads page. I then grabbed full x86-64 ISO file of CentOS Linux 8 (CentOS-Stream-8-x86_64-20210427-dvd1.iso) from CentOS downloads page to avoid any potential need for extra downloads during installation process.

After installing DEB package I quickly created new VM using the following options:

Creating VirtualBox VM – Name and OS
Creating VirtualBox VM – Memory Size
Creating VirtualBox VM – Hard disk
Creating VirtualBox VM – Hard disk file type
Creating VirtualBox VM – Storage on physical hard disk
Creating VirtualBox VM – File location and size

After creating VM I’ve started mounting CentOS iso file and selecting Install CentOS Linux 8

Starting CentOS 8 installation process

For my purposes it was OK to accept defaults for almost everything. English US for language settings:

CentOS 8 installation – language settings

I only changed installation type from default Server with GUI to Minimal Install and further assigned Root Password and configured Installation Destination with default options:

CentOS 8 installation – Installation Summary

Setting up weak root password (which is OK for test box) requires you to click Done twice:

CentOS 8 installation – Root Password

And for disk option it is OK to just accept defaults:

CentOS 8 installation – Installation Destination

With all settings in place we just hit begin Installation and wait/taking a coffee break 🙂

CentOS 8 installation – Installation Summary

It is now only a question of observing installation progress for some time and hitting Reboot System bottom at the very end of the process:

CentOS 8 installation – Installation Progress
CentOS 8 installation – Installation Completed

Once installation is over and system is rebooted we need to logon and install updates/make sure we have Internet connection, but if we run yum check-update immediately after logon we will see that VM has no internet access:

yum check-update – no connectivity

As you can see from the output we cannot connect/resolve host name to check for updates, so let’s check network status with nmcli general command:

Network connection status (nmcli general)

As you can see interfaces are enabled but we have no connectivity, basically it is because VM didn’t receive IP configuration from DHCHP and running dhclient -v command should resolve that (v flag only indicates that we need detailed output from this command):

Checking connection status after running dhclient -v

After that we can re-run nmcli general – state should change to connected and yum check-update or yum update commands should work just fine:

Running yum with working connection

But what I noticed is that after every reboot of VM network connection was again getting back to disconnected state, although yum check-update / yum update commands were not reporting connectivity errors, checking with nmcli general or with curl -I https://mikerodionov.com was showing that I can’t connect and dchclient command was helping only until next reboot. I checked network-scripts folder and interface configuration file did had BOOTPROTO=dhcp option which supposed to be responsible for use of DHCP at boot stage, but ONBOOT setting was set to no – changing it to yes made connectivity available immediately after reboot.

To edit these settings you can use vi as shown below:

Using vi to edit network configuration scripts
Configuration with ONBOOT option changed to yes

After that the only basic thing you may want to do is to adjust/verify hostname of VM which you can do with hostamectl command as shown below:

Changing and viewing hostname

With that we have CentOS 8 VM with internet connectivity and updates and at it is good idea to create baseline snapshot of VM at this stage. I guess these notes may come in handy to somebody else, especially final part on network configuration.

XRDP service error: Cannot read private key file

Recently it was necessary for me to enable XRDP service on Ubuntu 20.04 VM, so I followed the steps outlined in one of my old posts and get it working quickly. Unfortunately I run into some new issue with not being able to reset or shutdown Hyper-V VM for some reason, which I ignored for now, but after couple of power offs I realized that I cannot connect via XRDP until I open session locally. I then decided to check on the service status with sudo systemctl status xrdp command and got the output shown below:

XRDP Cannot read private key

Full error message says: [ERROR] Cannot read private key file /etc/xrdp/key.pem and I’m pretty sure that it didn’t show up when I used the same status command after initial configuration, though people tend to forget and miss things 🙂

Anyhow to clear up this the following command has to be executed:

sudo adduser xrdp ssl-cert

Abovementioned error occurs when the default user for XRDP’s service lacks access to the directory to which /etc/xrdp links, and with the command above you allow the user xrdp access through ssl-cert group membership. I hope that this information may come in handy to some one else 🙂

Creating Hyper-V VM with Ubuntu Server

I’ve recently decided to learn a bit about Ubuntu and going to do some project based on this platform, hence this little post describing how to create Ubuntu Server Hyper-V VM.

First of all, you need to download latest Ubuntu Server installation media from here, selecting between LTS (Long Term Support) and regular version:

LTS version is more tested and enterprise focused version which is released every 2 years and has 5 years support cycle.

Once you have installation media you just need to create Hyper-V VM allocating desired quantity of resources to it (note that this OS has quite humble minimum requirements) and make your VM Generation choice.

Despite the fact that process of creating VM is more or less the same for any OS I decided to write down all the steps involved into setting up Ubuntu Server VM.

You can follow these steps to create your own Hyper-V VM with Ubuntu Server OS. Right click on your Hyper-V host and select New > Virtual Machine:

Just click Next on Before You Begin page:

Specify name and location for your VM (be sure to specify your preferred VMs folder, VM specific subfolder will be created automatically based on VM name you type in):

Select Generation of your VM (note this cannot be changed once VM is created):

I wanted Generation 2 VM so I’ve selected this option (refer to MSFT documentation for information on choosing VM generation). Note that for Ubuntu VM you need to disable secure boot feature which will be enabled by default on Generation 2 VM.

Assign desired amount of memory and decide whether Dynamic Memory should be used:

Select virtual switch:

Adjust VHD settings if necessary:

Specify path to Ubunto ISO file you downloaded earlier:

Review selection you made and click on Finish:

Disable Secure Boot before powering on your VM – otherwise your VM fail to boot (as per MSFT documentation: “some Linux virtual machines will not boot unless the secure boot option is disabled”):

And while you are still in VM properties I would recommend you to disable automatic checkpoints (unless you want to use them):

Once you start VM setup process will be initiated automatically:

You will need to select preferred language:

Then keyboard settings:

And next, select Install Ubuntu option:

Accept default network connections settings:

And leave your proxy settings empty (unless you are using proxy server):

Accept default archive mirror address and hit Done:

Accept defaults on filesystem setup (which will mean use entire disk for our installation):

Select disc or accept selection if you have just one:

Accept default filesystem settings on the next page:

Agree with formatting selected drive (data loss warning):

Specify profile settings and server name (note that only small letters accepted for server and user names – great example of explicitness which leaves no chance for you to grown up into proficient user thinking that some case insensitive objects are case sensitive – happens way too often in more thanks to some user friendly OSs):

Select whether you want to install OpenSSH server:

Select any additional packages you may want to install:

Wait till installation go through remaining steps:

Hit Reboot Now once installation completes:

Once VM reboot completes you will be prompted to remove installation medium and hit ENTER (Hyper-V should auto remove it for you):

Once reboot completes Ubuntu Server should start and meet you with credentials prompt:

Once you type in your login and password correctly you will be invited to enter commands (no GUI installed on Server version by default):

At this point I suggest you to shutdown VM with shutdown -P now command and make your baseline VM snapshot.

Last do couple of more things before we wrap off our VM setup process. Let’s first install updates using sudo apt-get update (to fetch the list of available updates) and sudo apt-get upgrade (to upgrade installed packages):

And last but not least, let’s add GUI to our server – for that just use sudo apt-get install ubuntu-desktop confirming that you want to continue on additional space usage requirement consent step. Once setup completes you need to reboot your VM and it will start in GUI mode:

After clicking on your user icon, type in your password and click Sign In:

You will be presented with What’s new in Ubuntu splash screen:

This concludes VM installation and configuration process. Stay tuned for the new posts as I’m going to keep using this VM and documenting installation and configuration of additional packages and other things.