dd if=/dev/urandom of=/dev/sdx bs=4096 status=progress
This command will overwrite the entire drive with random data. That random data will stay there until you write other data, or secure-erase, or TRIM.
In other words, will the random data that I generated with dd still reside inside of the encrypted partitions that i create?
Normally this is the case.
However, it's not always obvious when TRIM happens. For example, mkfs
or mkswap/swapon
silently imply TRIM and you have to use additional parameters to disable it. I do not know if partitioners picked up the same idea and TRIM newly created partitions. If using LVM instead of partitions, note that lvremove
/ lvresize
/ etc. does imply TRIM if you have issue_discards = 1
in your lvm.conf
. Other storage layers such as mdadm
support TRIM as a simple pass-through operation.
cryptsetup open
by default does not allow TRIM unless you specify --allow-discards
, however some distributions might choose to change those defaults.
After all, it's very unusual to random-wipe SSD for encryption. The only use case I can think of is getting rid of old data while not trusting the hardware to do this for free when you TRIM or secure-erase.
Even with encryption, it's normal for free space to be visible on SSD. Most people will want to use TRIM weekly/monthly to avoid possible performance degradation in the long term, so distributions might follow that trend and use allow-discards
on encrypted devices by default.
Once trimmed, your overwriting with random data was for naught.
But as long as you are in control, and disable TRIM in everything you do, the random data will stay.