SUSE Support

Here When You Need Us

Configure autoyast to select disks by size order during install

This document (000021245) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 15
SUSE Linux Enterprise Server 12

Situation

When installing SLES on hardware with multiple block devices, it may be desirable to have autoyast automatically use the smallest block device for the root filesystem.

Resolution

Pre-script for SLE 12 and SLE 15.

This profile contains a "pre-script" that should provide the desired result.  The profile contains a "/dev/__DISK__" element which is replaced by the output of this command:

DISK=$(lsblk --noheadings --bytes -o NAME,SIZE,TYPE,TRAN -x SIZE | awk '{ if ($3 == "disk" && $4 != "usb") { print $1; exit} }')

The expression can fine-tuned, but it is a good starting point.

----
<profile xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns">
  <language>
    <language>en_US</language>
    <languages/>
  </language>
  <partitioning config:type="list">
    <drive>
      <device>/dev/__DISK__</device>
      <initialize config:type="boolean">true</initialize>
      <type config:type="symbol">CT_DISK</type>
      <use>all</use>
    </drive>
  </partitioning>
  <scripts>
    <pre-scripts config:type="list">
      <script config:type="map">
        <filename>set-installation-disk.sh</filename>
        <source>
          <![CDATA[ DISK=$(lsblk --noheadings --bytes -o NAME,SIZE,TYPE,TRAN -x SIZE | awk '{ if ($3 == "disk" && $4 != "usb") { print $1; exit} }') sed -e "s/__DISK__/$DISK/" /tmp/profile/autoinst.xml > /tmp/profile/modified.xml ]]>
        </source>
      </script>
    </pre-scripts>
  </scripts>
</profile>
----

Example for choosing the largest block device:
# lsblk --noheadings --bytes -o NAME,SIZE,TYPE,TRAN -x SIZE | sort -nrk 2 | awk '{ if ($3 == "disk" && $4 != "usb") { print $1; exit} }'

Example using "rota" as a filter only spinning block devices:
# lsblk --noheadings --bytes -o NAME,SIZE,TYPE,TRAN,rota -x SIZE | awk '{ if ($3 == "disk" && $4 != "usb" && $5 != 0) { print $1; exit} }'

Status

Top Issue

Additional Information

It appears that this functionality does exist with SLES15, starting with SLES15SP3:
https://documentation.suse.com/sles/15-SP5/single-html/SLES-autoyast/index.html#erb-disks-helper

> <partitioning t="list">
>   <drive>
>    <% disk = disks.sort_by { |d| d[:size] }.last %> <!-- find the largest disk -->
>    <device><%= disk[:device] %></device> <!-- print the disk device name -->
>    <initialize t="boolean">true</initialize>
>    <use>all</use>
>  </drive>
> </partitioning>

For the desired result, use the following syntax:

> <partitioning t="list">
>  <drive>
>    <% disk = disks.sort_by { |d| d[:size] }.first %> <!-- find the [smallest] disk -->
>    <device><%= disk[:device] %></device> <!-- print the disk device name -->
>    <initialize t="boolean">true</initialize>
>    <use>all</use>
>  </drive>
> </partitioning>

"ERB templates" are not available for SLES12SP5.
https://documentation.suse.com/sles/12-SP5/single-html/SLES-autoyast/index.html

Skipping devices is also an option:
https://documentation.suse.com/sles/15-SP5/html/SLES-all/cha-configuration-installation-options.html#CreateProfile-Partitioning-config

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:000021245
  • Creation Date: 20-Oct-2023
  • Modified Date:20-Oct-2023
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.