Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added first storage option as a RAM disk for Raspberry PI/Odroid users #7

Closed

Conversation

charliebabbitt1988
Copy link

@charliebabbitt1988 charliebabbitt1988 commented Oct 14, 2020

In addition to these changes to blue_hydra.rb, please consider augmenting your main README.md file with this information:

These instructions for configuring a RAM disk are for Debian based distros, but will work with other Linux variants

create RAM disk storage for use with the SQLite database that Blue Hydra uses

sudo mkdir /mnt/blue_hydra
sudo mount -t tmpfs -o rw,size=256M tmpfs /mnt/blue_hydra

for permanently fixed RAM disk in the OS

sudo cp -p -v /etc/fstab /etc/fstab.backup
vi /etc/fstab

add the following line to /etc/fstab

tmpfs /mnt/blue_hydra tmpfs rw,size=256M 0 0

reboot

if persistent storage of the data in blue_hydra.db is desired, then a service can be configured with systemd

sudo vi /lib/systemd/system/blue_hydra_ramdisk-sync.service

add the following to /lib/systemd/system/blue_hydra_ramdisk-sync.service

this assumes that you are running as root

[Unit]
Before=umount.target

[Service]
Type=oneshot
User=root
ExecStartPre=/bin/chown -Rf root /mnt/blue_hydra/
ExecStart=/usr/bin/rsync -ar /etc/blue_hydra/ /mnt/blue_hydra/
ExecStop=/usr/bin/rsync -ar /mnt/blue_hydra/ /etc/blue_hydra/
ExecStopPost=/bin/chown -Rf root /etc/blue_hydra
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

exit vi

sudo systemctl enable blue_hydra_ramdisk-sync.service
reboot

all of the above can be done, so as to mitigate constant writing to an SD card or eMMC module. This type of storage isn't known for its long term reliability.

Bring this fork up to date to the main branch
Updating develop branch from ZeroChaos main
Merge pull request #2 from ZeroChaos-/master
Updating to latest version from ZeroChaos master
Updating the develop branch from the master branch
Gave precedence to the /mnt/blue_hydra path if it exists in the OS.  This is so that constant writing to a sqlite file won't wear out storage on Mini PCs like the Raspberry Pi and/or Odroid.  SD cards and eMMC modules are not known for their long term reliability.
@ZeroChaos-
Copy link
Owner

I really don't like this at all. It's an odd corner case that shouldn't be written into the code at all. If you want to save the db on tmpfs use a symlink.

That said, based on a shocking amount of testing which I've done trying to solve speed issues, this will likely get you almost no speed improvement at all unless your sdcard is complete garbage. I did a lot of testing on tablet class emmc, so it was a little faster than most sdcards, but that was also a while ago, so sdcards have mostly caught up.

@ZeroChaos- ZeroChaos- closed this Oct 22, 2020
@charliebabbitt1988
Copy link
Author

This wasn't for speed gains, although that may be an unintended consequence. It was because SQLite constantly writes to the db file, which wears out the storage media.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants