Replies: 5 comments
-
I was just thinking, if install:
auto: true
device: >-
{{- $smallest := 99999 -}}
{{ $choice := "" }}
{{- range $disk := .Values.storage -}}
{{- if $disk.size < $smallest -}}
{{ $smallest = $disk.size }}
{{ $choice = $disk.name }}
{{- end -}}
{{- end -}}
{{- cat "/dev/" $choice | nospace }} Other very useful fields being |
Beta Was this translation helpful? Give feedback.
-
Even allowing to define an arbitrary shell script that returns the device to be used would be sufficient. |
Beta Was this translation helpful? Give feedback.
-
sysinfo is not available in that block because that one is evaluated by kairos-agent itself and not parsed by yip. Making sysinfo work in that block too is another way to fix it. |
Beta Was this translation helpful? Give feedback.
-
All valid answers. For the time being, what can I do to workaround this? stages:
after-install-chroot:
- name: "Install Longhorn Prerequisites"
commands:
- apt install parted
initramfs:
- name: "Get the largest disk"
commands: [ LARGEST_DISK=$(lsblk -AJ | jq -r '[.blockdevices[] | select(.type == "disk") | {name, size: (.size | rtrimstr("G") | tonumber)}] | max_by(.size) | .name') ]
- name: "Partition disk"
if: >-
[ $(sudo fdisk -l /dev/$LARGEST_DISK | grep -q "83 Linux"; echo $?) -ne 0 ]
commands:
- sudo parted /dev/$LARGEST_DISK rm 1
- parted /dev/$LARGEST_DISK --script -- mkpart primary 0 -1
- name: "Format disk if needed"
if: >-
[ $(sudo lsblk -o FSTYPE /dev/$LARGEST_DISK | tail -n 1 | wc -l) -eq 0 ]
commands:
- mkfs.ext4 -F /dev/$LARGEST_DISK
boot:
- name: "Mount /dev/$LARGEST_DISK under /mnt/longhorn"
commands:
- mount -o rw /dev/sdb1 /mnt/longhorn |
Beta Was this translation helpful? Give feedback.
-
I think you can technically get the functionality necessary by latching onto #cloud-config
install:
# Make sure the installer won't delete our custom partitions
no-format: true
stages:
kairos-install.pre.before:
- if: '[ -e /dev/sda ] && [ -e /dev/nvme0n1 ] && [ $(fdisk -l /dev/sda | grep sectors | head -n 1 | cut -d" " -f5) -lt $(fdisk -l /dev/nvme0n1 | grep sectors | head -n 1 | cut -d" " -f5) ]'
name: "Conditionally partition sda"
commands:
- |
parted --script --machine -- /dev/sda mklabel msdos
layout:
device:
path: /dev/sda
expand_partition:
size: 0 # All available space
add_partitions:
# all sizes bellow are in MB
- fsLabel: COS_OEM
size: 64
pLabel: oem
- fsLabel: COS_RECOVERY
size: 8500
pLabel: recovery
- fsLabel: COS_STATE
size: 18000
pLabel: state
- fsLabel: COS_PERSISTENT
pLabel: persistent
size: 25000
filesystem: "ext4"
- if: '[ -e /dev/sda ] && [ -e /dev/nvme0n1 ] && [ $(fdisk -l /dev/sda | grep sectors | head -n 1 | cut -d" " -f5) -ge $(fdisk -l /dev/nvme0n1 | grep sectors | head -n 1 | cut -d" " -f5) ]'
name: "Conditionally partition nvme0n1"
commands:
- |
parted --script --machine -- /dev/nvme0n1 mklabel msdos
layout:
device:
path: /dev/nvme0n1
expand_partition:
size: 0 # All available space
add_partitions:
# all sizes bellow are in MB
- fsLabel: COS_OEM
size: 64
pLabel: oem
- fsLabel: COS_RECOVERY
size: 8500
pLabel: recovery
- fsLabel: COS_STATE
size: 18000
pLabel: state
- fsLabel: COS_PERSISTENT
pLabel: persistent
size: 25000
filesystem: "ext4" I think what I suggested above with sysinfo and templating would be one of the lower-effort ways of solving this but another way to solve this is to make that field "smarter" by allowing the following options which behave in the way users would expect:
And then allow YAML objects in addition to the simple strings above for install:
device:
driver: sd / nvme / auto
size: smallest / largest / auto / 500
model: ST950*
|
Beta Was this translation helpful? Give feedback.
-
Selecting the Appropriate Installation Disk Based on Size
In my current cloud configuration, the Kairos system is set to install on the disk designated as
/dev/sda
, in line with the directive provided in my.install.device
configuration.This setup would function for me if all my nodes had the same disk configuration. However, what I have is:
The installation process would benefit from a more versatile disk selection strategy that can dynamically choose either the smallest or largest disk based on the specified preference. This logic could be integrated into the installation settings:
Proposed Solution for Disk Selection
I'd like to propose an enhancement to the installation configuration to include an option for selecting the smallest available disk automatically. This would require internal logic to identify and select the disk with the smallest capacity for installation. Additionally, a reboot option should be incorporated post-installation.
If this were to be implemented, it would remove boilerplate configuration for provisioning a secondary disk, as shown below:
Beta Was this translation helpful? Give feedback.
All reactions