Skip to content

Universal systemd service + script to prevent data loss from sudden power-off.

License

Notifications You must be signed in to change notification settings

PamJoshi/disk-unmount-daemon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”Œ disk-unmount-daemon

Safe automatic disk unmounting service for Linux

License: MIT Platform systemd Service


πŸš€ Overview

disk-unmount-daemon is a universal systemd service + shell script that automatically stops ongoing processes and unmounts selected disk partitions before shutdown, reboot, or halt.

It prevents:

  • ❌ Filesystem corruption
  • ❌ Bad sectors
  • ❌ Lost data during power cuts

Works with any filesystem: ext4, NTFS, FAT32, exFAT, Btrfs, etc.


✨ Features

  • πŸ›‘ Automatically unmounts drives before shutdown
  • πŸ”„ Works on any filesystem / OS partition
  • πŸ“„ Logs all unmount attempts to /var/log/unmount-windows-drives.log
  • 🧹 Log trimmed to last 10 entries
  • ⚑ Forces unmount with umount -f
  • πŸ”§ Minimal, reliable, and easy to customize

πŸ—‚ Repository Contents

File Description
safe-unmount.sh Script to unmount drives and log actions
safe-unmount.service systemd service for auto-unmount
safe-unmount-setup.sh Optional interactive setup installer

πŸ›  Installation

1️⃣ Copy script & service

sudo cp safe-unmount.sh /usr/local/bin/
sudo chmod +x /usr/local/bin/safe-unmount.sh

sudo cp safe-unmount.service /etc/systemd/system/
     _ _     _                                                 _            _                                  
  __| (_)___| | __     _   _ _ __  _ __ ___   ___  _   _ _ __ | |_       __| | __ _  ___ _ __ ___   ___  _ __  
 / _` | / __| |/ /____| | | | '_ \| '_ ` _ \ / _ \| | | | '_ \| __|____ / _` |/ _` |/ _ \ '_ ` _ \ / _ \| '_ \ 
| (_| | \__ \   <_____| |_| | | | | | | | | | (_) | |_| | | | | ||_____| (_| | (_| |  __/ | | | | | (_) | | | |
 \__,_|_|___/_|\_\     \__,_|_| |_|_| |_| |_|\___/ \__,_|_| |_|\__|     \__,_|\__,_|\___|_| |_| |_|\___/|_| |_|
                                                                                                               

About

Universal systemd service + script to prevent data loss from sudden power-off.

Topics

Resources

License

Stars

Watchers

Forks

Languages