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.


SUSE Linux Enterprise Server 15
SUSE Linux Enterprise Server 12


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.


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="" xmlns:config="">
  <partitioning config:type="list">
      <initialize config:type="boolean">true</initialize>
      <type config:type="symbol">CT_DISK</type>
    <pre-scripts config:type="list">
      <script config:type="map">
          <![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 ]]>

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} }'


Top Issue

Additional Information

It appears that this functionality does exist with SLES15, starting with SLES15SP3:

> <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.

Skipping devices is also an option:


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 Support Forums

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

Join Our Community

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.

SUSE Customer Support Quick Reference Guide SUSE Technical Support Handbook Update Advisories
Support FAQ

Open an Incident

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

Go to Customer Center