ubuntu:disk:ramdisk:persisting_ramdisk_data
This is an old revision of the document!
Table of Contents
Ubuntu - Disk - Ramdisk - Persisting Ramdisk Data
A Ramdisk will usually lose all data within it when turned off, or upon a reboot.
The approach is:
- Save Ramdisk data to hard drive on system shutdown.
- Load data from hard drive to Ramdisk on system boot.
NOTE: The directory where the Ramdisk is mounted and where the backup data will be saved must have the same file permissions.
Create backup directory
Create a directory where the Ramdisk data will be saved on system shutdown:
sudo mkdir /mnt/ramdisk_backup
Create a system service file
vi /lib/systemd/system/ramdisk-sync.service
and populate with:
- /lib/systemd/system/ramdisk-sync.service
[Unit] Before=umount.target [Service] Type=oneshot User=root ExecStartPre=/bin/chown -Rf peter /mnt/ramdisk/ ExecStart=/usr/bin/rsync -ar /mnt/ramdisk_backup/ /mnt/ramdisk/ ExecStop=/usr/bin/rsync -ar /mnt/ramdisk/ /mnt/ramdisk_backup/ ExecStopPost=/bin/chown -Rf peter /mnt/ramdisk_backup RemainAfterExit=yes [Install] WantedBy=multi-user.target
ubuntu/disk/ramdisk/persisting_ramdisk_data.1624359661.txt.gz · Last modified: 2021/06/22 11:01 by peter