Introduction
When using a solid state drive in Linux several configuration changes should be made to optimize its operation (ArchLinux: Solid State Drives).
The BeagleBone Black does not have and SSD but it use flash memory in the form of a microSD card. And it can benefit from similar optimizations to those of SSDs.
This document describes the options that worked with the BeagleBone Black.
Periodic TRIM Using cron
To periodically discard unneeded bytes from the disc the fstrim
program can be used.
To run this daily using cron, the following script can be placed in
/etc/cron.daily/fstrim
.
#!/bin/sh
OUT="$(fstrim -v /)"
logger "fstrim.sh: ${OUT}"
To see if there were bytes to be discarded it can be manually run.
root:~# fstrim -v /
/: 4928004096 bytes were trimmed
root:~#
Mount Options
The noatime
is good for reducing writes which can be
costly with flash devices.
The following is an /etc/fstab
from a BeagleBone Black.
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/mmcblk0p5 during installation
UUID=3b08c2a7-b255-4c91-a71c-45456202bf48 / ext4 noatime,errors=remount-ro 0 1
# swap was on /dev/mmcblk0p6 during installation
UUID=01421e62-2159-4e7b-a888-54cf3140794c none swap sw 0 0
/dev/mmcblk0p1 /boot/uboot auto defaults 0 0
I/O Scheduler
The I/O Schedule should be changed from cfq
which was optimized
for spinning hard drives to noop
or deadline
.
The following is an /etc/rc.local
script which would
change the scheduler to noop
on bootup.
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
echo noop > /sys/block/mmcblk0/queue/scheduler
echo noop > /sys/block/mmcblk1/queue/scheduler
exit 0