Sample Header Ad - 728x90

Why is blkdiscard not erasing all data of the whole drive?

1 vote
0 answers
1860 views
I have an old mSATA SSD (model name: Plextor PX-128M6M), which is installed to an mSATA-to-USB enclosure with ASM1153E controller. I want to *(just logically, at the SSD controller level)* erase all of its data. However, it seemed that: 1. blkdiscard command does not actually erase all requested region of data, just the beginning 2GiB minus 32KiB of data was actually erased. 2. hdparm --trim-sector-ranges-stdin seems to work fine, however, the SSD controller *(of this model of SSD specifically, another model does not seem to behave like this)* seems to be protecting the first 8 sectors (4KiB of data) from being erased by TRIM command. -------- My attempts and experiments are as follows: 1. I was doing this under Ubuntu 23.04. 2. Thanks to the guides from Arch Wiki, I found that I have to set /sys/block/sdX/device/scsi_disk/*/provisioning_mode to unmap first. It was full initially. After that, I thought the system was then able to send SCSI UNMAP command (through UASP, translated into TRIM command by the controller) to the old SSD. 3. I then did this to the whole drive: blkdiscard -f -v /dev/sdX (sdX is the actual device name), it then reported that all bytes (matches with the disk capacity) was discarded (erased), however I found that both the main GPT and the backup GPT at the beginning/end of disk space were still not erased. 4. I created a partition sized 2GiB, and then filled it with random data drained from /dev/urandom. 5. blkdiscard -f -v /dev/sdX was done on the whole drive, hexdump then showed that the last 1MiB + 32KiB of the first partiton was not erased (the partition starts from LBA 2048, with a sector size of 512 Bytes). 6. After re-executing blkdiscard -f -v /dev/sdX1 on the new partition instead of the whole drive, hexdump showed that the last 32KiB of this partition was not erased. 7. I then tried hdparm --trim-sector-ranges-stdin, with a list of all sectors of the whole drive fed from stdin. This time the main GPT still stood, but all remaining data was erased to zero. 8. I filled the first 2048 sectors with /dev/urandom data. Then hdparm --trim-sector-ranges-stdin seemed to erase all data except the first 8 sectors (4KiB of data). -------- To confirm that the behavoir of first 8 sectors not being erased is enforced by the SSD controller instead of mSATA-to-USB chip: 9. I then installed this old Plextor SSD as an internal mSATA drive without USB enclosure. The first 8 sectors still survived after hdparm --trim-sector-ranges-stdin. 10. I have another newer Kingston-branded mSATA SSD. I tested it with hdparm --trim-sector-ranges-stdin, but all sectors went zero without one single exception, no matter it's USB-enclosed or directly installed as an internal drive.
Asked by segfault_bilibili (11 rep)
Sep 15, 2023, 10:40 AM
Last activity: Sep 15, 2023, 10:42 AM