# Deploy a Custom Image Using iPXE

[**iPXE**](https://ipxe.org/) is a free open-source network boot firmware that provides a flexible and extensible framework for booting operating systems over a network. It provides a full PXE implementation enhanced with additional features.

**You have a valid public URL storing your iPXE script.**

You can use iPXE scripts to deploy your custom image. An iPXE script is essentially a set of instructions that are used to specify the boot process and configure network parameters. iPXE scripts can include commands for tasks such as obtaining an IP address, configuring network settings, loading specific boot images, and more.

Here is an example of an iPXE script:

```
#!ipxe

# Download Ubuntu 20.04 ISO image
kernel http://path/to/ubuntu-20.04-netboot/vmlinuz
initrd http://path/to/ubuntu-20.04-netboot/initrd
boot

:install
set base-url http://path/to/ubuntu-20.04-netboot/

# Launch Ubuntu setup
kernel ${base-url}linux auto=true hostname=${hostname} domain=${domain} url=${preseed/url} locale=${locale} console-setup/layoutcode=us keyboard-configuration/layoutcode=us file=/cdrom/preseed/ubuntu-server.seed initrd=initrd.gz quiet ---
initrd ${base-url}initrd.gz
boot
```

**You temporarily have no public URL.**

You can refer to [**netboot.xyz**](https://netboot.xyz/docs/) to finish the OS installation. [**netboot.xyz**](https://netboot.xyz/) provides a user friendly menu that lets you easily choose the operating system you want along with any specific types of versions or bootable flags.

## Procedures

### Deploying a Custom Image

See [**Create a Bare Metal Instance**](https://docs.console.zenlayer.com/welcome/bare-metal/get-started/create-a-bare-metal-instance) for detailed steps of how to create an instance, and in operating system selecting, choose **Custom OS** while creating an instance.

* Install via iPXE URL: enter your public URL storing your iPXE script.
* Install via netboot.xyz: you don't need to prepare your iPXE script.

Follow the other steps to finish instance creation.

{% hint style="info" %} <mark style="color:blue;">**Note**</mark>

<mark style="color:blue;">After deploying with a custom OS,</mark>

* <mark style="color:blue;">You cannot create partitions or label your hostname.</mark>&#x20;
* <mark style="color:blue;">You can only have the customized password. Remember your password to log in to IPMI console afterwards.</mark>
* <mark style="color:blue;">Your instance will show from</mark> <mark style="color:blue;"></mark><mark style="color:blue;">**Creating**</mark> <mark style="color:blue;"></mark><mark style="color:blue;">to</mark> <mark style="color:blue;"></mark><mark style="color:blue;">**Installing**</mark><mark style="color:blue;">, and to</mark> <mark style="color:blue;"></mark><mark style="color:blue;">**Powered On**</mark> <mark style="color:blue;"></mark><mark style="color:blue;">state. That doesn't mean your image has finished installing. You will need to remote access the instance to configure on the system.</mark>
  {% endhint %}

### What to Do Next

1. Go to instance **Details > OS\&IPMI > Log in to IPMI Console**.
2. Log in to IPMI Console using the public username (`operator`) and your password.
3. Select the configurations you need and finish the installation of your OS following the wizard.
4. Back to Console and go to instance **Details** page, and click **Reset IPs**.
5. After IP resetting, restart your instance.

{% hint style="info" %} <mark style="color:blue;">**Note**</mark>

<mark style="color:blue;">IP resetting may fail. Please try again. If IPs are successfully reset, you also need to check on your server to see whether your operations are effective.</mark>
{% endhint %}

### Other Networking Operations

Because you have installed your OS using iPXE, all networking related operations, except for IP resetting, need to be manually configured on your instance system to take effect.

Here we take elastic IP adding as an example.

1. Go to instance **Details > Networking** page and click **Add Elastic IP**.
2. Select your desired elastic IP (`23.90.160.73`) to assign.

   <figure><img src="https://3201622183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9X3FDdkCL2HzhbPpPMFt%2Fuploads%2FPBypfUo6euhD1C5LbHJT%2Fimage.png?alt=media&#x26;token=1ca9ea67-7699-453e-a94b-65ed4deda993" alt=""><figcaption></figcaption></figure>
3. Click **Reset IPs**.
4. Remote access to your instance and execute the following commands.

```bash
sudo ip addr add 23.90.160.73/32 dev wan0
```

{% hint style="info" %} <mark style="color:blue;">**Note**</mark>

<mark style="color:blue;">You must</mark> <mark style="color:blue;"></mark><mark style="color:blue;">**first**</mark> <mark style="color:blue;"></mark><mark style="color:blue;">make</mark> <mark style="color:blue;"></mark><mark style="color:blue;">**IP Resetting**</mark> <mark style="color:blue;"></mark><mark style="color:blue;">on Console and then configure on your server to make your operations really take effect.</mark>
{% endhint %}
