SUSE Support

Here When You Need Us

sgdisk -e causes unintended GPT partition table creation

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

Environment

SUSE Linux Enterprise Server 15 SP6
SUSE Linux Enterprise Server for SAP Applications 15 SP6


Situation

Using sgdisk -e on a raw disk without an existing partitioning scheme unexpectedly creates a new GPT, potentially causing data loss.

Resolution

This is expected and intended behavior. There is no separate "write" option in sgdisk, so any command that changes the partition table, including "-e", will cause it to write those changes to disk. As an alternative,  the "-P" ("--pretend") option can be used to prevent changes from being written to disk (this is not called out for each and every option).

Cause

Although the sgdisk man page does not explicitly state that a GPT will be created if none exists, this behavior is not unique to the "-e" option, other commands exhibit similar behavior. Therefore, documenting this behavior solely under the "-e" option would be misleading. Such cases are addressed by the general warning in the documentation [1]:

Warning: Not for Interactive Use

Additional Information

Using this option on a disk without an existing GPT can result in data loss, as it unconditionally writes a new GPT partition table, potentially destroying pre-existing structures such as LVM metadata.

Steps to reproduce:

1. Raw disk without a partition table on it:

sles15-sp6-clone:~ # parted -s /dev/vdb p 
Error: /dev/vdb: unrecognised disk label
Partition Table: unknown

2. Using sgdisk -e on that disk, produces:

sles15-sp6-clone:~ # sgdisk -e /dev/vdb
Creating new GPT entries in memory.
The operation has completed successfully.

3. Checking the disk again:

sles15-sp6-clone:~ # parted -s /dev/vdb p 
Partition Table: gpt

[1] https://www.rodsbooks.com/gdisk/sgdisk-walkthrough.html

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:000021858
  • Creation Date: 03-Jun-2025
  • Modified Date:03-Jun-2025
    • SUSE Linux Enterprise Server
    • SUSE Linux Enterprise Server for SAP Applications

< Back to Support Search

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

tick icon

SUSE Support Forums

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

tick icon

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.

tick icon

Open an Incident

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