Question on fstrim not operating the way I expected.
"Michael D. Setzer II" <[email protected]> Mon, 1 Jun 2026 00:26:52 +1000
| Newsgroups | org.kernel.vger.util-linux |
|---|---|
| Message-ID | <[email protected]> |
Have maintain a disk imaging program going back to 2004, and had script to clean partitions by writing nulls to unused sectors. But with solid state drives that added wear to drives. Thought fstrim would be a better solution. My G4L program loads in ram with no partitions mounted. It then mounts the partition and runs fstrim once showing the space it finds, and then runs again show 0 space to trim. Then partitions are unmount before backing up the partitions or drives. But if I run the fstrim again, it shows exactly the same numbers on first pass and then zeros on second pass. So looks like fstrim is only making changes to memory. Is very fast thou. Mad an image of a 1T drive with the fstrim process, and it created an 82G image file. Ran Zerofree which my script offers as a second option, and made another image file, and it produced a 78G image file? fstrim is very fast, but appears to not clear anything on physical disk. zerofree is a much longer process. Takes about 30 minutes on 1TB drive, but does only write to non-zero blocks. Older dd option would write to all unsed blocks, so would put wear. Creating he image file takes about 34 minutes to image 1TB disk, but zerofree taking about 30 minutes make total time 64 minutes. Usually the fstrim only takes 10 to 30 seconds. Thanks. +------------------------------------------------------------+ Michael D. Setzer II - Computer Science Instructor (Retired) mailto:[email protected] mailto:[email protected] mailto:[email protected] Guam - Where America's Day Begins G4L Disk Imaging Project maintainer http://sourceforge.net/projects/g4l/ +------------------------------------------------------------+