# OS Customization

{% hint style="info" %}
The instructions on this page only apply to Linux installations.
{% endhint %}

## Partitioning

The OS will be installed on the first disk. NVME drives will be preferred, if a server has multiple disk types.

### Default Linux Disk Partitions

By default, regular Linux installations will have the following partitioning details:

**Partitions:**

* `/boot`, 4096MB
* `/`, using the remaining space on the disk
* `swap` is enabled and has a size of 8192MB

### Custom Partitioning

During [new server requests](https://customer.i3d.net/apidoc-v3/all#/FlexMetalServer/createFlexMetalServer), it is possible to provide your own partitioning scheme.

In the `partitions` field of the OS object, you can customize your Linux partitions by specifying a list of them. Each partition object should have the following fields:

<table><thead><tr><th width="140.67578125">Field</th><th width="92.39453125">Type</th><th width="368.265625">Description</th><th>Example Value</th></tr></thead><tbody><tr><td><code>target</code></td><td>string</td><td>The mount point for the partition</td><td><code>/boot</code></td></tr><tr><td><code>filesystem</code></td><td>string</td><td>The filesystem to use for the target. Currently supported types: <code>ext2</code>, <code>ext3</code>, <code>ext4</code>, <code>xfs</code></td><td><code>ext4</code></td></tr><tr><td><code>size</code></td><td>int</td><td>The size of the partition in MB, or -1 for the remaining disk space</td><td><code>4096</code></td></tr></tbody></table>

#### Example

```json
{
    "name": "MyFlexServer",
    "location": "EU: Rotterdam",
    "instanceType": "bm7.std.8",
    "os": {
        "slug": "ubuntu-2404-lts",
        "partitions": [
            {
                "target": "/boot",
                "filesystem": "ext4",
                "size": 4096
            },
            {
                "target": "/",
                "filesystem": "ext4",
                "size": -1
            },
            {
                "target": "/custom",
                "filesystem": "ext4",
                "size": 10240
            },
            {
                "target": "swap",
                "size": 8192
            }
        ]
    },
    "sshKey": [
        "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIWrzxdeW3hhkejzSfFBFzPzcEBJBGtggOUJpLBCakbqmV/NztCaUoh631Xnk46MFn2snF89tSZZzlp9ySpqW7c= ecdsa-key-example"
    ],
    "postInstallScript": "#!/bin/bash\necho \"Hello flex world\" > /tmp/test.txt",
    "tags": [
        "My-tag1",
        "env:dev"
    ]
}
```

{% hint style="info" %}

* The `/` and `/boot` partitions are required and must be defined.
* The `size` field is in MB.
* The `size` field can be `-1` to use the remaining disk space.
* To disable the swap file, omit the `swap` partition from the list of partitions.
* Accepted filesystems: `ext2`, `ext3`, `ext4`, `xfs`.
* Partitioning does not apply to Talos installations, because Talos does not support customizing partitions.
  {% endhint %}

## The Linux bootloader

### Default bootloader options

During the OS installation process, we apply a specific customization to enable legacy network interface naming. This ensures that network interfaces follow the traditional ethX naming convention for OS install compatibility reasons.

The following kernel parameters are set:

* **`net.ifnames=0`** Disables predictable network interface names.
* **`biosdevname=0`** Disables naming based on BIOS device names.

No additional options are configured by default.

### Customizing the bootloader

{% hint style="warning" %}
Incorrect kernel arguments can prevent the server from booting. Please ensure that you provide valid kernel arguments.
{% endhint %}

You can provide additional kernel arguments to the bootloader by specifying them in the `kernelParams` field of the OS object when you [request a new server](https://customer.i3d.net/apidoc-v3/all#/FlexMetalServer/createFlexMetalServer). These values will be added to the GRUB configuration file and applied as follows:

* Add the kernel parameters to the `GRUB_CMDLINE_LINUX` variable in `/etc/default/grub`
* Update the GRUB configuration with `update-grub` (Debian based systems) or `grub2-mkconfig -o /boot/grub/grub.cfg` (RH / Centos based systems)
  * This generates the `grub.cfg` file and generates the `/boot/grub/grubenv` file

#### Example

In the `kernelParams` field of the OS object, you can provide a list of custom kernel or GRUB parameters. For example:

```json
{
    "name": "MyFlexServer",
    "location": "EU: Rotterdam",
    "instanceType": "bm7.std.8",
    "os": {
        "slug": "ubuntu-2404-lts",
        "kernelParams": [
            {
                "key": "mitigations",
                "value": "auto,nosmt"
            },
            {
                "key": "nopti",
                "value": ""
            }
        ],
    },
    "sshKey": [
        "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIWrzxdeW3hhkejzSfFBFzPzcEBJBGtggOUJpLBCakbqmV/NztCaUoh631Xnk46MFn2snF89tSZZzlp9ySpqW7c= ecdsa-key-example"
    ],
    "postInstallScript": "#!/bin/bash\necho \"Hello flex world\" > /tmp/test.txt",
    "tags": [
        "My-tag1",
        "env:dev"
    ]
}
```

This example disables hyperthreading (on the OS level) and disables Page Table Isolation (PTI) in the kernel. The options added to the GRUB configuration are: `mitigations=auto,nosmt nopti`.

{% hint style="info" %}
Talos Linux requires special kernel arguments to boot. Please refer to the [Talos installation](https://registry.terraform.io/providers/i3D-net/i3dnet/latest/docs/resources/flexmetal_server) documentation for more details.
{% endhint %}
