Format / Wipe Physical Disk

Disk Manager · Utilities~5 minView script

Securely wipe or format a physical disk on the Proxmox host. ProxMenux hides system disks, warns about any other use before you confirm, blocks disks used by a running VM or CT, and forces a double confirmation (yes/no plus typing the full disk path) before destroying any data.

Destructive tool

Every operation here writes to the disk. There is no undo. ProxMenux applies strict safety filters and confirmations, but the responsibility for picking the right disk is yours. Read the disk path out loud twice before you type it.

How the script runs

The flow has two phases with a triple-gate safety filter in between. The disk list, the operation mode and the file system details are all collected in Phase 1; nothing is written until Phase 2 passes a final re-validation right before executing.

┌─────────────────────────────────────────────┐
│  PHASE 1 — Filter, choose, confirm          │
│  (nothing touched yet)                      │
└──────────────────┬──────────────────────────┘
                   ▼
      Detect disks on host (lsblk)
                   │
                   ▼
      Visibility filter
      ├─ Hidden: system mount / swap / root pool
      ├─ Shown, blocked: used by a running VM/CT
      └─ Shown with warning: stopped guest ref,
         data mounts, ZFS / LVM / RAID members
                   │
                   ▼
      User picks a disk
                   │
                   ▼
      Operation mode
      ├─ 1. Wipe all         (partitions + sigs)
      ├─ 2. Remove FS labels (data preserved)
      ├─ 3. Zero all data    (partitions kept)
      └─ 4. Full format      (new GPT + mkfs)
                   │
                   ▼
      ╔════════════════════════════════════╗
      ║  Double confirmation gate           ║
      ║  (1) yes/no dialog with summary     ║
      ║  (2) type the full disk path exactly║
      ║      (e.g. /dev/sdc)                ║
      ║  Any mismatch → abort               ║
      ╚══════════════════╤═════════════════╝
                         │
  ┌──────── Cancel   OR   Confirm ────┐
  ▼                                   ▼
Exit, nothing             Mode = 4? → Filesystem:
was changed               ext4 / xfs / exfat / btrfs / zfs
                          (zfs → also asks the pool name)
                                      │
                     ┌────────────────┴──────────────────┐
                     │  PHASE 2 — Execute                 │
                     └─────────────────┬─────────────────┘
                                       ▼
                       Mode 4: install exfatprogs if
                       mkfs.exfat is missing; abort if
                       mkfs.btrfs is missing
                                       │
                                       ▼
                       Pre-execution re-validation
                       (state may have changed since
                        Phase 1 — user just confirmed)
                       ├─ Disk now hosts system mount?
                       │    → hard block, abort
                       ├─ Disk now in root ZFS pool?
                       │    → hard block, abort
                       ├─ Disk has active swap?
                       │    → hard block, abort
                       ├─ Data partitions still mounted?
                       │    → auto-unmount; abort if fails
                       ├─ Active ZFS pool on the disk?
                       │    → zpool export
                       └─ Used by a running VM/CT?
                            → hard block, abort
                                       │
                                       ▼
                       Run the selected mode:
                       ┌─────────────────────────────────┐
                       │ 1. Wipe all                     │
                       │    wipefs -af each partition    │
                       │    sgdisk --zap-all <disk>      │
                       │    blkdiscard (if supported)    │
                       │    zero first + last 16 MiB     │
                       ├─────────────────────────────────┤
                       │ 2. Remove FS labels             │
                       │    wipefs -af --types <fs/raid> │
                       │      <disk> + each partition    │
                       │    (partition table PRESERVED)  │
                       ├─────────────────────────────────┤
                       │ 3. Zero all data                │
                       │    For each partition:          │
                       │      dd if=/dev/zero of=<part>  │
                       │         bs=4M                   │
                       │    (partition table PRESERVED)  │
                       ├─────────────────────────────────┤
                       │ 4. Full format                  │
                       │    same wipe as mode 1          │
                       │    parted mklabel gpt           │
                       │    parted mkpart 1MiB 100%      │
                       │    mkfs.<fs> <disk>1            │
                       │    (zfs: zpool create <pool>)   │
                       └─────────────────────────────────┘

Visibility rules

Before the menu appears, ProxMenux filters the disk list. Only system disks are hidden; any other use is shown so you can decide:

  • Hidden: disks with a system mount (/, /boot, /usr, /var…), an active swap partition or a member of the ZFS root pool, plus read-only devices.
  • Shown, blocked at confirmation: disks referenced by a running VM or CT.
  • Shown with a warning: disks referenced by a stopped VM or LXC config, disks with mounted data partitions, and active ZFS / LVM / RAID members.

