These are some old notes from when fstrim
was not available:
Nowadays, you can simply run fstrim
on most systems like this:
fstrim -v /
When we did not have fstrim
, one way of doing it was as follows:
First, you had to use hdparm
.
You had to compile it from source, because the one distributed with most Linux distros at that time did not support this feature yet.
Then, with the newest hdparm
, you ran:
SIZE=$(sudo blockdev --getsize /dev/sda);
for ((x=0;x<$SIZE/4096;x++)); do
sudo hdparm --trim-sector-ranges $((x*4096)):4096
done