Configuring and Using the Discard
The Discard command allows cleaning unused blocks on a disk. All BSU volumes support this command, provided that the operating system is compatible and properly configured.
This command has different names depending on the operating system (for example Trim, Discard or Unmap). In this guide, the command is named Discard. |
Using the Discard command reduces the space consumed by snapshots, and therefore their cost. It may also improve the IOPS (input output per second) performances. For more information, see About Volumes.
It is recommended to use the Discard command each time you create a snapshot. |
This technical guide describes 3 methods to configure and using the Discard command:
-
Launching the discard periodically
We recommend using this method. This method is applied by default to our official images since January 2024.
-
Launching the discard manually
-
Configuring the discard when mounting a volume
This method can be dangerous and must be used with full knowledge of the possible impact on the performance.
Making Sure the Discard is Available
Making Sure the Discard is Available on Linux
Use the following command:
$ lsblk -D /dev/vda
-
If the Discard is available, you will get information about the disk:
Result SampleNAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO vda 512 512B 2G 0 └─vda1 0 512B 2G 0
-
If the Discard is unavailable, the returned elements are set to
0
:Result SampleNAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO vda 0 0B 0B 0 └─vda1 0 0B 0B 0
Making Sure the Discard is Available on Windows
On Windows, you cannot check the availability of Discard on each disk.
Use the following command to check that automatic Discard detection is enabled:
fsutil behavior query DisableDeleteNotify
-
If the automatic Discard detection is activated, the command returns the following element:
Result SampleDisableDeleteNotify = 1 (Enabled)
-
If the automatic Discard detection is not activated, the command returns the following element:
Result SampleDisableDeleteNotify = 0 (Disabled)
Configuring and Using Methods of the Discard
We recommend using this method. This method is applied by default to our official images since January 2024. |
Launching the Discard Periodically
Method 1: Launching the Discard Periodically on Linux
-
View the service status with the following command:
$ systemctl status fstrim.timer
The command returns the following elements:
Result Sample● fstrim.timer - Discard unused blocks once a week Loaded: loaded (/usr/lib/systemd/system/fstrim.timer; disabled; vendor preset: disabled) Active: inactive (dead) Trigger: n/a Docs: man:fstrim
-
Activate and configure the task with the following command:
$ systemctl enable fstrim.timer
-
Make sure the task is defined with the following command:
$ systemctl list-timers
The command returns the following elements:
Result SampleNEXT LEFT LAST PASSED UNIT ACTIVATES Wed 2023-10-04 14:53:08 UTC 56min left Wed 2023-10-04 13:27:59 UTC 28min ago dnf-makecache.timer dnf-makecache.service Thu 2023-10-05 00:00:00 UTC 10h left n/a n/a unbound-anchor.timer unbound-anchor.service Thu 2023-10-05 12:44:59 UTC 22h left Wed 2023-10-04 12:44:59 UTC 1h 11min ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service Mon 2023-10-09 00:00:00 UTC 4 days left n/a n/a fstrim.timer fstrim.service 4 timers listed. Pass --all to see loaded but inactive timers, too.
-
View the task status with the following command:
$ systemctl status fstrim.timer
The command returns the following elements:
Result Sample● fstrim.timer - Discard unused blocks once a week Loaded: loaded (/usr/lib/systemd/system/fstrim.timer; enabled; vendor preset: disabled) Active: active (waiting) since Wed 2023-10-04 13:55:44 UTC; 1s ago Trigger: Mon 2023-10-09 00:00:00 UTC; 4 days left Docs: man:fstrim oct. 04 13:55:44 ip-10-0-0-00.website.exemple.com systemd[1]: Started Discard unused blocks once a week.
Launching the Discard Periodically on Windows
Windows is able to detect automatically if the disk is compatible with the Discard. A periodical task can be configured in the Disk Management.
-
In Disk Management, right-click a disk and click Properties.
-
In the Tools tab, click Optimize.
-
In the Scheduled optimization section, click Change settings.
-
Customize the frequency.
It is recommended to define a weekly frequency.
-
Click OK.