LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-11-2016, 08:29 PM   #1
makem
Member
 
Registered: Nov 2013
Posts: 209

Rep: Reputation: Disabled
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.
 
Old 06-12-2016, 06:55 PM   #2
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
The recommended place to put any user-written init.d code is at the end of
Code:
/etc/rc.local
If you reboot a PC, all data would be lost from a RAM cache and might need rebuilding.

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.
 
Old 06-13-2016, 05:15 AM   #3
makem
Member
 
Registered: Nov 2013
Posts: 209

Original Poster
Rep: Reputation: Disabled
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.
 
Old 06-13-2016, 08:32 AM   #4
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
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.
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2016-06-13 13:51:17.png
Views:	20
Size:	60.2 KB
ID:	22097  
 
Old 06-13-2016, 09:08 AM   #5
makem
Member
 
Registered: Nov 2013
Posts: 209

Original Poster
Rep: Reputation: Disabled
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.

Last edited by makem; 06-13-2016 at 09:10 AM.
 
Old 06-13-2016, 10:25 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,750

Rep: Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928
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
 
Old 06-13-2016, 11:14 AM   #7
makem
Member
 
Registered: Nov 2013
Posts: 209

Original Poster
Rep: Reputation: Disabled
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.
 
Old 06-13-2016, 12:44 PM   #8
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
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.
 
Old 06-13-2016, 04:26 PM   #9
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,001

Rep: Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629
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/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] mdadm raid 1 with SSD and Ramdisk: Force reading from Ramdisk only ratio Linux - Software 5 04-04-2014 03:35 PM
70-persistent-net.rules No such file or directory noizar Linux From Scratch 4 10-29-2013 06:31 AM
RAMDISK: couldn't find valid ramdisk image starting at 0. iotc247 Slackware 10 12-10-2010 03:08 PM
Knoppix. Persistent home directory confusion nads1978 Linux - Distributions 4 07-23-2008 07:33 AM
Creating ramdisk for directory tree. vaibhavk Linux - General 0 01-16-2002 11:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration