Proxmox VE LXC Filesystem Trim #805
MickLesk
announced in
Announcements
Replies: 1 comment
-
why run trim on lxc? Isn't it better to run trim on the host? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
With traditional hard disk drives (HDDs or spinner disks), there isn't a significant performance penalty for leaving empty blocks or unused space on the disk. This is because HDDs use spinning magnetic platters and mechanical read/write heads to access data. Therefore, the physical location of data on the disk doesn't impact performance significantly, and there's no need to actively manage unused space to maintain performance.
However, solid-state drives (SSDs) operate differently. SSDs use NAND flash memory to store data, and they have a limited number of write cycles per cell. As data is written, erased, and rewritten to the SSD, performance can degrade over time due to the way NAND flash memory works. Specifically, write operations are faster on empty blocks than on blocks that have been previously written and need to be erased before new data can be written.
fstrim is a command used with SSDs to inform the drive which blocks of data are no longer considered in use by the filesystem so that the drive can internally erase them and prepare them for new data. This helps maintain consistent performance on SSDs over time and prevents degradation due to inefficient write operations.
Similarly, thin-provisioned storage technologies like LVM-Thin, Ceph, and qcow2 allocate storage space dynamically as needed. Without proper management, unused blocks within these storage systems can continue to occupy space, causing storage usage to grow unnecessarily.
Therefore, it's essential to periodically trim SSDs and manage unused space in thin-provisioned storage systems to optimize performance and prevent unnecessary consumption of storage resources.
VMs are configured to run fstrim automatically on a weekly basis, for LXC containers, it's necessary to perform fstrim manually or set up a separate automated process.
So, I created a script to run fstrim on all LXC containers (that are not selected to be skipped). This is designed to work with SSDs on ext4 filesystems only.
bash -c "$(wget -qLO - https://github.com/community-scripts/ProxmoxVE/raw/main/misc/fstrim.sh)"
Migrated from: tteck/Proxmox#2505
Beta Was this translation helpful? Give feedback.
All reactions