Create your own Linux operating system template

Estimated reading time: 1 min

Learn how to create your own Linux OS template

In this article, we will describe how you can convert a snapshot to a template that you can use to install new servers.

Prerequisites

Step 1: Log in using SSH

You must be logged in via SSH as sudo or root user. Please read this article for instructions if you don’t know how to connect.

Step 2: Find the active network interface

clear && echo $(ip -o -4 route get 8.8.8.8 | sed -nr 's/.*dev ([^\ ]+).*/\1/p')

Step 3: Change static IP address to DHCP

In order to prevent network problems, please change static IP address to DHCP.

Ubuntu 20.04 and above:

Make a copy of the interfaces configuration file

cp /etc/netplan/01-netcfg.yaml /root/01-netcfg.yaml.bak

Replace the configuration file

cat <<'EOF' > /etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    ens18:
      dhcp4: true
EOF
Debian:

Make a copy of the interfaces configuration file

cp /etc/network/interfaces /etc/network/interfaces.bak

Replace the configuration file

cat <<'EOF' > /etc/network/interfaces
auto lo
iface lo inet loopback

auto ens18
iface ens18 inet dhcp
EOF

Step 4: Turn the server off

Turn off the server through the operating system or turn off the server through the client area by clicking Power OFF.

poweroff

Step 5: Create the template

Click More... to see the dropdown menu. Click OS Templates .

os templates

Click Create template

create template

Provide a name and description to the template and click Create template

name description

Step 6: Verify the template

Once the template is created you should be seeing the status “Ready” if you reload the page.

templateready

Step 7: Turn on the server

Click Startup to start the server.

Step 8: Put configuration file back

Put the network configuration file back.

cp /etc/network/interfaces.bak /etc/network/interfaces

Conclusion

In this article, we have created an operating system template that can be used to deploy a new server.

Was this article helpful?
Dislike 0
Views: 1235

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *