Skip to content

Instantly share code, notes, and snippets.

@je8n
Created November 18, 2025 17:42
Show Gist options
  • Select an option

  • Save je8n/5ff34d48db8081eb95c5c7da247ad259 to your computer and use it in GitHub Desktop.

Select an option

Save je8n/5ff34d48db8081eb95c5c7da247ad259 to your computer and use it in GitHub Desktop.
0 ) start system with ubuntu debian live cd. First, under windows -> power options -> there is a parameter called fast wake-up, make sure it is turned off.
1 ) open cli. blkid > get nvme path => "/dev/nvme0n1" put script first variable
2 ) The following script is saved to a file. => "wipe.sh"
3 ) add execute attribute with "chmod +x wipe.sh" to script, and run script "sudo ./wipe.sh"
4 ) stript steps
- Necessary packages for nvme disk will be installed
- Hardware self-resetting feature of nvme disks is activated
- The disk is formatted as a single partition
- waiting for 2 seconds
- Random data is written on the disk
- disk formatting slowly
- The system is shutting down.
5 ) Any operating system can then be installed from scratch. The disk is in undivided RAW format.
6 ) To switch to GPT partitioning, the disk can be converted from mbr to gpt by going to the command line with windows + F10 while on the windows installation screen -> diskpart -> list disk -> select disk 0 -> convert gpt (MBR is limited to 2 TB of storage and four partitions; GPT supports larger drives and more than four partitions.)
-----------------
#!/bin/bash
# FULLY DANGEROUS DISK RESET SCRIPT (MBR)
# /dev/nvme0n1 PERMANENTLY DELETE ALL DATA ON IT!
DISK="/dev/nvme0n1"
PART="${DISK}p1"
echo "WARNING: $DISK will be completely deleted and recreated with MBR!"
read -p "WRITE 'YES' TO CONTINUE: " ONAY
if [[ "$ONAY" != "YES" ]]; then
echo "The transaction has been cancelled."
exit 1
fi
sudo apt update -y
sudo apt install -y util-linux gdisk parted ntfs-3g coreutils
echo "1) Partition tables, signatures and metadata are being cleared..."
sudo wipefs -a $DISK
sudo sgdisk --zap-all $DISK
if [[ "$DISK" == *nvme* ]]; then
echo "2) NVMe Secure Erase is in progress..."
sudo apt install -y nvme-cli
sudo nvme format "$DISK" -s 1
else
echo "If it is not an NVMe disk, this step is skipped."
fi
echo "3) Creating MBR (msdos) disk label..."
sudo parted $DISK mklabel msdos -s
echo "4) A single primary NTFS partition covering the entire disk is created..."
sudo parted -a optimal $DISK mkpart primary ntfs 1MiB 100% -s
sleep 2
echo "5) Random data is written on the partition (fills the entire disk)..."
sudo dd if=/dev/urandom of=$PART bs=1M status=progress
echo "6) NTFS slow format initialization (with badblock scanning)..."
sudo mkfs.ntfs -f -c $PART
echo "7) The process is completed. System is shutting down..."
sudo shutdown -h now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment