Page 1 of 1

[Solved]Relocating Chrome Cache to Flash Drive

Posted: Mon Jan 06, 2020 7:10 pm
by LanceM
For the purpose of experimentation, I would like to know how to move /home/lance/.cache/google-chrome to a flash drive, that is permanently left plugged in including reboots. I can't find a valid reference online. Maybe someone knows the procedure?

Re: Relocating Chrome Cache

Posted: Mon Jan 06, 2020 7:29 pm
by rene
Either link ~/.cache/google-chrome to, say, /mnt/flash/google-chrome, or supply the command-line parameter --disk-cache-dir=/mnt/flash/google-chrome when you start it, i.e., on the Exec= line of /usr/share/applications/google-chrome.desktop if you start it always from the menus.

Re: Relocating Chrome Cache

Posted: Mon Jan 06, 2020 8:37 pm
by LanceM
Thanks rene. I'm a bit unclear. I start Chrome from the panel. The command-line parameter --disk-cache-dir=/mnt/flash/google-chrome method: Is flash the name of the flash drive (configured with Disks, to mount on startup and not show on desktop with the label flash)?

Re: Relocating Chrome Cache

Posted: Mon Jan 06, 2020 8:50 pm
by rene
/mnt/flash is the directory that you mount that flash drive on. Try looking in /etc/fstab to see what that directory/mountpoint is if you don't know.

Re: Relocating Chrome Cache

Posted: Mon Jan 06, 2020 9:08 pm
by LanceM
Here's the flash drive in Disks and ect/fstab It's formatted without a partition table with Btrfs.
What do I do?
Disks.jpg
Fstab.jpg

Re: Relocating Chrome Cache

Posted: Mon Jan 06, 2020 9:50 pm
by rene
blueocean wrote:
Mon Jan 06, 2020 9:08 pm
What do I do?
Sit on the porch and read a book. Or, if desperately need be, note the information denoting the "mountpoint" as /mnt/X. I.e., move with Chrome closed your existing cache:

Code: Select all

sudo mv ~/.cache/google-chrome /mnt/X/
and either simply link it back:

Code: Select all

ln -s /mnt/X/google-chrome ~/.cache/
or change in the mentioned .desktop file /usr/share/applications/google-chrome.desktop the Exec= lines to

Code: Select all

Exec=/usr/bin/google-chrome-stable --disk-cache-dir=/mnt/X/google-chrome <other already present parameters, i.e., once %U, once nothing and once --incognito>
Former would I feel be preferred but YMMV.

Re: Relocating Chrome Cache

Posted: Mon Jan 06, 2020 9:57 pm
by LanceM
It's -2F in the porch, so I'll do the latter :D
Thanks and it worked. Now one more request. What exactly do I do to reverse this back to default? I used

Code: Select all

ln -s /mnt/X/google-chrome ~/.cache/

Re: Relocating Chrome Cache

Posted: Mon Jan 06, 2020 10:07 pm
by rene
Delete the symbolic link and move back the cache directory:

Code: Select all

$ rm ~/.cache/google-chrome
$ sudo mv /mnt/X/google-chrome ~/.cache/
(note that the use of mv here and above rather than e.g. cp keeps you as the owner of the cache directory which is important for Chrome's access rights when started by you; never mind if this remark does not make sense; just be mildly aware of it...)

Re: Relocating Chrome Cache

Posted: Mon Jan 06, 2020 10:17 pm
by LanceM
Much appreciated rene. With my best flash drive it's pretty responsive. Not as good as an SSD, but on par with a 5400 Rpm HDD. I'm going to re-title this post to include flash drive and mark it solved.

Re: [Solved]Relocating Chrome Cache to Flash Drive

Posted: Tue Jun 02, 2020 2:43 pm
by LanceM
and either simply link it back:
I've discovered that even though the /.cache/google-chrome has a shortcut arrow on it and is writing the cache do flash drive X, it is also still duplicating everything to the /.cache/google-chrome folder. Being as this is happening the writes to the SSD remain the same. I'm wondering if the /.cache/google-chrome needs to be moved by a different method? By that, I mean starting completely over.

Re: [Solved]Relocating Chrome Cache to Flash Drive

Posted: Tue Jun 02, 2020 3:09 pm
by rene
LanceM wrote:
Tue Jun 02, 2020 2:43 pm
I've discovered that even though the /.cache/google-chrome has a shortcut arrow on it and is writing the cache do flash drive X, it is also still duplicating everything to the /.cache/google-chrome folder.
That statement does not make sense I'm afraid. if ~/.cache/google-chrome is a symlink to /mnt/X/google-chrome then it's not a folder: is a link to a folder, and you can as such merrily e.g. cd into it, but if you do, you are actually in /mnt/X/google-chrome. Just look at the output of ls. If it shows it as a symbolic link, all is fine:

Code: Select all

$ ls -l ~/.cache/google-chrome 
lrwxrwxrwx 1 lance lance 20 jun  2 21:04 /home/lance/.cache/google-chrome -> /mnt/X/google-chrome
Also, if you want e.g. cd to resolve symbolic links, say e.g. cd -P ~/.cache/google-chrome. This would place you in /mnt/X/google-chrome. All is assumedly well, that is.

Re: [Solved]Relocating Chrome Cache to Flash Drive

Posted: Tue Jun 02, 2020 4:31 pm
by LanceM
I attached a before moving and after pic. You can see the folder with the shortcut arrow. I see what you mean about it being in X. I can create a folder in /home/.cache/google-chrome and it immediately shows up in /mnt/X/google-chrome. So it is working. I'll reevaluate the writes more carefully over a longer period.
Before-Moving.jpg
After-Moving.jpg
If I forget to plug the flash drive in it looks like this:
Forgot-Drive.jpg
Forgot-Drive.jpg (2.23 KiB) Viewed 213 times
If I plug it in and restart the PC, it recovers it to the folder with the arrow, so it's ok.

Re: [Solved]Relocating Chrome Cache to Flash Drive

Posted: Tue Jun 02, 2020 4:35 pm
by LanceM
One puzzle though, is if I forget the plug the flash drive in and click on Chrome, it still works, but the /home.cache/google-chrome file as in the 3rd pic is unchanged and no new folder with that name is created. So where on earth is the chrome cache being put then? Not X because it's not attached.

Re: [Solved]Relocating Chrome Cache to Flash Drive

Posted: Tue Jun 02, 2020 5:49 pm
by rene
Probably nowhere.

Re: [Solved]Relocating Chrome Cache to Flash Drive

Posted: Tue Jun 02, 2020 6:34 pm
by LanceM
Maybe it defaults to RAM?

Re: [Solved]Relocating Chrome Cache to Flash Drive

Posted: Tue Jun 02, 2020 7:54 pm
by rene
LanceM wrote:
Tue Jun 02, 2020 6:34 pm
Maybe it defaults to RAM?
~/.cache/google-chrome is explicitly the disk cache, i.e., survives over restarts. So, yes, it does, but that's the same as saying "nowhere" --- well, certainly unless/until you're under memory pressure.

Re: [Solved]Relocating Chrome Cache to Flash Drive

Posted: Thu Jun 04, 2020 3:34 pm
by LanceM
After carefulling testing Chrome cache to a flash drive, it reduces the browser's writes to an SSD by roughly 20%. So indeed, it works.