[Solved]Relocating Chrome Cache to Flash Drive

Questions about applications and software
Forum rules
Before you post please read how to get help
Post Reply
User avatar
LanceM
Level 9
Level 9
Posts: 2811
Joined: Sun Jul 08, 2018 11:50 pm

[Solved]Relocating Chrome Cache to Flash Drive

Post 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?
Last edited by LanceM on Mon Jan 06, 2020 10:18 pm, edited 1 time in total.
To mark this issue solved, go to your original 1st post and click the edit pencil and add [Solved] at the beginning of the title and click Submit.
Mint accepts donations: https://linuxmint.com/donors.php

rene
Level 16
Level 16
Posts: 6584
Joined: Sun Mar 27, 2016 6:58 pm

Re: Relocating Chrome Cache

Post 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.

User avatar
LanceM
Level 9
Level 9
Posts: 2811
Joined: Sun Jul 08, 2018 11:50 pm

Re: Relocating Chrome Cache

Post 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)?
To mark this issue solved, go to your original 1st post and click the edit pencil and add [Solved] at the beginning of the title and click Submit.
Mint accepts donations: https://linuxmint.com/donors.php

rene
Level 16
Level 16
Posts: 6584
Joined: Sun Mar 27, 2016 6:58 pm

Re: Relocating Chrome Cache

Post 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.

User avatar
LanceM
Level 9
Level 9
Posts: 2811
Joined: Sun Jul 08, 2018 11:50 pm

Re: Relocating Chrome Cache

Post 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
To mark this issue solved, go to your original 1st post and click the edit pencil and add [Solved] at the beginning of the title and click Submit.
Mint accepts donations: https://linuxmint.com/donors.php

rene
Level 16
Level 16
Posts: 6584
Joined: Sun Mar 27, 2016 6:58 pm

Re: Relocating Chrome Cache

Post 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.

User avatar
LanceM
Level 9
Level 9
Posts: 2811
Joined: Sun Jul 08, 2018 11:50 pm

Re: Relocating Chrome Cache

Post 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/
To mark this issue solved, go to your original 1st post and click the edit pencil and add [Solved] at the beginning of the title and click Submit.
Mint accepts donations: https://linuxmint.com/donors.php

rene
Level 16
Level 16
Posts: 6584
Joined: Sun Mar 27, 2016 6:58 pm

Re: Relocating Chrome Cache

Post 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...)

User avatar
LanceM
Level 9
Level 9
Posts: 2811
Joined: Sun Jul 08, 2018 11:50 pm

Re: Relocating Chrome Cache

Post 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.
To mark this issue solved, go to your original 1st post and click the edit pencil and add [Solved] at the beginning of the title and click Submit.
Mint accepts donations: https://linuxmint.com/donors.php

User avatar
LanceM
Level 9
Level 9
Posts: 2811
Joined: Sun Jul 08, 2018 11:50 pm

Re: [Solved]Relocating Chrome Cache to Flash Drive

Post 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.
To mark this issue solved, go to your original 1st post and click the edit pencil and add [Solved] at the beginning of the title and click Submit.
Mint accepts donations: https://linuxmint.com/donors.php

rene
Level 16
Level 16
Posts: 6584
Joined: Sun Mar 27, 2016 6:58 pm

Re: [Solved]Relocating Chrome Cache to Flash Drive

Post 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.

User avatar
LanceM
Level 9
Level 9
Posts: 2811
Joined: Sun Jul 08, 2018 11:50 pm

Re: [Solved]Relocating Chrome Cache to Flash Drive

Post 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 223 times
If I plug it in and restart the PC, it recovers it to the folder with the arrow, so it's ok.
To mark this issue solved, go to your original 1st post and click the edit pencil and add [Solved] at the beginning of the title and click Submit.
Mint accepts donations: https://linuxmint.com/donors.php

User avatar
LanceM
Level 9
Level 9
Posts: 2811
Joined: Sun Jul 08, 2018 11:50 pm

Re: [Solved]Relocating Chrome Cache to Flash Drive

Post 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.
To mark this issue solved, go to your original 1st post and click the edit pencil and add [Solved] at the beginning of the title and click Submit.
Mint accepts donations: https://linuxmint.com/donors.php

rene
Level 16
Level 16
Posts: 6584
Joined: Sun Mar 27, 2016 6:58 pm

Re: [Solved]Relocating Chrome Cache to Flash Drive

Post by rene »

Probably nowhere.

User avatar
LanceM
Level 9
Level 9
Posts: 2811
Joined: Sun Jul 08, 2018 11:50 pm

Re: [Solved]Relocating Chrome Cache to Flash Drive

Post by LanceM »

Maybe it defaults to RAM?
To mark this issue solved, go to your original 1st post and click the edit pencil and add [Solved] at the beginning of the title and click Submit.
Mint accepts donations: https://linuxmint.com/donors.php

rene
Level 16
Level 16
Posts: 6584
Joined: Sun Mar 27, 2016 6:58 pm

Re: [Solved]Relocating Chrome Cache to Flash Drive

Post 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.

User avatar
LanceM
Level 9
Level 9
Posts: 2811
Joined: Sun Jul 08, 2018 11:50 pm

Re: [Solved]Relocating Chrome Cache to Flash Drive

Post 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.
To mark this issue solved, go to your original 1st post and click the edit pencil and add [Solved] at the beginning of the title and click Submit.
Mint accepts donations: https://linuxmint.com/donors.php

Post Reply

Return to “Software & Applications”