Moving the Google Chrome cache directory onto RAM disk automatically at boot in Linux











up vote
0
down vote

favorite












OS: Linux Mint 19 Cinnamon 64-bit.





I know how to create a RAM disk (tmpfs), actually I have it mounted in /etc/fstab like so:



none    /ramdisk    tmpfs    size=2G,mode=0777    0    0


As you can see, it has 2 GiB, and is accessible to all users on my personal computer it does not matter anyways.





I know about --disk-cache-dir Google Chrome option. But I don't want to use it.



Reason being, I want to be able to run Chrome in whichever way I like, having the same RAM cache directory. There are simply too many ways I run my Chrome. What if I replaced an icon for instance? It is unusable for me at least.





I seek guidance on creating a shell script, which would create a symlink to Chrome cache directory onto my RAM disk, which is mounted as seen above.



That script I intend to put into root's cron using sudo crontab -e as follows:



@reboot /home/vlastimil/Development/sh/google-chrome-cache-ramdisk


Note, that I don't have a swap enabled on my system.










share|improve this question




























    up vote
    0
    down vote

    favorite












    OS: Linux Mint 19 Cinnamon 64-bit.





    I know how to create a RAM disk (tmpfs), actually I have it mounted in /etc/fstab like so:



    none    /ramdisk    tmpfs    size=2G,mode=0777    0    0


    As you can see, it has 2 GiB, and is accessible to all users on my personal computer it does not matter anyways.





    I know about --disk-cache-dir Google Chrome option. But I don't want to use it.



    Reason being, I want to be able to run Chrome in whichever way I like, having the same RAM cache directory. There are simply too many ways I run my Chrome. What if I replaced an icon for instance? It is unusable for me at least.





    I seek guidance on creating a shell script, which would create a symlink to Chrome cache directory onto my RAM disk, which is mounted as seen above.



    That script I intend to put into root's cron using sudo crontab -e as follows:



    @reboot /home/vlastimil/Development/sh/google-chrome-cache-ramdisk


    Note, that I don't have a swap enabled on my system.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      OS: Linux Mint 19 Cinnamon 64-bit.





      I know how to create a RAM disk (tmpfs), actually I have it mounted in /etc/fstab like so:



      none    /ramdisk    tmpfs    size=2G,mode=0777    0    0


      As you can see, it has 2 GiB, and is accessible to all users on my personal computer it does not matter anyways.





      I know about --disk-cache-dir Google Chrome option. But I don't want to use it.



      Reason being, I want to be able to run Chrome in whichever way I like, having the same RAM cache directory. There are simply too many ways I run my Chrome. What if I replaced an icon for instance? It is unusable for me at least.





      I seek guidance on creating a shell script, which would create a symlink to Chrome cache directory onto my RAM disk, which is mounted as seen above.



      That script I intend to put into root's cron using sudo crontab -e as follows:



      @reboot /home/vlastimil/Development/sh/google-chrome-cache-ramdisk


      Note, that I don't have a swap enabled on my system.










      share|improve this question















      OS: Linux Mint 19 Cinnamon 64-bit.





      I know how to create a RAM disk (tmpfs), actually I have it mounted in /etc/fstab like so:



      none    /ramdisk    tmpfs    size=2G,mode=0777    0    0


      As you can see, it has 2 GiB, and is accessible to all users on my personal computer it does not matter anyways.





      I know about --disk-cache-dir Google Chrome option. But I don't want to use it.



      Reason being, I want to be able to run Chrome in whichever way I like, having the same RAM cache directory. There are simply too many ways I run my Chrome. What if I replaced an icon for instance? It is unusable for me at least.





      I seek guidance on creating a shell script, which would create a symlink to Chrome cache directory onto my RAM disk, which is mounted as seen above.



      That script I intend to put into root's cron using sudo crontab -e as follows:



      @reboot /home/vlastimil/Development/sh/google-chrome-cache-ramdisk


      Note, that I don't have a swap enabled on my system.







      linux google-chrome cache browser-cache ramdisk






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 at 13:13

























      asked Sep 28 at 10:43









      Vlastimil

      1,09311333




      1,09311333






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          Supposing you have your RAM disk (tmpfs) mounted at boot time in /etc/fstab, you can do it as follows:




          1. First, make sure your script will exit on errors, this is important, don't skip this step.


          2. I recommend you start with constants definitions for an easy maintenance.


          3. I believe, but am unsure - feel free to correct me - you need to use absolute paths of commands since you intend to run the script from crontab.


          4. Actually, it appears, the which command below works without any problems, this command I used in this answer to ensure, that on each Linux wherever the binaries are, they are found.


          5. Create the directory structure on RAM disk for the Google Chrome cache.


          6. It will only work if you have access, so make yourself an owner of the whole RAM disk.


          7. Since we can't know what might happen, it would be a good idea to remove possibly existing cache directory (symlink or real).


          8. Finally, let's create a symlink for the cache directory onto your RAM disk.



          Note, that the solution below will create both:




          1. Normal Cache directory.


          2. In addition to the original solution, also the Media Cache directory, which will Chrome create upon loading some media.





          The final script could look like this (should be portable):



          #!/bin/sh

          ########################################################
          ## Google Chrome ##
          ## Cache on RAM disk ##
          ########################################################

          set -o nounset
          set -o errexit

          # constants definitions for easy edits
          username="vlastimil"
          ramdisk_path="/ramdisk"
          cache_path_ramdisk="${ramdisk_path}/google-chrome/Default"
          cache_path_userdir="/home/${username}/.cache/google-chrome/Default"

          # create directory structure on RAM disk
          $(which mkdir) -p "${cache_path_ramdisk}"

          # change ownership of RAM disk to my user
          $(which chown) -R "${username}":"${username}" "${ramdisk_path}"

          # remove possibly existing cache directory (symlink or real)
          $(which rm) -r -f "${cache_path_userdir}"

          # create symlink for cache directory onto RAM disk
          $(which ln) -s "${cache_path_ramdisk}" "${cache_path_userdir}"





          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1362184%2fmoving-the-google-chrome-cache-directory-onto-ram-disk-automatically-at-boot-in%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            Supposing you have your RAM disk (tmpfs) mounted at boot time in /etc/fstab, you can do it as follows:




            1. First, make sure your script will exit on errors, this is important, don't skip this step.


            2. I recommend you start with constants definitions for an easy maintenance.


            3. I believe, but am unsure - feel free to correct me - you need to use absolute paths of commands since you intend to run the script from crontab.


            4. Actually, it appears, the which command below works without any problems, this command I used in this answer to ensure, that on each Linux wherever the binaries are, they are found.


            5. Create the directory structure on RAM disk for the Google Chrome cache.


            6. It will only work if you have access, so make yourself an owner of the whole RAM disk.


            7. Since we can't know what might happen, it would be a good idea to remove possibly existing cache directory (symlink or real).


            8. Finally, let's create a symlink for the cache directory onto your RAM disk.



            Note, that the solution below will create both:




            1. Normal Cache directory.


            2. In addition to the original solution, also the Media Cache directory, which will Chrome create upon loading some media.





            The final script could look like this (should be portable):



            #!/bin/sh

            ########################################################
            ## Google Chrome ##
            ## Cache on RAM disk ##
            ########################################################

            set -o nounset
            set -o errexit

            # constants definitions for easy edits
            username="vlastimil"
            ramdisk_path="/ramdisk"
            cache_path_ramdisk="${ramdisk_path}/google-chrome/Default"
            cache_path_userdir="/home/${username}/.cache/google-chrome/Default"

            # create directory structure on RAM disk
            $(which mkdir) -p "${cache_path_ramdisk}"

            # change ownership of RAM disk to my user
            $(which chown) -R "${username}":"${username}" "${ramdisk_path}"

            # remove possibly existing cache directory (symlink or real)
            $(which rm) -r -f "${cache_path_userdir}"

            # create symlink for cache directory onto RAM disk
            $(which ln) -s "${cache_path_ramdisk}" "${cache_path_userdir}"





            share|improve this answer



























              up vote
              0
              down vote



              accepted










              Supposing you have your RAM disk (tmpfs) mounted at boot time in /etc/fstab, you can do it as follows:




              1. First, make sure your script will exit on errors, this is important, don't skip this step.


              2. I recommend you start with constants definitions for an easy maintenance.


              3. I believe, but am unsure - feel free to correct me - you need to use absolute paths of commands since you intend to run the script from crontab.


              4. Actually, it appears, the which command below works without any problems, this command I used in this answer to ensure, that on each Linux wherever the binaries are, they are found.


              5. Create the directory structure on RAM disk for the Google Chrome cache.


              6. It will only work if you have access, so make yourself an owner of the whole RAM disk.


              7. Since we can't know what might happen, it would be a good idea to remove possibly existing cache directory (symlink or real).


              8. Finally, let's create a symlink for the cache directory onto your RAM disk.



              Note, that the solution below will create both:




              1. Normal Cache directory.


              2. In addition to the original solution, also the Media Cache directory, which will Chrome create upon loading some media.





              The final script could look like this (should be portable):



              #!/bin/sh

              ########################################################
              ## Google Chrome ##
              ## Cache on RAM disk ##
              ########################################################

              set -o nounset
              set -o errexit

              # constants definitions for easy edits
              username="vlastimil"
              ramdisk_path="/ramdisk"
              cache_path_ramdisk="${ramdisk_path}/google-chrome/Default"
              cache_path_userdir="/home/${username}/.cache/google-chrome/Default"

              # create directory structure on RAM disk
              $(which mkdir) -p "${cache_path_ramdisk}"

              # change ownership of RAM disk to my user
              $(which chown) -R "${username}":"${username}" "${ramdisk_path}"

              # remove possibly existing cache directory (symlink or real)
              $(which rm) -r -f "${cache_path_userdir}"

              # create symlink for cache directory onto RAM disk
              $(which ln) -s "${cache_path_ramdisk}" "${cache_path_userdir}"





              share|improve this answer

























                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                Supposing you have your RAM disk (tmpfs) mounted at boot time in /etc/fstab, you can do it as follows:




                1. First, make sure your script will exit on errors, this is important, don't skip this step.


                2. I recommend you start with constants definitions for an easy maintenance.


                3. I believe, but am unsure - feel free to correct me - you need to use absolute paths of commands since you intend to run the script from crontab.


                4. Actually, it appears, the which command below works without any problems, this command I used in this answer to ensure, that on each Linux wherever the binaries are, they are found.


                5. Create the directory structure on RAM disk for the Google Chrome cache.


                6. It will only work if you have access, so make yourself an owner of the whole RAM disk.


                7. Since we can't know what might happen, it would be a good idea to remove possibly existing cache directory (symlink or real).


                8. Finally, let's create a symlink for the cache directory onto your RAM disk.



                Note, that the solution below will create both:




                1. Normal Cache directory.


                2. In addition to the original solution, also the Media Cache directory, which will Chrome create upon loading some media.





                The final script could look like this (should be portable):



                #!/bin/sh

                ########################################################
                ## Google Chrome ##
                ## Cache on RAM disk ##
                ########################################################

                set -o nounset
                set -o errexit

                # constants definitions for easy edits
                username="vlastimil"
                ramdisk_path="/ramdisk"
                cache_path_ramdisk="${ramdisk_path}/google-chrome/Default"
                cache_path_userdir="/home/${username}/.cache/google-chrome/Default"

                # create directory structure on RAM disk
                $(which mkdir) -p "${cache_path_ramdisk}"

                # change ownership of RAM disk to my user
                $(which chown) -R "${username}":"${username}" "${ramdisk_path}"

                # remove possibly existing cache directory (symlink or real)
                $(which rm) -r -f "${cache_path_userdir}"

                # create symlink for cache directory onto RAM disk
                $(which ln) -s "${cache_path_ramdisk}" "${cache_path_userdir}"





                share|improve this answer














                Supposing you have your RAM disk (tmpfs) mounted at boot time in /etc/fstab, you can do it as follows:




                1. First, make sure your script will exit on errors, this is important, don't skip this step.


                2. I recommend you start with constants definitions for an easy maintenance.


                3. I believe, but am unsure - feel free to correct me - you need to use absolute paths of commands since you intend to run the script from crontab.


                4. Actually, it appears, the which command below works without any problems, this command I used in this answer to ensure, that on each Linux wherever the binaries are, they are found.


                5. Create the directory structure on RAM disk for the Google Chrome cache.


                6. It will only work if you have access, so make yourself an owner of the whole RAM disk.


                7. Since we can't know what might happen, it would be a good idea to remove possibly existing cache directory (symlink or real).


                8. Finally, let's create a symlink for the cache directory onto your RAM disk.



                Note, that the solution below will create both:




                1. Normal Cache directory.


                2. In addition to the original solution, also the Media Cache directory, which will Chrome create upon loading some media.





                The final script could look like this (should be portable):



                #!/bin/sh

                ########################################################
                ## Google Chrome ##
                ## Cache on RAM disk ##
                ########################################################

                set -o nounset
                set -o errexit

                # constants definitions for easy edits
                username="vlastimil"
                ramdisk_path="/ramdisk"
                cache_path_ramdisk="${ramdisk_path}/google-chrome/Default"
                cache_path_userdir="/home/${username}/.cache/google-chrome/Default"

                # create directory structure on RAM disk
                $(which mkdir) -p "${cache_path_ramdisk}"

                # change ownership of RAM disk to my user
                $(which chown) -R "${username}":"${username}" "${ramdisk_path}"

                # remove possibly existing cache directory (symlink or real)
                $(which rm) -r -f "${cache_path_userdir}"

                # create symlink for cache directory onto RAM disk
                $(which ln) -s "${cache_path_ramdisk}" "${cache_path_userdir}"






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Oct 20 at 5:20

























                answered Sep 28 at 10:43









                Vlastimil

                1,09311333




                1,09311333






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1362184%2fmoving-the-google-chrome-cache-directory-onto-ram-disk-automatically-at-boot-in%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    QoS: MAC-Priority for clients behind a repeater

                    Ивакино (Тотемский район)

                    Can't locate Autom4te/ChannelDefs.pm in @INC (when it definitely is there)