# Installing Custom CentOS 7 On Oracle Cloud

**URL:** <https://hostballs.com/t/installing-custom-centos-7-on-oracle-cloud/3020>\
**Category:** Wiki\
**Created:** [September 25, 2019, 8:09am UTC](https://hostballs.com/t/installing-custom-centos-7-on-oracle-cloud/3020 "2019-09-25T08:09:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tetech](https://hostballs.com/letter_avatar/tetech/32/5_5575768a8748004e209b776fc1b2916d.png) [@tetech](https://hostballs.com/u/tetech)\
**Post date:** [September 25, 2019, 8:09am UTC](https://hostballs.com/t/installing-custom-centos-7-on-oracle-cloud/3020/1 "2019-09-25T08:09:11Z")

</div>

I jumped on the Oracle Cloud free offer, but couldn’t see a way to do a custom CentOS install. There could be many reasons not to use Oracle’s CentOS image. Creating a LUKS-encrypted partition, just for example. Here’s one way to get there by using VirtualBox.

**1. Create a new CentOS 7 VM in VirtualBox.**

- In Settings-\>System, make sure “Enable EFI” is checked
- In Settings-\>Serial ports, check “Enable serial port”, and have the COM1 port mode set to Disconnected.
- When creating a virtual disk, be sure to use VMDK format and don’t segment it. Keep the size small, e.g. 5 GB.

**2. Install CentOS 7**

Nothing special, just make sure you’ve got an unecrypted /boot and /boot/efi partition.

**3. Boot the new VM**

Set it up for console access. As root:  
`echo 'GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200"' >> /etc/default/grub`  
`echo 'GRUB_TERMINAL="serial console"' >> /etc/default/grub`  
`sed -i "s/^\(GRUB_CMDLINE_LINUX.*\).$/\1 console=tty1 console=ttyS0,115200\"/" /etc/default/grub`  
`grub2-mkconfig -o /boot/grub2/grub.cfg`

Then:  
`cp -p /boot/efi/EFI/centos/grubx64.efi /boot/efi/EFI/BOOT/`  
`cp /etc/sysconfig/network-scripts/ifcfg-enp0s3 /etc/sysconfig/network-scripts/ifcfg-eth0`  
`sed -i "s/UUID/#UUID/" /etc/sysconfig/network-scripts/ifcfg-eth0`

You might need to replace the adapter name to match your system; just make sure you have an `ifcfg-eth0` file using DHCP with `ONBOOT=yes`.

**4. Halt the VM and upload the VMDK file.**

In the Oracle Cloud console, go to Object Storage → Object Storage, create a bucket if none exists, then click “Upload objects” and upload the VMDK file.

**5. Create an image**

After the VMDK object has been uploaded, click “View object details” and copy the URI.

Go to Compute → Custom images, click “Import image”, in the “Object storage URL” field paste the URI. Be sure VMDK format and Paravirtualized mode are selected, then click “Import image”.

When complete (takes a few minutes) click “Edit Details” and check the VM.Standard.E2.1.Micro shape.

**6. Create VM**

Once the custom image exists, it is simply a matter of “Create Instance”. Nothing much should need to be done after it starts, except for expanding the partition.

---

<div class="post-metadata">

**Author:** ![luissousa](https://hostballs.com/user_avatar/hostballs.com/luissousa/32/18949_2.png) [@luissousa](https://hostballs.com/u/luissousa)\
**Post date:** [September 25, 2019, 11:17am UTC](https://hostballs.com/t/installing-custom-centos-7-on-oracle-cloud/3020/2 "2019-09-25T11:17:11Z")

</div>

I can’t even get past “Out of host capacity” 🤣

---

<div class="post-metadata">

**Author:** ![tetech](https://hostballs.com/letter_avatar/tetech/32/5_5575768a8748004e209b776fc1b2916d.png) [@tetech](https://hostballs.com/u/tetech)\
**Post date:** [September 25, 2019, 11:29am UTC](https://hostballs.com/t/installing-custom-centos-7-on-oracle-cloud/3020/3 "2019-09-25T11:29:22Z")

</div>

If you try to create a free VM outside your home region, or more than 2 VMs of any shape inside any region, you get that error. If this doesn’t apply, then keep trying!

---

<div class="post-metadata">

**Author:** ![Mason](https://hostballs.com/user_avatar/hostballs.com/mason/32/66_2.png) [@Mason](https://hostballs.com/u/Mason)\
**Post date:** [September 25, 2019, 12:41pm UTC](https://hostballs.com/t/installing-custom-centos-7-on-oracle-cloud/3020/4 "2019-09-25T12:41:45Z")

</div>

Awesome! Thanks for the guide, I’m sure it’ll help some peeps here 🙂

I wonder if something similar can be done for Debian installs since only Ubuntu is listed.

---

<div class="post-metadata">

**Author:** ![tetech](https://hostballs.com/letter_avatar/tetech/32/5_5575768a8748004e209b776fc1b2916d.png) [@tetech](https://hostballs.com/u/tetech)\
**Post date:** [December 30, 2019, 10:44am UTC](https://hostballs.com/t/installing-custom-centos-7-on-oracle-cloud/3020/5 "2019-12-30T10:44:54Z")

</div>

Had a reason to revisit this. Most Linux versions seem to follow a very similar process, with the biggest hassle associated with getting the serial console working. I did Alpine today, and needed:

```
sed -i "s/^\(GRUB_CMDLINE_LINUX.*\).$/\1 console=ttyS0,115200\"/" /etc/default/grub
sed -i -e "s/^#ttyS0/ttyS0/" /etc/inittab
echo ttyS0 >> /etc/securetty

```
