[LINUX] Completely erase the data on the hard disk

Introduction

When it becomes necessary to completely format the data, such as when discarding the hard disk, simply deleting the file may cause it to be stolen by using recovery software. Use the dd command to delete the complete data.

Check disk information

The device is / dev / sdX.

$ sudo fdisk -l /dev/sdX
disk/dev/sdX: 1.8 TiB,2000398934016 bytes,3907029168 sector
unit:sector(1 * 512 =512 bytes)
Sector size(logic/Physics):512 bytes/4096 bytes
I/O size(minimum/Recommendation):4096 bytes/4096 bytes

The physical sector size seems to be 4096 bytes. The total number of physical sectors is 2000398934016/4096 = 488378646 sectors.

Delete the entire disk

Write a random number. If the capacity is large, it will take time, so execute it when the resources of the PC are sufficient.

$ sudo dd if=/dev/urandom of=/dev/sdX bs=4096 count=488378646 seek=0 status=progress

Reference site

https://wiki.archlinux.jp/index.php/ディスクの完全消去

Recommended Posts

Completely erase the data on the hard disk
Start data science on the cloud
Looking back on the data M-1 Grand Prix 2020
Analyzing data on the number of corona patients in Japan
Data analysis based on the election results of the Tokyo Governor's election (2020)
Deploy the strongest front-end Streamlit for data scientists on Azure!