Wiping baremetal server disks

If you ever need to clean the disks on a bare-metal machine running Linux, this is a quick reference on how to do it in our Hetzner environment.

tip

If you are facing an issue and see this error message: Error: Error Message: DetectLinuxOnAnotherDisk failed (permanent error): FAIL: nvme0n1p1 eui.002538bb31006f8f looks like a Linux /boot/efi partition on another disk. , the process described in this page will solve it.

Using The Annotation

The first way to wipe the disks is by using the annotation wipe-disks in the HetznerBareMetalHost object. Servers with this annotation will have the indicated disks wiped the next time it's provisioned.

baremetalhosts.yaml yaml
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: HetznerBareMetalHost metadata: name: baremetal-1 annotations: // [!code tooltip:all:1:All disks in this server will be wiped] capi.syself.com/wipe-disk: all spec: description: My first baremetal machine serverID: 1234567 rootDeviceHints: wwn: eui.726163646f6d2d2d maintenanceMode: false --- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: HetznerBareMetalHost metadata: name: baremetal-2 annotations: // [!code tooltip:eui.737472696e677349cd:1:Only the disk with the corresponding WWN will be wiped] capi.syself.com/wipe-disk: eui.737472696e677349cd spec: description: My second baremetal machine serverID: 7654321 rootDeviceHints: wwn: eui.737472696e677349cd maintenanceMode: false

If you have already added the server to the cluster, you can scale down and up again the associated machine deployment to trigger a reprovisioning.

Otherwise, the server disks will be wiped the next time you perform an update.

Using The Rescue System

Another way to wipe the disks is by doing it manually using the rescue system.

We recommend using the annotation method, but the manual way is explained here for users in older versions of Autopilot that don't yet support the wipedisk annotation.

Activate Rescue

Access the Hetzner Console and go to the Robot servers.

After selecting the server you want to wipe, go to the Rescue tab, select the appropriate ssh key and keyboard layout, and enable the rescue system.

Now you need to reboot the machine in the Reset tab. To enter the rescue system, only a "Send CTRL+ALT+DEL to server" reset will work. The machine will take a few minutes to become available after the reboot.

Wipe the disks

SSH into the machine using the key you specified in the previous step.

For disks without RAID, do the steps below:

shell
lsblk # List the disks wipefs -af /dev/sdx # Wipe the "sdx" disk, where sdx is the label of the disk, listed with lsblk. Most frequently will be in the sdX or nvmeXnY format.

For disks on RAID:

shell
lsblk # List the disks mdadm --stop /dev/sdx # Stop RAID wipefs -af /dev/sdx # Wipe the "sdx" disk, where sdx is the label of the disk, listed with lsblk. Most frequently will be in the sdX or nvmeXnY format.

Repeat this process for all disks in the machine as needed.

Next
Introduction to Syself Autopilot