Securely wiping a disk or partition in Linux prevents previously stored data from being recovered when a drive is repurposed, decommissioned, or handed off to another party. Regular deletion and formatting operations mostly update filesystem metadata, leaving underlying blocks intact for forensic tools, so sensitive information can survive long after a filesystem has been removed.

Block devices exposed as /dev/sdX or /dev/nvmeXnY present the raw storage that sits beneath filesystems and partition tables. Overwriting every block with known patterns or instructing the controller to discard all blocks ensures old content is no longer accessible through normal interfaces. Tools such as lsblk, dd, and blkdiscard work together to identify the correct device and apply the wipe at the device layer instead of within a single filesystem.

Destructive write operations can instantly erase operating systems and data if pointed at the wrong device, so careful identification of disk names and mount points is essential. Solid-state drives use wear‑leveling, which changes how overwrites behave compared to spinning disks and makes controller-level discard operations preferable to repeated random passes. Running the procedure from a live environment after creating any required backups reduces the risk of accidentally wiping an active or irreplaceable system.

Steps to completely wipe a disk or partition in Linux:

  1. Open a terminal with access to a user account in the sudo group.
    $ whoami
    user

    sudo access is required because wiping operations target block devices such as /dev/loop3 that are owned by the root user.

  2. List available disks and partitions to locate the target device name.
    $ lsblk
    NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
    loop0    7:0    0   512M  0 loop /mnt/bench
    loop1    7:1    0   300M  0 loop 
    loop2    7:2    0   128M  0 loop 
    loop3    7:3    0    64M  0 loop /mnt/wipe-target
    nbd0    43:0    0     0B  0 disk 
    nbd1    43:32   0     0B  0 disk 
    nbd2    43:64   0     0B  0 disk 
    nbd3    43:96   0     0B  0 disk 
    nbd4    43:128  0     0B  0 disk 
    nbd5    43:160  0     0B  0 disk 
    nbd6    43:192  0     0B  0 disk 
    nbd7    43:224  0     0B  0 disk 
    vda    254:0    0   1.8T  0 disk 
    `-vda1 254:1    0   1.8T  0 part /etc/hosts
                                     /etc/hostname
                                     /etc/resolv.conf
    vdb    254:16   0 606.5M  1 disk 
    nbd8    43:256  0     0B  0 disk 
    nbd9    43:288  0     0B  0 disk 
    nbd10   43:320  0     0B  0 disk 
    nbd11   43:352  0     0B  0 disk 
    nbd12   43:384  0     0B  0 disk 
    nbd13   43:416  0     0B  0 disk 
    nbd14   43:448  0     0B  0 disk 
    nbd15   43:480  0     0B  0 disk 

    Match the capacity and TYPE fields to the intended target to avoid selecting the system disk or an external device that must be kept.

  3. Ensure the target disk or partition is not the current system disk or an active mount.
    $ lsblk -f
    NAME   FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
    loop0                           451.3M     0% /mnt/bench
    loop1                                         
    loop2                                         
    loop3                            51.5M     0% /mnt/wipe-target
    nbd0                                          
    nbd1                                          
    nbd2                                          
    nbd3                                          
    nbd4                                          
    nbd5                                          
    nbd6                                          
    nbd7                                          
    vda                                           
    `-vda1                            1.7T     1% /etc/hosts
                                                  /etc/hostname
                                                  /etc/resolv.conf
    vdb                                           
    nbd8                                          
    nbd9                                          
    nbd10                                         
    nbd11                                         
    nbd12                                         
    nbd13                                         
    nbd14                                         
    nbd15                                         

    Selecting a mounted system disk such as /dev/vda typically destroys the running installation and leaves the machine unbootable.

  4. Unmount the target partition if it has a mount point.
    $ sudo umount /dev/loop3

    Unmounting ensures no filesystem activity interferes with the wiping operation; use a live environment when the target contains the active root filesystem.

  5. For traditional HDD media or non‑TRIM‑aware devices, overwrite the entire disk with zeros.
    $ sudo dd if=/dev/zero of=/dev/loop3 bs=1M status=progress oflag=direct
    dd: error writing '/dev/loop3': No space left on device
    65+0 records in
    64+0 records out
    67108864 bytes (67 MB, 64 MiB) copied, 0.0253249 s, 2.6 GB/s

    The dd command irreversibly overwrites every block on the specified device; an incorrect of= value erases the wrong disk without any interactive confirmation.

  6. For SSD devices that support TRIM, discard all blocks using blkdiscard instead of repeated overwrites.
    $ sudo blkdiscard /dev/loop3

    blkdiscard instructs the controller to mark all blocks as unused, which can complete almost instantly; verify the device name very carefully before running the command.

  7. Inform the kernel that the partition table on the wiped disk has changed or is now empty.
    $ sudo partprobe /dev/loop3
    sh: 1: udevadm: not found
    sh: 1: udevadm: not found

    partprobe forces a rescan so tools such as lsblk and partition editors see the updated layout.

  8. Verify that no partitions remain on the wiped disk and that it appears only as a bare device.
    $ lsblk
    NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
    loop0    7:0    0   512M  0 loop /mnt/bench
    loop1    7:1    0   300M  0 loop 
    loop2    7:2    0   128M  0 loop 
    loop3    7:3    0    64M  0 loop 
    nbd0    43:0    0     0B  0 disk 
    nbd1    43:32   0     0B  0 disk 
    nbd2    43:64   0     0B  0 disk 
    nbd3    43:96   0     0B  0 disk 
    nbd4    43:128  0     0B  0 disk 
    nbd5    43:160  0     0B  0 disk 
    nbd6    43:192  0     0B  0 disk 
    nbd7    43:224  0     0B  0 disk 
    vda    254:0    0   1.8T  0 disk 
    `-vda1 254:1    0   1.8T  0 part /etc/hosts
                                     /etc/hostname
                                     /etc/resolv.conf
    vdb    254:16   0 606.5M  1 disk 
    nbd8    43:256  0     0B  0 disk 
    nbd9    43:288  0     0B  0 disk 
    nbd10   43:320  0     0B  0 disk 
    nbd11   43:352  0     0B  0 disk 
    nbd12   43:384  0     0B  0 disk 
    nbd13   43:416  0     0B  0 disk 
    nbd14   43:448  0     0B  0 disk 
    nbd15   43:480  0     0B  0 disk 
  9. Optionally read a small portion of the device to confirm only zeros or non‑structured data remains.
    $ sudo head -c 64 /dev/loop3 | od -An -tx1
     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    *

    Random or all‑zero output with no filesystem signatures indicates that previous data and partition metadata were successfully removed.