Wednesday 13 November 2019

HOWTO upload a Centos8 image to Digital Ocean


So you'd like to run Centos 8 on Digital Ocean... But the Cloud version of Centos 8 has not been released yet, so therefore Digital Ocean does not offer Centos 8 as an option...

No problem, just create a VM on your own workstation and then upload it as a Custom Image.

This HOWTO assumes you have a desktop running a Linux OS, with a copy of the free VMware Player installed.


1) Create VM from Centos 8 ISO using VMware Player.

- Select the Server option with no GUI and no packages selected. (Or maybe try picking the Minimal Install option? As we can always Yum Install packages later from Digital Ocean.)

- To save a little size, run: "yum remove cockpit cockpit*" if you don't expect to run the Cockpit GUI.

2) Run "dracut --force --no-hostonly" so that the kernel will boot on new virtual hardware after upload to DO...

To quote https://fedoramagazine.org/initramfs-dracut-and-the-dracut-emergency-shell/

"The force parameter tells dracut that it is OK to overwrite the existing initramfs archive. The no-hostonly parameter overrides the default behavior of including only drivers that are germane to the currently-running computer and causes dracut to instead include all drivers in the initramfs.

This means that dracut will now be "bloated" and have all the applicable drivers required for when the hard drive is moved. After you finish moving the hard drive you have to rerun dracut with dracut --force to regenerate a lightweight version of dracut."

3) Shut down the VM and quit VMware.

4) Run "qemu-img convert VMNAME.vmdk VMNAME.qcow2" to export the VMDK files into a single QCOW2 file.
(you may have to "yum install qemu-img" first or perhaps apt-get it if you're on a Debian-derived distro).

5) gzip VMNAME.qcow2 to make the image smaller before upload.  For me, this produced an image of about 939 Megabytes, for upload to Digital Ocean as a custom image.  You could also use Bzip for greater compression if you have a slow upload link.

6) Upload to Digital Ocean (I used Firefox).  After upload, the image will show as Pending for about 10 minutes... Then it will become available for deployment on new Dropleys.

7) Deploy Droplet from image.

8) Boot Droplet and Bodge The Networking.  If like me you have not bothered to enable cloud-init, the network won't work initiallly, so it will be necessary to log in over the console and adjust /etc/sysconfig/network-scripts/ifcfg-ethXXX in order to get network access.

- rename ifcfg-ethXXX to match the name of the eth device shown in ifconfig
- edit the file and:
- set ONBOOT=yes
- set DEVICE= and NAME= to match the name of the eth device shown in ifconfig
- set the last 12 characters of the UUID= to match the MAC of the eth device shown in ifconfig
- set IPADDR=, PREFIX=, and GATEWAY= to match the details shown at the bottom the console window.
- set DNS1=1.1.1.1, DNS2=1.0.0.1 (or whatever you prefer)
- Hint: run "ipcalc" if you need to calculate the Prefix length e.g. 20 from the netmask e.g. 255.255.240.0.

After rebooting you should have SSH access.

9) Free up some RAM.  If you run "top" you will find you only appear to have about 820 MiB of RAM in total (if you are deploying a 1 GB droplet for economy.

To free some memory:

- run "dracut --force" and reboot.  This removes a little kernel bloat (see 2 above).

- lose the crash kernel memory allocation:

# sed -i 's/crashkernel=auto/crashkernel=no/' /etc/default/grub
# grub2-mkconfig -o /boot/grub2/grub.cfg 
Generating grub configuration file ...
done
# reboot

Now I have 981 MiB of RAM... Enough for a small server :-)

Hope this was useful.

No comments:

Post a Comment

Spammers: please stop wasting my time. All comments are moderated before publication.