Skip to content

Instantly share code, notes, and snippets.

@sepastian
Last active March 10, 2023 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sepastian/73a420d6d9112206681f0995e4603c3b to your computer and use it in GitHub Desktop.
Save sepastian/73a420d6d9112206681f0995e4603c3b to your computer and use it in GitHub Desktop.
ext4 file system tuning

From: https://cromwell-intl.com/open-source/performance-tuning/file-systems.html.

Mount Parameters

Disable recording of access times when mounting the FS.

For example, find with access times enabled would upate the access time of every file found.

# /etc/fstab
/dev/mapper/x220--vg-root / ext4 errors=remount-ro,nodiratime,relatime 0 1

Adding nodiratime and relatime will disable access times for direcotire, and update access times for files only, when modifying the file.

Defragmentation

Check the fragmentation of free space with:

sudo e2freefrag /dev/mapper/x220--vg-root

Check the number of extents info which a file has been fragmented:

sudo filefrag CentOS-x86_64.iso

Check, if defragmentation is required:

sudo e4defrag -c /home

Perform defragmentation:

sudo e4defrag /home

Defragmentation may take a long time. Faster:

The easiest and fastest way to get a less fragmented file system is to back up all your data to another volume. Then create a new file system within the old volume and copy the data back into place.

Trimming SSD Drives

Without trimming, SSD performance degrades over time.

We distinguish between continous trimming, using the discard mount option, and periodic trimming, for example once every week. Disable continous trimming, then enable periodic trimming with:

sudo systemctl enable fstrim.timer
sudo systemctl start fstrim.timer

From: https://wiki.debian.org/%20SSDOptimization

Monitoring HDD (and System) Performance

Install sysstat, enable the collector, use sar to view logs. See https://www.catalyst2.com/knowledgebase/server-management/how-to-install-configure-sysstat/ and https://www.catalyst2.com/knowledgebase/server-management/how-to-use-the-sar-utility/.

sudo apt install sysstat
sudo systemctl enable --now sysstat # enable and start collecting now;
                                    # default interval is 10 min, keep 28 days worth of data

# sar examples:

sar -rh     # memory usage, current day

sar -b 3 10 # current usage, every 3 sec, 10 times
Linux 5.10.0-21-686-pae (openhab) 	03/10/2023 	_i686_	(2 CPU)

05:33:15 PM       tps      rtps      wtps      dtps   bread/s   bwrtn/s   bdscd/s
05:33:18 PM      0.33      0.00      0.33      0.00      0.00      2.67      0.00
05:33:21 PM      0.67      0.00      0.67      0.00      0.00     10.67      0.00
:
05:33:45 PM      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:         1.60      0.00      1.60      0.00      0.00     13.33      0.00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment