0

Are there any apps or any ways to cache and sync a hard disk directory with RAM? Currently I'm making a fake disk and RAM RAID.

Firstly, I make an .img file on hard disk:

qemu-img create -f raw /media/username/partitionname/ramraiddsk.img 2G

or using dd command, then run this command, each time after my PC reboots:

sudo mount -t tmpfs -o size=2100M,mode=0755 none /home/username/tmpfsdir/
sudo chown username:username /home/username/tmpfsdir/
qemu-img create -f raw /home/username/tmpfsdir/tmpfsi.img 2G
sudo rm /home/username/ramdsknod*
sudo mknod /home/username/ramdsknod0 b 7 0
sudo mknod /home/username/ramdsknod1 b 7 1
sudo losetup /home/username/ramdsknod0 /home/username/tmpfsdir/tmpfsi.img
sudo losetup /home/username/ramdsknod1 /media/username/partitionname/ramraiddsk.img
sudo mdadm -C /dev/md/ramraid -c64 -l1 -n2 missing /home/username/ramdsknod1 -R
sudo mdadm --manage /dev/md/ramraid --add /home/username/ramdsknod0
watch -d1 cat /proc/mdstat

After resync finish, I can mount the partition using file manager for ccache or some other cache directory. It is limited the disk size by raid1, and if my RAM is big enough I cannot use it for system because I need to run the script first. Are there any software or other methods that can emulate folders work on RAM and sync later to disk?

2
  • Use code formatting for command and command output please: askubuntu.com/editing-help#code
    – muru
    Mar 9, 2018 at 15:49
  • To format a block of terminal commands, select the block and press the {} button in the editor. Mar 9, 2018 at 16:49

0

You must log in to answer this question.

Browse other questions tagged .