Setting Up a GUI Environment on RHEL in AWS EC2: Installing VirtualBox and Creating a VM

Ayushmaan Srivastav
3 min readOct 6, 2024

--

In this blog post, I will guide you through the process of finding an Amazon Machine Image (AMI) with Red Hat Enterprise Linux (RHEL) that includes a Graphical User Interface (GUI). We will then launch an EC2 instance from this AMI, install VirtualBox, and create a virtual machine (VM) within the RHEL environment.

Prerequisites

  1. AWS Account: Make sure you have an active AWS account.
  2. IAM Permissions: Ensure your IAM user has permissions to launch EC2 instances and manage AMIs.
  3. SSH Client: You’ll need an SSH client to connect to your EC2 instance. Use Terminal on macOS/Linux or PuTTY on Windows.

Step 1: Finding an AMI with RHEL GUI

  1. Log in to the AWS Management Console.
  2. Navigate to the EC2 Dashboard.
  3. Click on Launch Instance.
  4. In the “Choose an Amazon Machine Image (AMI)” section, type “RHEL” in the search bar. You might need to select the “Public images” option to see the community AMIs.
  5. Look for AMIs labeled as “RHEL with GUI” or similar. Ensure that the AMI is from a trusted source, ideally from Red Hat or the AWS Marketplace.
  6. Select the desired AMI and click on Select.

Step 2: Launching the EC2 Instance

  1. Instance Type: Choose an appropriate instance type based on your needs. A t2.micro instance is a good start if you're eligible for the AWS Free Tier.
  2. Configure Instance: Click on Next: Configure Instance Details. You can leave most settings as default unless you have specific requirements.
  3. Add Storage: The default storage is typically sufficient for testing. Click Next: Add Tags.
  4. Add Tags: (Optional) You can add tags for better management.
  5. Configure Security Group: Set rules to allow SSH (port 22) and any other ports you may need. Click Review and Launch.
  6. Review the configuration and click on Launch. Select an existing key pair or create a new one to access the instance, and click Launch Instances.

Step 3: Connecting to Your EC2 Instance

  1. Once the instance is running, select it in the EC2 Dashboard.
  2. Click on Connect to view connection instructions. Use your SSH client to connect to the instance.
ssh -i "your-key.pem" ec2-user@your-instance-public-dns

Step 4: Installing VirtualBox

  1. Update the System: After connecting to your instance, ensure that your system packages are up to date.
sudo yum update -y

2. Install Required Packages: Install the necessary dependencies for VirtualBox:

sudo yum install -y gcc make perl kernel-devel

3. Download VirtualBox: Go to the VirtualBox download page and find the latest RPM package link for RHEL.

Use wget to download it. Replace x.x.x with the version you want.

wget https://download.virtualbox.org/virtualbox/x.x.x/VirtualBox-x.x.x-xxxxxx.rpm

4. Install VirtualBox: Install the downloaded RPM file:

sudo yum localinstall VirtualBox-x.x.x-xxxxxx.rpm

5. Load the VirtualBox Kernel Module: After installation, load the necessary kernel modules:

sudo /sbin/vboxconfig

Step 5: Creating a Virtual Machine (VM)

  1. Launch VirtualBox: You can start VirtualBox from the GUI or the command line. In this case, you’ll want to start it via the GUI. Run:
virtualbox

2. Creating a New VM:

  • Click on New.
  • Enter a name for your VM, choose the type (Linux) and version (select the appropriate version for your guest OS).
  • Allocate memory (RAM) to the VM. A minimum of 1024 MB is recommended.
  • Create a virtual hard disk and follow the prompts to finalize the VM creation.

3. Installing the Guest OS:

  • Download the ISO of the OS you wish to install on the VM.
  • In VirtualBox, select your newly created VM and click on Settings.
  • Under Storage, click on the empty optical drive and select the downloaded ISO as the optical disk file.
  • Start the VM and follow the installation prompts for the guest OS.

Conclusion

Congratulations! You have successfully set up a RHEL GUI environment in AWS EC2, installed VirtualBox, and created a virtual machine. This setup can be beneficial for testing, development, or educational purposes.

--

--

No responses yet