# Notes on getting RHCOS/RHEL to boot on LPAR

Target: Booting the RHCOS 4.16 live installer (from rhcos-416.94.202410211619-0-live.s390x.iso) in an LPAR with Fibre Channel (FCP) storage, to install a node that will join an existing OpenShift cluster.

## s90x ISO

### RHCOS
```bash
tree rhcos
rhcos
├── boot.catalog
├── coreos
│   ├── features.json
│   ├── igninfo.json
│   ├── kargs.json
│   └── miniso.dat
├── generic.ins
└── images
    ├── cdboot.img
    ├── cdboot.prm
    ├── genericdvd.prm
    ├── generic.prm
    ├── initrd.addrsize
    ├── pxeboot
    │   ├── initrd.img
    │   ├── kernel.img
    │   └── rootfs.img
    └── redhat.exec

4 directories, 15 files
```

### RHEL
```bash
❯ tree rhel
rhel
├── generic.ins
└── images
    ├── boot.cat
    ├── cdboot.img
    ├── cdboot.prm
    ├── genericdvd.prm
    ├── generic.prm
    ├── initrd.addrsize
    ├── initrd.img
    ├── install.img
    ├── kernel.img
    └── redhat.exec

2 directories, 11 files
```

## Sample .ins Files (LPAR Boot Instructions)

The .ins file for LPAR (often named generic.ins) specifies the kernel, initrd, parm file, and an address size file, along with the memory load addresses. The RHCOS ISO provides these files under an images/ directory. A minimal example (for RHCOS 4.x on s390x) is as follows​ [@rhel_boot_params] [@ibm_install_ocp].

```bash
images/kernel.img 0x00000000
images/initrd.img 0x02000000
images/genericdvd.prm 0x00010480
images/initrd.addrsize 0x00010408
```

This assumes the ISO contents are available (e.g. via FTP or attached as virtual media) with the same directory structure. The above instructs the loader to place kernel.img at memory address 0, initrd.img at 0x02000000, the parameter file at 0x00010480, and the initrd.addrsize file at 0x00010408 (these standard addresses are provided by Red Hat​ [@rhel_boot_params]). You would point the HMC to this .ins file when IPLing the LPAR to boot RHCOS.


```bash
# No diff between RHEL and RHCOS generic INS file
diff rhcos/generic.ins rhel/generic.ins| wc -l
0
```

## Sample .prm File (Kernel Parameters for RHCOS)
The genericdvd.prm file (or a copy thereof) contains the kernel boot parameters required to start the RHCOS installer on IBM Z. For RHCOS, the parameters direct the CoreOS live installer to the target install disk and the Ignition config. A minimal example for RHCOS 4.16 in an LPAR with Fiber Channel storage is below (line breaks are for readability; each space-separated entry is a kernel parameter):

```bash
rd.neednet=1 console=ttysclp0 coreos.inst.install_dev=sda 
coreos.live.rootfs_url=http://<HTTP_SERVER>/rhcos-416.94.202410211619-0-live-rootfs.s390x.img 
coreos.inst.ignition_url=http://<HTTP_SERVER>/ignition/worker.ign ip=dhcp 
nameserver=<DNS_IP> cio_ignore=all,!condev zfcp.allow_lun_scan=0 
rd.zfcp=0.0.<FCP_DEV>,0x<WWPN>,0x<LUN>
```


## RHCOS ISO Mount
```bash
# Mount RHCOS ISO from subdirectory
sudo mount -o loop ./rhcos/rhcos-416.94.202410211619-0-live.s390x.iso ~/mnt/rhcos
```

## RHEL ISO Mount
```bash
# Mount RHEL ISO from subdirectory
sudo mount -o loop ./rhel/rhel-9.5-s390x-boot.iso ~/mnt/rhel
```

## Working with ISO Content in Read-Write Mode
ISO9660 filesystems are inherently read-only. To work with the content in a read-write manner:

### Option 1: Extract and Work with Content
```bash
# For RHCOS
mkdir -p ~/rw-rhcos
cp -r ~/mnt/rhcos/* ~/rw-rhcos/
# Now modify content in ~/rw-rhcos/

# For RHEL
mkdir -p ~/rw-rhel
cp -r ~/mnt/rhel/* ~/rw-rhel/
# Now modify content in ~/rw-rhel/
```

### Option 2: Use OverlayFS (Advanced)
```bash
# For RHCOS
mkdir -p ~/overlay-rhcos/{lower,upper,work,merged}
sudo mount -o loop ./rhcos/rhcos-416.94.202410211619-0-live.s390x.iso ~/overlay-rhcos/lower
sudo mount -t overlay -o lowerdir=~/overlay-rhcos/lower,upperdir=~/overlay-rhcos/upper,workdir=~/overlay-rhcos/work overlay ~/overlay-rhcos/merged
# Now you can modify files in ~/overlay-rhcos/merged and changes will be stored in ~/overlay-rhcos/upper
```

### Option 3: Create a New ISO After Modifications
```bash
# After making changes in the extracted directory, create a new ISO:
sudo genisoimage -o new-rhcos.iso -r -J -V "RHCOS_NEW" ~/rw-rhcos/
```

## Unmount Commands
When you're done using the ISOs, unmount them with:
```bash
sudo umount ~/mnt/rhcos
sudo umount ~/mnt/rhel
```

# References

@rhel_boot_params https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/automatically_installing_rhel/preparing-a-rhel-installation-on-64-bit-ibm-z_rhel-installer#customizing-boot-parameters_preparing-a-rhel-installation-on-64-bit-ibm-z
@ibm_install_ocp https://community.ibm.com/community/user/ibmz-and-linuxone/blogs/gerald-hosch1/2024/07/26/installing-red-hat-openshift-with-lpar-on-ibm-z?communityKey=fd56de68-d38b-499b-a1f4-51010f4eee66