Disk Operations
system.disk
Protects against destructive disk operations like dd to devices, mkfs, partition table modifications, RAID management, btrfs/LVM/device-mapper operations, network block devices, and macOS diskutil erase/partition/APFS deletion
- 59blocking rules
- 19safe patterns
- 15Critical
- 44High
On by default. To turn it off:
[packs]
disabled = ["system.disk"]Evaluated when a command contains dd, diskutil, fdisk, mkfs, mke2fs, mkdosfs, mkntfs, mkexfatfs, newfs, newfs_apfs.
Recorded verdicts
dd if=/dev/zero of=/dev/disk2 bs=1mBlockedsystem.disk:dd-device
Blocking rules
Each rule ID is system.disk:<name>. Use it in allowlists and [policy.rules].
Criticalbadblocks-writebadblocks -w (write mode) overwrites every block on the device with test patterns, destroying all existing data.
Criticalblkdiscardblkdiscard discards (TRIMs) every block on the device, destroying all data instantly with no undo.
Criticalcryptsetup-erasecryptsetup erase/luksErase/luksFormat destroys the LUKS key material; the encrypted volume becomes permanently unreadable.
Criticalddrescue-deviceddrescue --force writes its output onto a device, overwriting all data on it, exactly as dd would.
Criticaldiskutil-apfs-deletediskutil apfs delete/erase operations permanently remove APFS containers, volumes, or snapshots.
Explanation
Deleting an APFS container destroys every volume inside it; deleting or erasing a volume destroys that volume's data; deleting a snapshot removes a restore point. None of these are recoverable without backups. List APFS structure first: diskutil apfs list
Criticaldiskutil-erasediskutil erase operations DESTROY all data on the target disk or volume.
Explanation
diskutil eraseDisk/eraseVolume/reformat/zeroDisk/randomDisk/secureErase overwrite the target's contents. On APFS this removes every volume in the container. There is no recovery without backups. Inspect the target first: diskutil list diskutil info <disk>
Criticaldiskutil-partitiondiskutil partitioning operations rewrite the partition map and erase data.
Explanation
diskutil partitionDisk erases the entire disk before writing the new partition map; splitPartition and mergePartitions destroy the contents of the partitions they reshape (merge preserves only the first when asked); resetFusion wipes both constituent devices. Preview the current layout first: diskutil list <disk>
Criticalhdparm-security-erasehdparm --security-erase issues an ATA secure erase of the WHOLE drive at the firmware level. Unrecoverable.
Criticalnvme-format-sanitizenvme format/sanitize erases an NVMe namespace (or the entire controller). All data is destroyed.
Criticalnwipenwipe (the dban successor) overwrites an entire disk with wipe patterns; `--autonuke` targets every disk. All data is destroyed.
Criticalscrub-devicescrub overwrites a device with data-destruction patterns (DoD/Gutmann/etc.); its contents are gone.
Criticalsg_formatsg_format --format performs a SCSI low-level format, erasing all data on the medium.
Criticalwipe-devicewipe securely overwrites the target device, destroying all data on it.
Criticalzfs-destroyzfs destroy removes a ZFS dataset, volume, or snapshot; with -r it destroys the whole descendant tree.
Criticalzpool-destroyzpool destroy removes a ZFS pool and every dataset, snapshot, and byte of data it contains.
Highbtrfs-balancebtrfs balance redistributes data across devices. Can be slow and disruptive.
Highbtrfs-check-repairbtrfs check --repair is DANGEROUS and can cause data loss. Backup first!
Highbtrfs-device-addbtrfs device add incorporates a device into the filesystem. Verify the device is correct.
Highbtrfs-device-removebtrfs device remove redistributes data off a device. Interruption causes data loss.
Highbtrfs-filesystem-resizebtrfs filesystem resize can shrink a filesystem. Data loss if size is too small.
Highbtrfs-rescuebtrfs rescue operations modify filesystem metadata. Use only as last resort.
Highbtrfs-subvolume-deletebtrfs subvolume delete PERMANENTLY removes a subvolume and all its data.
Highcopy-to-deviceCopying or moving onto a device OVERWRITES that device, exactly as dd would. Extremely dangerous!
Highdd-devicedd to a block device will OVERWRITE all data on that device. Extremely dangerous!
Highdd-wipedd from /dev/zero or /dev/urandom to a device will WIPE all data!
Highdmsetup-cleardmsetup clear removes the mapping table from a device.
Highdmsetup-createdmsetup create sets up a new device-mapper device. Verify parameters carefully.
Highdmsetup-loaddmsetup load changes device mapping. Verify the new table is correct.
Highdmsetup-removedmsetup remove detaches a device-mapper device. May cause data loss if in use.
Highdmsetup-remove-alldmsetup remove_all removes ALL device-mapper devices. Extremely dangerous!
Highdmsetup-wipe-tabledmsetup wipe_table replaces the device table, causing all I/O to fail.
Highfdisk-editfdisk can modify partition tables and cause data loss.
Highgdisk-editgdisk/cgdisk open the GPT for interactive editing; a write from that session destroys the partition table.
Explanation
gdisk and cgdisk are editors: they load the partition table and apply what the session writes back. An agent that cannot see the prompts cannot know what it is about to commit. Read the table instead, which is never blocked: gdisk -l /dev/sda sgdisk --print /dev/sda lsblk /dev/sda
Highlosetup-devicelosetup modifies loop device associations. Verify before proceeding.
Highlvconvert-mergelvconvert --merge reverts LV to snapshot state, discarding changes since snapshot.
Highlvreducelvreduce SHRINKS a logical volume. Data loss if filesystem isn't resized first!
Highlvremovelvremove PERMANENTLY deletes a logical volume and ALL its data.
Highlvresize-shrinklvresize with negative size SHRINKS the volume. Resize filesystem first or lose data!
Highmdadm-createmdadm --create initializes a new RAID array, ERASING existing data on member devices.
Highmdadm-failmdadm --fail marks a device as failed. Use only for intentional drive replacement.
Highmdadm-growmdadm --grow reshapes a RAID array. Interruption can cause data loss. Backup first.
Highmdadm-removemdadm --remove removes a drive from a RAID array. May cause data loss if redundancy is lost.
Highmdadm-stopmdadm --stop shuts down a RAID array. Data may become inaccessible.
Highmdadm-zero-superblockmdadm --zero-superblock PERMANENTLY erases RAID metadata. Array cannot be reassembled.
Highmkfsmkfs formats a partition/device and ERASES all existing data.
Highmkswapmkswap formats a partition as a swap area, ERASING any existing data.
Highmount-bind-rootmount --bind to root directory can have system-wide effects.
Highnbd-client-connectnbd-client connecting a device can expose or overwrite data. Verify server and device.
Highnbd-client-disconnectnbd-client -d disconnects a network block device. Data loss if not properly unmounted.
Highparted-modifyparted can modify partition tables and cause data loss.
Highpvmovepvmove migrates data between physical volumes. Do NOT interrupt or data may be lost.
Highpvremovepvremove ERASES LVM metadata from a physical volume. Data becomes inaccessible.
Highsfdisk-modifysfdisk rewrites the partition table: options act immediately, and a bare invocation reads a new layout from stdin.
Explanation
sfdisk is non-interactive by design. Pointed at a device it either applies the requested change (`--delete`, `--part-type`, `--wipe`, `--relocate`) or replaces the whole table with the script on stdin. There is no confirmation and no undo. What stays allowed: - Inspecting: `sfdisk -l /dev/sda`, `sfdisk --json /dev/sda`. - Saving the table: `sfdisk --dump /dev/sda > table.sfdisk`. - Rehearsing: add `-n`/`--no-act`.
Highsgdisk-modifysgdisk rewrites the GPT; --zap-all/-Z also erases the protective MBR, losing every partition.
Explanation
sgdisk applies its options and exits — there is no confirmation step and no undo. `--zap-all`/`-Z` destroys the GPT and the protective MBR together; `--clear`/`-o`, `--delete`/`-d`, `--new`/`-n` and `--typecode`/`-t` each rewrite the partition table in place. On a UEFI disk that is the same blast radius as `parted mklabel`, which is already denied. What stays allowed: - Inspecting the table: `sgdisk --print /dev/sda`, `sgdisk -i 1 /dev/sda`. - Saving it: `sgdisk --backup=/tmp/table.bin /dev/sda`. - Rehearsing a change: add `-P`/`--pretend` to see what would happen. Before changing anything, back the table up and look at the device: sgdisk --backup=/tmp/table.bin /dev/sda lsblk /dev/sda
Hightee-devicetee/sponge into a device will OVERWRITE that device, exactly as dd would. Extremely dangerous!
Highumount-forceumount -f force unmounts which may cause data loss if device is in use.
Highvgreducevgreduce removes a physical volume from a volume group. Data may be lost.
Highvgremovevgremove DELETES a volume group and all logical volumes within it.
Highwipefswipefs removes filesystem signatures. Use with extreme caution.
Safe patterns
Checked first. A command that matches one is never blocked by this pack.
dd-discardlsblkblkiddfparted-printbtrfs-subvolume-listbtrfs-subvolume-showbtrfs-filesystem-showbtrfs-filesystem-dfbtrfs-filesystem-usagebtrfs-device-statsbtrfs-property-getbtrfs-scrub-statusdmsetup-lsdmsetup-statusdmsetup-infodmsetup-tabledmsetup-depsdiskutil-readonly