# Creating an Ubuntu 20.04 Image

Download the Ubuntu 20.04 ISO from Canonical, and upload the base image to vCetner. Then, create a new virtual machine in vCenter.

NOTE

Since we’ll include cloud-init with our image, we will need to ensure the virtual machine has a cdrom. Select the Ubuntu 20.04 ISO we just downloaded from the CD/DVD drive dropdown menu when creating the new virtual machine.

Before installing the operating system, set up a single ext partition without a swap disk. Then, continue on installing Ubuntu making the following selections during the setup process:

- Update to the latest installer if a later version is available
- Use the entire disk and deselect the option to set up the disk as an LVM group
- Configure an account and set a password
- Opt to install OpenSSH Server
- Other optional packages aren’t needed for this basic Ubuntu image

Complete the installation process and reboot the machine. Update the package list and apply any upgrades:

```
```
apt-get update  
apt-get upgrade
```
```

Change the network interface to `eth0` by editing `/etc/default/grub`. The line `GRUB_CMDLINE_LINUX=""` should be edited to `GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"`.

Update GRUB:

```
```
update-grub
```
```

Update the `70-persistent-net.rules` file:

```
```
cat << EOF > /etc/udev/rules.d/70-persistent-net.rules  
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="eth0"  
EOF
```
```

Remove `subiquity-disable-cloudinit-networking.cfg` as cloud-init will skip network configuration if it’s present:

```
```
rm -f /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg
```
```

Update `99-pve.cfg`:

```
```
cat << EOF > /etc/cloud/cloud.cfg.d/99-pve.cfg  
datasource_list: [ConfigDrive, NoCloud]  
EOF
```
```

Remove Netplan files, they will not be regenerated if they exist:

```
```
rm -f /etc/netplan/00-installer-config.yaml  
rm -f /etc/netplan/50-cloud-init.yaml
```
```

Run cloud-init clean:

```
```
cloud-init clean
```
```

Next, reboot the system and confirm the network interface is labeled `eth0` once the machine comes back up. Then, clear BASH history for root. The history entry has a copy in the memory and it will flush back to the file when you log out. You can avoid this with the following command:

```
```
cat /dev/null > ~/.bash_history && history -c && exit
```
```

Shutdown the system:

```
```
shutdown -h now
```
```

Convert the VM to a template in vCenter before moving back to VM Essentials to onboard the image and use it to begin building your provisioning library.
