Bug 93553 - Erasing partition with zeroes doesn't erase existing data
Summary: Erasing partition with zeroes doesn't erase existing data
Status: NEW
Alias: None
Product: udisks
Classification: Unclassified
Component: operations (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium major
Assignee: Martin Pitt
QA Contact:
Depends on:
Reported: 2016-01-01 17:42 UTC by Sylvain Pasche
Modified: 2016-04-16 23:04 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Description Sylvain Pasche 2016-01-01 17:42:45 UTC
I wanting to erase a partition containing existing data by creating a new partition from gnome-disk-utility by checking "Overwrite existing data with zeroes" when formatting the partition.

To my surprise, I ran "strings" on the just erased partition and I could still see old data.

This is a on Fedora 23 with udisks2-2.1.6-1.fc23.x86_64.

To reproduce:

# write some test data
yes sensitive_data > /dev/sda4
# status before the erase
strings /dev/sda4|grep sensitive_data|wc -l
# now erase the partition with zeroes
# status after erase
strings /dev/sda4|grep sensitive_data|wc -l

I ran strace on the udisksd process and I can see the writes to the drive:

27221 open("/dev/sda4", O_WRONLY|O_EXCL|O_SYNC) = 14
27221 ioctl(14, BLKGETSIZE64 <unfinished ...>
27221 <... ioctl resumed> , [536870912]) = 0

27221 write(14, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576) = 1048576

The partition is 536870912 bytes (512MB) large. There are 512 calls to write() with a buffer of 1048576 bytes. So in theory all of the partition should be overwritten (1048576 * 512 = 536870912), so I'm surprised to see such behavior.

The drive is a SSD from a Toshiba Portegé laptop.
Comment 1 Chris Murphy 2016-04-16 23:04:21 UTC
I think the overwrite with zeros option should only appear with physical block devices having /sys/../queue/rotational 1.

For anything else, logical devices including thin volumes, and SSDs, it should not exist. mkfs.xfs and mkfs.btrfs use full device trim to zero the device, and it's available with ext4 using -E discard.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.