Sample Header Ad - 728x90

How to merge two directories with failover?

1 vote
1 answer
59 views
Lets say I have two devices: - /dev/sda1 mounted to / (system partition) - /dev/sdb1 mounted to /media/data (data partition, usb device may be unplugged) I want to merge/overlay/raid two directories like so: - /media/data is the primary directory - /usr/data is the backup/failover directory that exists on the system partition The resulting directory (e.g /mnt/merged) will consist of the above two directories so that: - when writing a file to /mnt/merged the file will be written to /media/data - if the /dev/sdb1 is not available while writing (the usb storage is removed) then write to the backup /usr/data and when the primary partition is plugged again move the data to the primary partition - (optional) setup the second partition as a cache partition in case it is faster than the primary partition, so that reads and writes happen to the backup (faster) directory before moving to the primary directory
Asked by MOHAMMAD RASIM (530 rep)
May 25, 2025, 12:08 PM
Last activity: May 26, 2025, 03:53 PM