Safety at confirmation and execution

  • Disks with stale / active metadata show detailed warnings before you confirm.
  • Disks used by a running VM are hard-blocked at confirmation.
  • Mounted data partitions are unmounted automatically at execution and any active ZFS pool on the disk is exported. If a partition cannot be unmounted, execution aborts (a fresh re-validation runs right before anything is written).
  • Two confirmations are always required: yes/no dialog + typing the full disk path exactly.

Operation modes

After picking a disk you choose one of four modes. They differ in what they destroy and what they leave behind:

ModePartition tableDataUse case
1. Wipe allDestroyedSignatures wipedRemoves the partition table and the filesystem and RAID metadata, zeroes the first and last 16 MiB and, on drives that support discard, trims the whole disk. The rest of the data is not overwritten and may still be recoverable on HDDs; this is not a secure erase.
2. Remove FS labelsPreservedPreservedRemoves stale ZFS / LVM / RAID signatures so the disk is no longer auto-claimed. Bulk user data is not overwritten, but removing signatures can make it inaccessible.
3. Zero all dataPreservedDestroyed (zeroed)Overwrite the existing partitions with zeros while keeping the partition table. Unallocated space and SSD spare areas are not covered; this is not a complete device sanitization guarantee.
4. Full formatNew GPTDestroyedReady-to-use disk with a single new partition and a fresh filesystem or ZFS pool.

Full format asks one more question after the confirmation:

  • Filesystem: ext4, xfs, exfat (portable), btrfs or zfs. If mkfs.exfat is missing, ProxMenux installs exfatprogs; if mkfs.btrfs is missing, it aborts with a hint.
  • ZFS pool name (ZFS only): suggested as pool_<disk>. The pool is created with ashift=12 and lz4 compression.

Step-by-step

Step 1

Pick a free disk

ProxMenux lists every disk that passes the visibility filter above, with its model and size. Any metadata found on the disk (ZFS / LVM / RAID signatures, mounted partitions, guest references) is shown in the confirmation summary so you know what you are about to overwrite.

Step 2

Pick an operation mode

Choose between Wipe all, Remove FS labels, Zero all data or Full format according to the table above.

Step 3

Confirm twice

ProxMenux shows a summary of what will happen. You accept with a yes/no dialog and type the full disk path exactly as shown (for example /dev/sdc). Anything else aborts.

Step 4

(Full format only) Pick the filesystem

ext4 / xfs / exfat / btrfs / zfs. For ZFS, also the pool name.

Step 5

Re-validation and execution

Just before writing, the script re-checks the disk state. It aborts if the disk now holds a system mount, an active swap partition or a ZFS root pool member, or if a running VM or CT uses it. Mounted data partitions are unmounted and active ZFS pools on the disk are exported. Then the chosen operation runs.

Manual equivalents

If you prefer to run the equivalent commands by hand:

# --- mode 1: wipe all (partition table + signatures) ---
wipefs -af /dev/sdX
sgdisk --zap-all /dev/sdX

# --- mode 2: remove FS labels only (keep partitions + data) ---
# --types limits wipefs to filesystem/RAID signatures; without it,
# wipefs -af on the disk would also erase the partition table
types=$(blkid -k | paste -sd,)
wipefs -af --types "$types" /dev/sdX /dev/sdX?*

# --- mode 3: zero all data (keep partition table) ---
for p in /dev/sdX?*; do
  dd if=/dev/zero of="$p" bs=4M status=progress || true
done

# --- mode 4: full format (new GPT + filesystem) ---
wipefs -af /dev/sdX
sgdisk --zap-all /dev/sdX
parted -s /dev/sdX mklabel gpt mkpart primary 1MiB 100%   # one partition
mkfs.ext4 /dev/sdX1                        # pick the fs you want

Disk not listed in the menu

It was filtered for safety. Only system disks are hidden: a disk with a system mount (/, /boot, /usr, /var…), an active swap partition or a member of the ZFS root pool, or a read-only device. Data mounts, guest references and ZFS / LVM / RAID membership do not hide a disk. Run lsblk -f, swapon --show and zpool status on the host to understand why.

"Disk may be busy" / unmount failed

Something is still holding an open file on a partition of that disk — most often a container or a shell whose cwd is inside a mountpoint. Identify it with lsof | grep /dev/sdX or fuser -vm /dev/sdX1, stop it, then re-run the tool.

Related