3 ms·
How do you make sure the empty space is trimmed? Can you trim a portion of a disk?
by chx 2y ago
How do you make sure the empty space is trimmed? Can you trim a portion of a disk?
- kasabali 2y agoAFAIK Windows runs TRIM when you format a partition. So you can create a dummy partition and format it. Then you can either delete or simply not use it. On Linux, blkdiscard can be used in the same manner (create a dummy partition and run blkdiscard on it ex. *blkdiscard /dev/sda2).
- bravetraveler 2y agoIf one prefers working with LVM for their devices, that can be a similar wrench. Making/removing a logical volume can do the same It depends on 'issue_discards' being set in the config This has drifted over time. I haven't quite rationalized why. Hoping someone can remind me if nothing else, away from a real computer for a bit.
- rzzzt 2y agoYou can go into Properties > Tools > Optimize, the same button that runs defrag on spinning drives runs TRIM on solid state devices.
- formerly_proven 2y agoWindows by default issues TRIMs basically instantly when deleting a file, and runs "Optimize disk" (which trims all free space) on a schedule by default as well.
- FooBarWidget 2y agoWhat about external SSDs over USB? How do you trim those?
- wtallis 2y agoThere are trim-equivalent commands in the ATA, SCSI, and NVMe command sets. So the OS can issue the SCSI command to the USB device that's using UASP, and the bridge chip inside the external SSD can translate that to the ATA or NVMe counterpart before passing it on to the SSD controller behind the bridge. Not all external SSDs or bridge chips actually support trim passthrough, but these days it's standard functionality.
- FooBarWidget 2y agoI wonder how to do it on macOS then. I have several external SSDs and none of them can be trimmed.
- wtallis 2y agohttps://kb.plugable.com/data-storage/trim-an-ssd-in-macos https://kb.plugable.com/data-storage/trim-an-ssd-in-macos Apparently macOS doesn't expose the ability for userspace to manually issue trim commands to block devices (or at least doesn't ship a suitable tool to do so), so the best available workaround is to tell the filesystem layer that it should do automatic trimming even on external drives.
- ciupicri 2y agoCreate a partition that you'll never use and run blkdiscard [1] from util-linux on it. [1]: https://man7.org/linux/man-pages/man8/blkdiscard.8.html https://man7.org/linux/man-pages/man8/blkdiscard.8.html / https://github.com/util-linux/util-linux/blob/master/sys-utils/blkdiscard.8.adoc https://github.com/util-linux/util-linux/blob/master/sys-uti...
- mananaysiempre 2y agoThe literal answer is yes, an ATA TRIM, SCSI UNMAP, or NVMe Deallocate command can cover whatever range on a device you feel like issuing it for. (The device, in turn, can clear all, none, or part of it.) On Linux, blkdiscard accepts the -o, --offset and -l, --length options (in bytes) that map more or less exactly to that. Making a(n unformatted) partition for the empty space and then trimming it is a valid workaround as well. But you’re most probably doing this on a device with nothing valuable on it, so you should be able to just trim the whole thing and then allocate and format whatever piece of it that you are planning to use.