How to change an Oracle OCI Compute Instance Name and Host Name?

There is an Oracle OCI compute instance (with Oracle Linux 8 as operating system). There is a request from a customer to change both the compute instance name and its hostname.
Here are the steps to do that.

Change the Compute Instance Name:

This is very simple. Just navigate to the compute instance:

Navigation Menu ==> Compute ==> Instances ==> Click your Instance Name (to display the instance details) ==> More Actions ==> Edit
In the “Name” field enter the new name and then click “Save Changes”

If the compute instance are linked with NSG (Network Security Group), that you need to change its name to match the new compute name, this also very simple.
Navigation Menu ==> Networking ==> Virtual Cloud Networks ==> Select your VCN
In the “Resources” Section, select “Network Security Groups”
Select the “…” beside the NSG that you want to rename, then select “Edit”, and enter the new name:

The new Name for the NSG will be reflected automatically in the Compute Instance Details.

If the compute instance is attached with any Block Volume, and if there is a need to change the name of that block volume to match the new compute instance name, this is also very simple.
Navigate to:
Navigation Menu ==> Storage ==> Block Volumes ==> Action Menu ==> Select “Edit” ==> Enter the new block volume name , then “Save Changes”.
The new block volume name will be reflected automatically in the Compute Instance’s attached block volumes list.

Change the Hostname:

Now coming to the important task of renaming the virtual machine hostname. I followed the following steps to rename the hostname:
1- Login to the VM as root user (using utility like putty or MobaXTerm): “sudo su –
2- First, check the current hostname using the command: “hostname
3- Change the hostname in the file /etc/hostname: vi /etc/hostname
4- Change the hostname in the file /etc/hosts: vi /etc/hosts
5- Change the hostname using the command hostnamectl: hostnamectl set-hostname <new-hostname>

That is all

Thanks
Ahmed

Leave a comment