Remounts external media with sync option

fatal_strategy e7aa2e731c Fix README markdown 3 years ago
README.md e7aa2e731c Fix README markdown 3 years ago
install.sh 0d799f7bb3 Initial commit 3 years ago
media-remount-syncd 0d799f7bb3 Initial commit 3 years ago
media-remount-syncd.service 0d799f7bb3 Initial commit 3 years ago
remove.sh 0d799f7bb3 Initial commit 3 years ago

README.md

In GNU/Linux distros everything is mounted with write caching enabled by default. This causes some nuissances with external storage devices:

  • progress statuses display the progress of writing to cache instead of the actual write operation to the device itself
  • data to be written is often still waiting in the cache after progress statuses show completition, causing people to mistakenly pull out devices prematurely
  • "safely removing" devices finally forces data to be actually written, but without any indication of how much time this will take

media-remount-syncd is an experimental workaround for the issues above.

It is a simple shell script that runs in the background as a systemd service and automatically remounts any new mounts in the /media directory with the sync option, which disables write caching. It uses findmnt --poll=mount to detect new mounts, then remounts them using mount -o remount,sync.

Install

sudo ./install.sh

Test

Plug-in (and mount) some external storage device, then run:

systemctl status media-remount-syncd.service

The output should contain "mount -o remount,sync" log lines.

Uninstall

sudo ./remove.sh