I need to safely format my hardrive. I booted from a usb key and I am planning to run the following command on the whole hard drive:
sudo shred -v -n3 -z /dev/the-partition
My question is: how do I identify all the partitions that there are in order to totally wipe out the hard drive?
Here's the output of lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 1.8G 1 loop /rofs
loop1 7:1 0 91M 1 loop /snap/core/6350
loop2 7:2 0 34.6M 1 loop /snap/gtk-common-themes/818
loop3 7:3 0 140.7M 1 loop /snap/gnome-3-26-1604/74
loop4 7:4 0 2.3M 1 loop /snap/gnome-calculator/260
loop5 7:5 0 13M 1 loop /snap/gnome-characters/139
loop6 7:6 0 14.5M 1 loop /snap/gnome-logs/45
loop7 7:7 0 3.7M 1 loop /snap/gnome-system-monitor/57
sda 8:0 1 7.5G 0 disk /cdrom
├─sda1 8:1 1 1.9G 0 part
└─sda2 8:2 1 2.4M 0 part
nvme0n1 259:0 0 238.5G 0 disk
and here's is df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 786M 1.7M 785M 1% /run
/dev/sda 1.9G 1.9G 0 100% /cdrom
/dev/loop0 1.8G 1.8G 0 100% /rofs
/cow 3.9G 331M 3.6G 9% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
tmpfs 3.9G 0 3.9G 0% /tmp
tmpfs 786M 44K 786M 1% /run/user/999
/dev/loop1 91M 91M 0 100% /snap/core/6350
/dev/loop2 35M 35M 0 100% /snap/gtk-common-themes/818
/dev/loop3 141M 141M 0 100% /snap/gnome-3-26-1604/74
/dev/loop4 2.3M 2.3M 0 100% /snap/gnome-calculator/260
/dev/loop5 13M 13M 0 100% /snap/gnome-characters/139
/dev/loop6 15M 15M 0 100% /snap/gnome-logs/45
/dev/loop7 3.8M 3.8M 0 100% /snap/gnome-system-monitor/57
Why not shred then entire device (important! choose the right device to shred!):
... rather than
I like
lsblk
, it show device name and partition inside it, as well the mounted partition.sudo fdisk -l
gives more detail, but it requires superuser access.I always uses
lsblk
to detect the drive, then register/dev/zero
to wipe the disk.To get a more meaningful report from
lsblk
without the noise from dozens ofloop
devices use:If you want to completely wipe everything:
shred
, it's primarily meant for files, not disks./dev/nvme0n1
, instead of each partition individually.Addendum: When using the "use the whole disk device" method, check if there is a HPA set up (with hdparm -N, please read the manual for the version at hand, getting hdparm command lines wrong can mess up things BAD), and remove it in that case.