UFS UFS: zeroing free space

With UFS:
  • how best to write zeros (or whatever) into free space?
In this case: to allow better compaction of the underlying virtual disk.

1636422049256.png

(Above: 73 G, compacted, for a system that uses only 12 G.)
 
Does the underlying virtual disk support trim? …

Good thinking. I enabled solid state for the virtual disk, then made some attempts:

1636519204334.png1636519350573.png

– at least in single user mode, the operation is not permitted.

Ignoring the fourth attempt (on a disk that was not virtually solid state), were the first three commands properly constructed?

If trim(8) can not automatically limit itself to unused space, is it risky?
 
Wait ... as far as I remember, the trim command trims the whole device, not just the parts that are not allocated by the file system! I think you really don't want that. And the "permission denied" error is probably that you can't use state-changing commands on devices that have mounted file systems.

If these partitions have file systems on them, you need to do the proper trick to enable trim. For UFS, that's tunefs to enable trim (look at the man page), followed by a special command line option to fsck_ufs (again, easy to find in the manpage) that trims stuff that had been deleted earlier. For ZFS, I don't know how to do it, but I vaguely remember discussions here on the forum about it.
 
Yup I just enabled trim on my gmirror on my firewall tonight.
Didn't realize it was not enabled.
Needed to boot to single user mode because of "permission denied".

Sucess:
Code:
oot@X9SRL:/home/firewall # tunefs -p /dev/mirror/gm0p2
tunefs: POSIX.1e ACLs: (-a)                                disabled
tunefs: NFSv4 ACLs: (-N)                                   disabled
tunefs: MAC multilabel: (-l)                               disabled
tunefs: soft updates: (-n)                                 enabled
tunefs: soft update journaling: (-j)                       disabled
tunefs: gjournal: (-J)                                     disabled
tunefs: trim: (-t)                                         enabled
tunefs: maximum blocks per file in a cylinder group: (-e)  4096
tunefs: average file size: (-f)                            16384
tunefs: average number of files in a directory: (-s)       64
tunefs: minimum percentage of free space: (-m)             8%
tunefs: space to hold for metadata blocks: (-k)            6400
tunefs: optimization preference: (-o)                      time
tunefs: volume label: (-L)

I dunno about whole device as /EFI will not trim.
 
You guys are reminding me that the SSD my FreeBSD server boots from is now getting seriously old. It has been powered on for over 6 years (and I got it from a stack of SSDs that were being thrown away in the office, so it is probably 11 or 12 years old). It doesn't even support trim. Guess I'll have to buy a new one soon.
 
Back
Top