Persistent directory in ramdisk
I have a ramdisk created via an fstab entry.
I want to move the user .cache into the ramdisk on boot. How can I create a .cache directory in a ramdisk at a point in time before any use is made of the .cache? If I can achieve this then I could place a symlink in ~/user pointing to the ramdisk .cache and so save many many writes to my new SSD I have searched and it appears that I need a script which is called from /etc/init.d and the closest I can find is that from this page: http://https://www.a-netz.de/blog/20...with-ramdisks/ Could that script be edited to just make a ramdisk followed by a .cache directory in it by editing out the copying parts and replacing them with the entry I now have in fstab followed by mkdir .cache? My apologies if using another's script is frowned on. |
The recommended place to put any user-written init.d code is at the end of
Code:
/etc/rc.local If you have a hard disk, it would probably be more efficient to use this as the target, rather than a RAM disk. Linux retains cacheable items for a considerable time, if it has spare memory. |
I have had to rethink the solution because I have established that some user temporary data has to be carried over a reboot.
In that case it would be quite complex as you suggest to move the whole user .cache to ram. I do have a hard disk so as you suggest, I could leave the browser data in ram for speed and reduced SSD writing, then move the remainder of .cache to HDD. There would be some loss of speed but set against the reduced SSD writing, worthwhile. Would a symlink work? I think it would in the case of .cache to HDD. My first attempt at a symlink to move the cache to ram locked up the boot after signing in and that makes me wary although I do have another temporary instance of xubuntu running on the HDD and could edit the symlink out. |
1 Attachment(s)
With firefox, you can control the cache size (via preferences) - I think the default is to use a lot of storage!
(see attachment) Perhaps a small or even zero size cache might be acceptable, provided it helps your SSD??? I would do all experimenting with symbolic links in a live environment, before changing any boot scripts. Can't see why it wouldn't work though. |
Moving the cache of firefox is easily done and I have done it. Chrome is another matter and as you suggest for firefox, I have reduced Chrome's cache to 1byte. Apparently zero cache does not work.
I don't want firefox to write anything to the SSD, not even 1 byte but do need the cache! I will try a symlink to HHD live as you suggest. Thanks. |
I don't know what applications or how you use your computer but your concerns about writing to ~/.cache might be misplaced. What does SMART indicate for its lifetime?
There are two specifications i.e. TBW (terabytes written) and DWPD (drive writes per day) for SSD endurance. TBW is the max number of terabytes written before a the drive is likely to fail and DWPD is the number of times you can overwrite the entire disk every day during the warranty period. Most users will find that modern SSDs have a lifetime equal to that of a mechanical hard drive. It is important that you use a kernel/filesystem that supports trim with the correct options and partitioned i.e aligned correctly. https://wiki.archlinux.org/index.php..._space_on_SSDs |
TRIM is supported and runs weekly I think and nowadays the partitions are automatically aligned, or so I read.
I think my OCZ drive has SMART software and will check. It is a brand new drive and I want it to last, that is all, I don't use drive intensive programs. I do have a swap partition and will look at swappiness. The link you posted is useful, thanks. |
You're overreacting to a problem that does not exist. The write limit of modern SSDs is so ridiculously high it's unreasonable to think that anybody will be able to hit it within the rest of the computer's lifetime under normal usage. The only way to hit it is with dedicated stress tests that run continuously, and it STILL takes years before any problems show up.
Turn down swappiness, turn off atime, and you're done. |
Guess one could use some sort of advanced raid type file system.
Personally, I'd consider a pcie ssd. https://www.engadget.com/2015/03/24/...-predator-ssd/ |
All times are GMT -5. The time now is 09:25 PM. |